Skip to content

Instantly share code, notes, and snippets.

@metalelf0
Created February 23, 2011 11:28
Show Gist options
  • Save metalelf0/840314 to your computer and use it in GitHub Desktop.
Save metalelf0/840314 to your computer and use it in GitHub Desktop.
Autotest notifier
module Autotest::Notify
def self.notify title, msg, img, pri='low', time=3000
`notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'`
end
Autotest.add_hook :initialize do |at|
%w{.svn .hg .git vendor}.each {|exception| at.add_exception(exception)}
end
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
folder = "~/Pictures/rails/"
if output =~ /[1-9]\d*\sfailures?/
notify "FAIL:", "#{output}", folder+"rails_fail.png", 'critical', 10000
elsif output =~ /[1-9]\d*\spending?/
notify "PENDING:", "#{output}", folder+"rails_pending.png", 'normal', 10000
else
notify "PASS:", "#{output}", folder+"rails_ok.png"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment