Skip to content

Instantly share code, notes, and snippets.

@chris
Created November 10, 2008 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris/23649 to your computer and use it in GitHub Desktop.
Save chris/23649 to your computer and use it in GitHub Desktop.
require 'autotest/redgreen'
module Autotest::Growl
def self.growl(title, msg, img, pri=0, stick="")
system "/usr/local/bin/growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |at|
results = at.results.last
unless results.nil?
output = results[/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/]
if output
failures = $~[2].to_i
pending = $~[4].to_i
end
if failures > 0
#growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2
`/usr/bin/say -v Zarvox "you broke the code"`
elsif pending > 0
#growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
`/usr/bin/say -v Alex "Tests passed, with some pending"`
else
#growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
unless at.tainted
`/usr/bin/say -v Victoria "all tests passed"`
else
`/usr/bin/say -v Victoria "tests passed"`
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment