|
|
# Save this as ".autotest" in root_folder of computer or project
# These require growlnotify, but once you have that you can tweak priorities
# in the Growl control panel to get RedGreen in the growl bubble itself!
# http://growl.info/documentation/growlnotify.php
#Taken straight from the example in Autotest gem
module AutoGrowl
def self.growl title, msg, pri=0
system "growlnotify -n autotest --image /Applications/Mail.app/Contents/Resources/Caution.tiff -p #{pri} -m #{msg.inspect} #{title}"
end
Autotest.add_hook :run do |at|
growl "Run", "Run" unless $TESTING
end
Autotest.add_hook :red do |at|
growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2
end
Autotest.add_hook :green do |at|
growl "Tests Passed", "All tests passed", -2 if at.tainted
end
Autotest.add_hook :init do |at|
growl "autotest", "autotest was started" unless $TESTING
end
Autotest.add_hook :interrupt do |at|
growl "autotest", "autotest was reset" unless $TESTING
end
Autotest.add_hook :quit do |at|
growl "autotest", "autotest is exiting" unless $TESTING
end
Autotest.add_hook :all do |at|_hook
growl "autotest", "Tests have fully passed", -1 unless $TESTING
end
end
class Autotest
# All code borrowed from:
# http://www.robsanheim.com/2006/08/07/hacking-green-bar-color-output-into-autotest/
BAR = "=" * 80
# filter output for colorized green/red bar
def filter_output(results)
filtered = ""
results.each do |line|
if line =~ /\d+ tests, \d+ assertions, 0 failures, 0 errors/
line = "\e[32m#{BAR}\n#{$&}\e[0m\n\n"
elsif line =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
if $1 != 0 || $2 != 0
line = "\e[31m#{BAR}\n#{$&}\e[0m\n\n"
end
end
filtered <
|