Created
August 28, 2010 23:46
-
-
Save AlSquire/555718 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Growl autotest module I use with Rails 3 RC Test::Unit | |
module Autotest::Growl | |
def self.growl(title, msg, img = nil) | |
cmd = "growlnotify -n autotest -m \"#{msg}\" \"#{title}\"" | |
cmd += " --image \"#{img}\"" if img | |
system cmd | |
end | |
Autotest.add_hook :ran_command do |at| | |
# Sample : | |
# 2 tests, 2 assertions, 1 failures, 0 errors, 0 skips | |
regexp = /^(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors, (\d+) skips$/ | |
output = at.results.detect { |r| r.match(regexp) } | |
if output.nil? | |
growl "Can't match results", "Nooo!" | |
else | |
tests, assertions, failures, errors, skips = output.match(regexp).to_a[1, 5].map(&:to_i) | |
if failures == 0 && errors == 0 | |
growl "GREEN", "#{output}", "/Users/arnaud/Dev/Misc/autotest/rails_ok.png" | |
else | |
growl "FAIL", "#{output}", "/Users/arnaud/Dev/Misc/autotest/rails_fail.png" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Obsolete with the autotest-growl gem