Can I get color highlighting on rails for the rake test command?

When running the rake test command from the terminal in the rails 3 project directory, the test result is not colored. Therefore, it cannot be interpreted at a glance.

Is there a way to get color output for the results, how can you get in rspec?

>rspec --colour 
+7
ruby-on-rails
source share
2 answers

Yes, you can use a reddish stone. Include it in your gemfile:

 group :development, :test do gem 'redgreen' end 

And all you need for ruby ​​1.8. If you are using 1.9, a workaround. add the gem to the test block:

 group :development, :test do gem 'redgreen' gem 'test-unit', '1.2.3 end 

It's not perfect with 1.9 - the test block seems to run an empty test suite after every rake or generator call, which is harmless but annoying.

+11
source share

I found that redgreen was abandoned many years ago and found this solution that works well and does not require a hack script. However, the output shows which test is being performed in real time. So this is much more than an integrated test output. It has nice colors.

http://rubygems.org/gems/turn

In my gemfile:

 group :test do gem 'turn' end 

Then run:

 $ bundle install $ rake test 

The "turn" gem works great. The danger is that it does not work with Mocha due to problems with intercepting monkeys. If you use Mocha, you can use a reddish stone. See Instructions in the approved answer to this question.

+21
source share

All Articles