Guest User

Untitled

a guest
Feb 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #!/bin/ruby
  2. # ~.autotest
  3. # require 'autotest_notification'
  4. # SPEAKING = false
  5. # DOOM_EDITION = false
  6. # BUUF = false
  7. # PENDING = false
  8. # STICKY = false
  9. # SUCCESS_SOUND = ''
  10. # FAILURE_SOUND = ''
  11.  
  12. # require 'redgreen'
  13. require 'autotest/timestamp'
  14.  
  15. module Autotest::GnomeNotify
  16. def self.notify title, msg, img
  17. system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
  18. end
  19. Autotest.add_hook :initialize do |autotest|
  20. autotest.add_mapping(%r%^spec/(requests)/.*rb$%) do |filename, _|
  21. filename
  22. end
  23. end
  24. Autotest.add_hook :ran_command do |at|
  25. image_root = "~/.autotest_images"
  26. results = [at.results].flatten.join("\n")
  27. results.gsub!(/\\e\[\d+m/,'')
  28. output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
  29. full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
  30. if output
  31. if failures > 0
  32. notify "FAIL", "#{output}", "#{image_root}/fail.png"
  33. elsif pending > 0
  34. notify "Pending", "#{output}", "#{image_root}/pending.png"
  35. else
  36. notify "Pass", "#{output}", "#{image_root}/pass.png"
  37. end
  38. end
  39. end
  40. end
Add Comment
Please, Sign In to add comment