Written by Sean Behan on Sun Jun 17th 2012

If you are testing using Test:Unit (rather than RSpec) and you're using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded and not available and will break your tests.

The solution is to require Test:Unit version 2.0.0 in your Gemfile, require the testrunner.rb script in test/test_helper.rb and reopen and implement the guess_color_availability method.

#test/test_helper.rb
require 'test/unit/ui/console/testrunner'

class Test::Unit::UI::Console::TestRunner
    def guess_color_availability 
        true 
    end
end

#Gemfile
group :development, :test do
    gem "minitest", "~> 2.10.0"
    gem "turn", "~> 0.8.3"
    gem 'test-unit', '~> 2.0.0'  
    gem 'autotest-rails'
end

Then you can just run the autotest command (or bundle exec autotest) from your project directory. When you save a file your tests will be run for the file that has been changed and the results will be fully colorized!


Tagged with..
#autotest #color #hacks #ruby #tdd #testing #tools #workarounds #workflow #ruby #Ruby on Rails

Just finishing up brewing up some fresh ground comments...