Skip to content

Instantly share code, notes, and snippets.

@olauzon
Created April 14, 2009 19:34
Show Gist options
  • Save olauzon/95378 to your computer and use it in GitHub Desktop.
Save olauzon/95378 to your computer and use it in GitHub Desktop.
require 'autotest/redgreen'
# require 'autotest/pretty'
# require 'autotest/snarl'
# require 'autotest/timestamp'
module Autotest::Growl
def self.growl title, msg, img, pri=0, sticky=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
if output
if $~[2].to_i > 0
growl "Test Results", "#{output}", "~/.rails_fail.png", 2
else
growl "Test Results", "#{output}", "~/.rails_ok.png"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment