Guest User

Untitled

a guest
Feb 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. require 'autotest/redgreen'
  2.  
  3. module Autotest::Growl
  4. def self.growl(title, msg, img, pri=0, stick="")
  5. system "/usr/local/bin/growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
  6. end
  7.  
  8. Autotest.add_hook :ran_command do |at|
  9. results = at.results.last
  10.  
  11. unless results.nil?
  12. output = results[/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/]
  13. if output
  14. failures = $~[2].to_i
  15. pending = $~[4].to_i
  16. end
  17.  
  18. if failures > 0
  19. #growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2
  20. `/usr/bin/say -v Zarvox "you broke the code"`
  21. elsif pending > 0
  22. #growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
  23. `/usr/bin/say -v Alex "Tests passed, with some pending"`
  24. else
  25. #growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
  26. unless at.tainted
  27. `/usr/bin/say -v Victoria "all tests passed"`
  28. else
  29. `/usr/bin/say -v Victoria "tests passed"`
  30. end
  31. end
  32. end
  33. end
  34. end
Add Comment
Please, Sign In to add comment