public
Last active

Show Growl notifications from both autotest and autospec

  • Download Gist
.autotest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.