Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'autotest/redgreen'
- module Autotest::Growl
- def self.growl(title, msg, img, pri=0, stick="")
- system "/usr/local/bin/growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
- end
- Autotest.add_hook :ran_command do |at|
- results = at.results.last
- unless results.nil?
- output = results[/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/]
- if output
- failures = $~[2].to_i
- pending = $~[4].to_i
- end
- if failures > 0
- #growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2
- `/usr/bin/say -v Zarvox "you broke the code"`
- elsif pending > 0
- #growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
- `/usr/bin/say -v Alex "Tests passed, with some pending"`
- else
- #growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
- unless at.tainted
- `/usr/bin/say -v Victoria "all tests passed"`
- else
- `/usr/bin/say -v Victoria "tests passed"`
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment