Skip to content

Instantly share code, notes, and snippets.

@champierre
Created December 10, 2008 04:38
Show Gist options
  • Save champierre/34233 to your computer and use it in GitHub Desktop.
Save champierre/34233 to your computer and use it in GitHub Desktop.
module Autotest::Growl
def self.growl title, msg, img="~/.autotest_icons/rails_ok.png", pri=0, sticky=""
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
system "growlnotify -n autotest -H localhost --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.last.slice(/(\d+)\s+tests,\s*(\d+)\s+assertions,\s*(\d+)\s+failures,\s*(\d+)\s+errors/)
if output
if $~[3].to_i > 0 || $~[4].to_i > 0
growl "Tests Failed", "#{output}", "~/.autotest_icons/rails_fail.png", 2, "-s"
else
growl "Tests Passed", "#{output}", "~/.autotest_icons/rails_ok.png", -2
end
else
growl "Tests Failed", "errors", "~/.autotest_icons/rails_fail.png", 2, "-s"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment