/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
require 'autotest/redgreen' # You need mpg321, so: # sudo port install mpg321 # Resources from: # http://www.thelucid.com/articles/2007/07/30/autotest-growl-fail-pass-smilies # http://www.fozworks.com/2007/7/28/autotest-sound-effects module Autotest::Growl def self.growl(title, msg, type) pri = { :fail => 2, :pending => 1, :pass => 0 } system "growlnotify --name Autotest --image ~/.autotest_resources/#{type}.png --title #{title.inspect} --message #{msg.inspect} --priority #{pri[type]}" end Autotest.add_hook :ran_command do |autotest| results = [autotest.results].flatten.join("\n") output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/) if output =~ /[1-9]\sfailures?/ growl "FAIL", "#{output}", :fail elsif output =~ /[1-9]\spending?/ growl "PENDING", "#{output}", :pending else growl "PASS", "#{output}", :pass end end end module Autotest::Sound def self.play_sound sound system "mpg321 ~/.autotest_resources/#{sound}.mp3 > /dev/null 2>&1 &" end Autotest.add_hook :ran_command do |autotest| results = [autotest.results].flatten.join("\n") output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/) if output =~ /[1-9]\sfailures?/ play_sound :fail elsif output =~ /[1-9]\spending?/ play_sound :pending else play_sound :pass end end end