I’ve been watching some Peepcode stuff this weekend and I’m officially jealous of the Growl support. It turns out I’m not the only one. After surfing around for a while I found this :
ikhono.net: Gnome autotest Notifications
I had to update the regex to handle a change in the output of Rspec - but otherwise it works like a charm. (I also modified it to change the tray icon to the same icon it displays on the status update).
Here are my changes:
Autotest.add_hook :initialize do |at|
@notify = Notification.new
end
Autotest.add_hook :ran_command do |at|
results = at.results.flatten.join("\n")
unless results.nil?
output = results.match(/(\d+)\sexample[s]?,\s(\d+)\sfailure[s]?,\s(\d+)\spending/)
unless output
output = results.match(/(\d+)\sexample[s]?,\s(\d+)\sfailure[s]?/)
end
failures = 0
pending = 0
test_results = “”
if output
test_results = output[0]
failures = output[2].to_i
if output[3]
pending = output[3].to_i
end
end
if failures > 0
@notify.failed(”Tests Failed”, test_results)
elsif pending > 0
@notify.pending(”Tests Pending”, output)
else
unless at.tainted
@notify.passed(”All Tests Passed”, test_results)
else
@notify.passed(”Tests Passed”, test_results)
end
end
end
end