Using redgreen gem in Ruby 1.9

We all love autotest, don’t we? It’s an essential tool for TDD software development, no doubt about it.

redgreen adds a little sugar to how your test results are displayed on the console. It doesn’t work out-of-the box with Ruby 1.9, however it’s just a matter of a simple tweak in your ~/.autotest file.

Here’s an example of my ~/.autotest:

require "autotest/fsevent"
require "autotest/growl"

unless ENV["RSPEC"]
  PLATFORM = RUBY_PLATFORM unless defined? PLATFORM
  require "redgreen/autotest"
end

Autotest.add_hook :initialize do |at|
  %w{.svn .hg .git vendor}.each {|exception| at.add_exception exception}
end

For Ruby 1.9 be sure to define PLATFORM constant, and if you want to use both autotest and autospec you need the unless ENV["RSPEC"] ... end block.