Skip to content

Instantly share code, notes, and snippets.

@wagenet
Created April 25, 2009 17:08
Show Gist options
  • Save wagenet/101692 to your computer and use it in GitHub Desktop.
Save wagenet/101692 to your computer and use it in GitHub Desktop.
Show Growl notifications from both autotest and autospec
# Show Growl notifications from both autotest and autospec
# Author: Peter Wagenet (http://in.finitu.de)
# URL: http://gist.github.com/101692
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
command = "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
# puts command
system command
end
Autotest.add_hook :ran_command do |at|
results = at.results.last
unless results.nil? || results.strip == ""
output = results.slice(/((\d+ examples?)|(\d+ tests, \d+ assertions)), \d+ failures?(, \d+ errors)?(, \d+ pending)?/)
if !(output.include?(" 0 failures")) || (output.include?("error") && !output.include?(" 0 errors"))
growl "Test Results", "#{output}", "/Users/peterwagenet/Library/autotest/rails_fail.png", 2, "-s"
elsif output =~ /pending/
growl "Test Results", "#{output}", "/Users/peterwagenet/Library/autotest/rails_pending.png"
else
growl "Test Results", "#{output}", "/Users/peterwagenet/Library/autotest/rails_ok.png"
end
else
growl "Tests Results", "Tests Crashed", "/Users/peterwagenet/Library/autotest/rails_fail.png", 2, "-s"
end
end
end
Autotest.add_hook :initialize do |autotest|
[/^\.\/vendor/, /^\.\/public/, /^\.\/coverage/, ".svn", ".git"].each { |exception| autotest.add_exception(exception) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment