Skip to content

Instantly share code, notes, and snippets.

Created August 11, 2008 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4900 to your computer and use it in GitHub Desktop.
Save anonymous/4900 to your computer and use it in GitHub Desktop.
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 |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}", "~/Library/autotest/rails_fail.png", 2, "-s"
elsif output =~ /[1-9]\spending?/
growl "PENDING:", "#{output}", "~/Library/autotest/rails_pending.png", 2, "-s"
else
growl "PASS:", "#{output}", "~/Library/autotest/rails_ok.png"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment