My .autotest file


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. require 'autotest/redgreen'
  2.  
  3. # You need mpg321, so:
  4. # sudo port install mpg321
  5.  
  6. # Resources from:
  7. # http://www.thelucid.com/articles/2007/07/30/autotest-growl-fail-pass-smilies
  8. # http://www.fozworks.com/2007/7/28/autotest-sound-effects
  9.  
  10. module Autotest::Growl
  11.  
  12. def self.growl(title, msg, type)
  13. pri = {
  14. :fail => 2,
  15. :pending => 1,
  16. :pass => 0
  17. }
  18. system "growlnotify --name Autotest --image ~/.autotest_resources/#{type}.png --title #{title.inspect} --message #{msg.inspect} --priority #{pri[type]}"
  19. end
  20.  
  21. Autotest.add_hook :ran_command do |autotest|
  22. results = [autotest.results].flatten.join("\n")
  23. output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
  24. if output =~ /[1-9]\sfailures?/
  25. growl "FAIL", "#{output}", :fail
  26. elsif output =~ /[1-9]\spending?/
  27. growl "PENDING", "#{output}", :pending
  28. else
  29. growl "PASS", "#{output}", :pass
  30. end
  31. end
  32. end
  33.  
  34. module Autotest::Sound
  35. def self.play_sound sound
  36. system "mpg321 ~/.autotest_resources/#{sound}.mp3 > /dev/null 2>&1 &"
  37. end
  38.  
  39. Autotest.add_hook :ran_command do |autotest|
  40. results = [autotest.results].flatten.join("\n")
  41. output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
  42. if output =~ /[1-9]\sfailures?/
  43. play_sound :fail
  44. elsif output =~ /[1-9]\spending?/
  45. play_sound :pending
  46. else
  47. play_sound :pass
  48. end
  49. end
  50. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.