Being a person with a keen auditory sense, I wanted my autotest to give me sonic feedback as well as colored growl images.
The sndplay utility I have compiled as a universal binary comes from snd (a handy app I used all the time when I was at CCRMA) sndplay has the nice feature of controlling the volume, which is important for toning down the annoyance factor.
Here are the fun audio files that I use in my .autotest. And here is the code:
require 'autotest/redgreen'
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.to_s.slice(/(\d+).*errors/)
if output =~ /ns.*[1-9]/
system "~/bin/sndplay ~/Library/autotest/bonk.wav -volume 0.5"
growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s"
else
system "~/bin/sndplay ~/Library/autotest/om.aiff -volume 0.1"
growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
end
end
end
1/29/08 UPDATE: The autotest API has been updated to have sound playback hooks… examples here.
I got so hooked on redgreen autotest that I wanted to see green in my growl notifications. So I came up with this modification to Labrat’s advice on autotest and growl.
Greg and I decided we don’t like the sticky window for errors, hence we commented out the “-s” parameter. It took me awhile to realize that one can customize the display properties of different message priorities in the Growl control panel, but I prefer to change the image instead of the background color.
Add the following to your ~/.autotest file:
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.slice(/(\d+).*errors/)
if output =~ /ns.*[1-9]/
growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s"
else
growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
end
end
end
(Note: also make sure you comment out the “require ‘autotest/growl’” line at the top, as this replaces it.)
Here are the images that I use:

output = at.results.last.slice(/(\d+).*errors/)
