Skip to content

Instantly share code, notes, and snippets.

@xenda
Created March 11, 2010 18:19
Show Gist options
  • Save xenda/329474 to your computer and use it in GitHub Desktop.
Save xenda/329474 to your computer and use it in GitHub Desktop.
#!/bin/ruby
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 :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?/)
puts output.inspect
if output
if $~[2].to_i > 0
notify "FAIL", "#{output}", "#{image_root}/fail.png"
else
notify "Pass", "#{output}", "#{image_root}/pass.png"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment