If you watched the PeepCode episode about RSpec (the first of the trilogy), you may want something like growl on linux to get informed about the results of autotest. Well, there is such thing, but it is quite complicated.
You can use libnotify on Gnome, though. Those little alerts Ubuntu shows you (3 new updates, It’s time to restart your computer, Connected to Wireless Network etc), all uses libnotify. Let’s move on!
1) Install the libnotify-bin package via apt-get
2) Go to a terminal and type, remembering to change ZenTest-3.6.0 to your current version.
sudo gedit /usr/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest/gnomenotify.rb
3) Paste the following on the new file
# -*- ruby -*-
# Adapted from PeepCode RSpec screencast no 1,
# who got it from someone else!
# Adapted with tip from http://ph7spot.com/articles/getting_started_with_autotest
# by DitoCujo (http://ditoinfo.wordpress.com)
module Autotest::GnomeNotify
EXPIRATION_IN_SECONDS = 5
ERROR_ICON = "gtk-dialog-error"
SUCCESS_ICON = "gtk-dialog-info"
def self.notify(title, msg, icon)
options = "-t #{EXPIRATION_IN_SECONDS * 1000} -i #{icon}"
system "notify-send #{options} '#{title}' '#{msg}'"
end
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?/)
if output
if $~[2].to_i > 0
notify "FAIL", "#{output}", ERROR_ICON
else
notify "Success!", "#{output}", SUCCESS_ICON
end
end
end
end
4) Now save the file and open your .autotest file (/home/_____/.autotest – Create one if it does not exist) and require the file you just created by placing this line on the top:
require ‘autotest/gnomenotify’
Done! You should now get beautiful notifications on your screen like this one here
