Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.81 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'autotest/growl'
  2.  
  3. module Autotest::Growl
  4.   def self.growl title, msg, img, pri=0, stick=""
  5.     system "growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg}' #{title} #{stick}"
  6.   end
  7.          
  8.   Autotest.add_hook :red do |at|
  9.     errors = at.files_to_test.map { |k, v| "#{k}:\n #{v.join("\n ")}"}.join("\n\n")
  10.     #failed_tests = at.files_to_test.inject(0){ |s,a| k,v = a; s + v.size}
  11.     growl "Tests failed:", "#{errors}", '~/library/autotest/rails_fail.png', 2
  12.   end
  13.                          
  14.   Autotest.add_hook :green do |at|
  15.     res = at.results.scan(/Finished.*failures/m).to_s.gsub(/\e\[32m/,'')
  16.     growl "Test Results", "#{res}", '~/library/autotest/rails_ok.png'
  17.   end
  18. end
  19.  
  20. Autotest.add_hook :initialize do |at|
  21.   %w{.git vendor rerun.txt tmp log}.each {|exception| at.add_exception(exception)}
  22. end