Skip to content

Instantly share code, notes, and snippets.

@ogredude
Created June 30, 2011 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogredude/1056467 to your computer and use it in GitHub Desktop.
Save ogredude/1056467 to your computer and use it in GitHub Desktop.
module Autotest::Growl
def self.growl title, msg, img, pri=0, stick=""
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
end
Autotest.add_hook :ran_command do |autotest|
filtered = autotest.results.grep(/\d+\s.*examples?/)
output = filtered.empty? ? '' : filtered.last.slice(/(\d+)\s.*examples?,\s(\d+)\s.*failures?(?:,\s(\d+)\s.*pending)?/)
if output =~ /[1-9]\sfailures?/
growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2
elsif output =~ /pending/
growl "Test Results", "#{output}", '~/Library/autotest/rails_pending.png'
else
growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
end
end
end
Autotest.add_hook :initialize do |at|
%w{.svn .hg .git .log vendor}.each {|exception| at.add_exception(exception)}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment