Created
November 10, 2008 21:50
-
-
Save chris/23649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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