Wrap text
Report abuse
# ~.autotest
require 'autotest/growl'
module Autotest::Growl
FAIL_IMAGE = "/Users/carlosbrando/.autotest_images/fail.png"
PENDING_IMAGE = "/Users/carlosbrando/.autotest_images/pending.png"
SUCCESS_IMAGE = "/Users/carlosbrando/.autotest_images/pass.png"
Autotest.add_hook :ran_command do |at|
result = at.results.last
if result
# examples = result =~ /(\d+) examples/ ? $1.to_i : 0
failures = result =~ /(\d+) failure/ ? $1.to_i : 0
pendings = result =~ /(\d+) pending/ ? $1.to_i : 0
if failures > 0
growl "Tests Failed", "#{failures} test#{ 's' if failures > 1 } failed", FAIL_IMAGE
elsif pendings > 0
growl "Tests Pending", "#{pendings} test#{ pendings == 1 ? ' is pending' : 's are pending'}", PENDING_IMAGE
else
growl "Tests Passed", "All tests passed", SUCCESS_IMAGE
end
code = (failures > 0) ? 31 : (pendings > 0) ? 33 : 32
puts "\e[#{code}m#{'=' * 80}\e[0m\n\n"
end
end
class << self
def growl(title, msg, img = SUCCESS_IMAGE, pri = 0)
title = "Autotest Running" if title == "autotest running"
msg += " at #{Time.now.strftime("%I:%M %p")}" if msg == "Started"
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}"
end
end
end