SQLTerminal.app
now available

XPath.app
now available
Want fresh tech tips in your inbox?

Color Output with Test:Unit, AutoTest and Ruby 1.9

       

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 w/ #autotest #color #hacks #ruby #tdd #testing #tools #workarounds #workflowruby #ruby on rails

Apps I've Built

XPath Expression Editor
Practice and improve your XPath skills with XPath Editor
Click to buy on the App Store
Photo Location Changer
Easily change the location on your photos and videos
Click here for more info about the app
Photo Date Changer
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app