Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ruby
- # ~.autotest
- # require 'autotest_notification'
- # SPEAKING = false
- # DOOM_EDITION = false
- # BUUF = false
- # PENDING = false
- # STICKY = false
- # SUCCESS_SOUND = ''
- # FAILURE_SOUND = ''
- # require 'redgreen'
- require 'autotest/timestamp'
- module Autotest::GnomeNotify
- def self.notify title, msg, img
- system "notify-send '#{title}' '#{msg}' -i #{img} -t 3000"
- end
- Autotest.add_hook :initialize do |autotest|
- autotest.add_mapping(%r%^spec/(requests)/.*rb$%) do |filename, _|
- filename
- end
- end
- Autotest.add_hook :ran_command do |at|
- image_root = "~/.autotest_images"
- results = [at.results].flatten.join("\n")
- results.gsub!(/\\e\[\d+m/,'')
- output = results.slice(/(\d+)\sexamples?,\s(\d+)\sfailures?(,\s(\d+)\spending?|)/)
- full_sentence, green, failures, garbage, pending = $~.to_a.map(&:to_i)
- if output
- if failures > 0
- notify "FAIL", "#{output}", "#{image_root}/fail.png"
- elsif pending > 0
- notify "Pending", "#{output}", "#{image_root}/pending.png"
- else
- notify "Pass", "#{output}", "#{image_root}/pass.png"
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment