How to enable colors with rspec when using JRuby or bundle exec?

↘锁芯ラ 提交于 2019-11-30 23:52:48

问题


I'm trying to run my rspec's with JRuby:

rake spec 

which results in:

jruby -S bundle exec rspec --color spec/foo_spec.rb

No colors show up, so I removed Jruby from the equation:

bundle exec rspec --color spec/foo_spec.rb

no colors. How can I get the "--color" option passed through to rspec? I've also got a .rspec file in the root directory of my project which doesn't seem to help in these cases. However, the .rspec file is picked-up or used when I just run:

rspec spec/foo_spec.rb

Any ideas?


回答1:


Adding --tty to the call fixes the problem for me:

jruby -S bundle exec rspec --tty --color spec/foo_spec.rb

The option tells RSpec that the output is not written to a file (in which case you wouldn't want colorized output), but send to another process instead.



来源:https://stackoverflow.com/questions/5091296/how-to-enable-colors-with-rspec-when-using-jruby-or-bundle-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!