autotest with growl notifications
There’s a lot of tutorials out there, but this is what worked for me:
touch ~/.autotest
vim ~/.autotest
require 'autotest/redgreen'
require 'autotest/timestamp'
module Autotest::Growl
def self.growl title, msg, pri = 0, img = nil
title += " in #{Dir.pwd.split(/\//)[-3..-1].join("/")}"
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
# TODO: parameterize default image
img ||= "/Applications/Mail.app/Contents/Resources/Caution.tiff"
cmd = "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}"
system cmd
end
Autotest.add_hook :initialize do |at|
growl "autotest running", "Started"
end
Autotest.add_hook :red do |at|
growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2, "~/.autotest_images/rails_fail.png"
end
Autotest.add_hook :green do |at|
growl "Tests Passed", "Tests passed", -2, "~/.autotest_images/rails_ok.png" if at.tainted
end
Autotest.add_hook :all_good do |at|
growl "Tests Passed", "All tests passed", -2, "~/.autotest_images/rails_ok.png" if at.tainted
end
endI copied autotest/growl from the ZenTest source and just added red and green Rails logos for passes and fails.
mkdir ~/.autotest_images
wget these two files into ~/.autotest_images:
wget http://media.tumblr.com/1TEAMALps8blcxlteudb3JGo_400.png -O .autotest_images/rails_fail.png
wget http://media.tumblr.com/1TEAMALps8bld6f7K7NkG7bF_400.png -O .autotest_images/rails_ok.png


One big oversight I made the first time around was getting growlnotify installed. After you download Growl and mount the image, do this:
cd /Volumes/Growl/Extras/growlnotify
./install.sh
If you have Growl running, stop and start it. Run autotest and everything should be groovy now.