Skip to content

@wagenet /.autotest
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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 == ""
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) }
puts "Weird Hack" # This lets the .autotest in print_handler run
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.