Skip to content

Instantly share code, notes, and snippets.

@lukebayes
Created May 25, 2009 21:24
Show Gist options
  • Save lukebayes/117761 to your computer and use it in GitHub Desktop.
Save lukebayes/117761 to your computer and use it in GitHub Desktop.
require 'autotest/redgreen'
require 'autotest/menu'
module Autotest::Growl
def self.growl title, msg, image=nil, pri=0
path = Dir.pwd
# TODO: Change to your home path:
path.gsub!('/Users/lbayes/', '')
title += " in [#{path}]"
msg += " at #{Time.now.strftime('%I:%M %p')}"
system "growlnotify -n autotest --image #{image || "/Applications/Mail.app/Contents/Resources/Caution.tiff"} -p #{pri} -m #{msg.inspect} #{title}"
end
Autotest.add_hook :initialize do |at|
growl "autotest running", "Started",'~/.autotest_images/rails_grey.png'
end
Autotest.add_hook :red do |at|
growl("Tests Failed", "#{at.files_to_test.size} tests failed", '~/.autotest_images/rails_fail.png', 2)
end
Autotest.add_hook :green do |at|
growl("Tests Passed", "#{at.known_files.size} tests passed", '~/.autotest_images/rails_ok.png', -2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment