Gnome and Autospec Notifications
I’m very keen on DBB with RSpec now and I wanted to share how I set up autospec notifications on Ubuntu (Jaunty 9.04) as long as the post I followed to do it is no longer available.
I’m using XCFE but should work perfectly on Gnome as well. This is an screenshot of what you’ll get in the end:

autospec notification XFCE/Gnome
First you need the ZenTest gem, you probably already do:
$ sudo gem install ZenTest $ sudo gem install redgreen
Then install the libnotify-bin package:
$ sudo apt-get install libnotify-bin
Here is the trick. Create a file called ~/.autotest with this:
#!/bin/ruby require 'redgreen' require 'autotest/timestamp' module Autotest::GnomeNotify def self.notify title, msg, img system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000" end Autotest.add_hook :ran_command do |at| image_root = "~/.autotest_images" results = [at.results].flatten.join("\n") results.gsub!(/\\e\[\d+m/,'') output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/) full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i) if output if failures > 0 notify "FAIL", "#{output}", "#{image_root}/fail.png" elsif pending > 0 notify "Pending", "#{output}", "#{image_root}/pending.png" else notify "Pass", "#{output}", "#{image_root}/pass.png" end end end end
As you can see I use the fail.png and pass.png images to show those cheesy smileys : ). You can download them here and copy them to ~/.autotest_images/.
Make your tests go green and have a beer! : )
Update: Added redgreen gem and changed “require redgreen” as Rodrigo Flores and rakk suggested. Thanks!
Update: Changed mistakenly escaped >. Thanks to Martin y Hunter for the comments.
Update: The script now supports pending examples. Thanks to Andy.
Update: Removed an extra end. Thanks to Andy again.
English
Español