如何在使用JRuby或bundle exec时使用rspec启用颜色?

时间:2022-03-13 23:26:53

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

我正试图用JRuby运行我的rspec:

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:

没有颜色出现,所以我从等式中删除了Jruby:

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:

没有颜色。如何将“--color”选项传递给rspec?我在项目的根目录中也有一个.rspec文件,在这些情况下似乎没有帮助。但是,当我运行时,会提取或使用.rspec文件:

rspec spec/foo_spec.rb

Any ideas?

有任何想法吗?

1 个解决方案

#1


24  

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

在调用中添加--tty可以解决我的问题:

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.

该选项告诉RSpec输出未写入文件(在这种情况下,您不希望彩色输出),而是发送到另一个进程。

#1


24  

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

在调用中添加--tty可以解决我的问题:

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.

该选项告诉RSpec输出未写入文件(在这种情况下,您不希望彩色输出),而是发送到另一个进程。