Skip to content

Instantly share code, notes, and snippets.

@ryopeko
Created May 5, 2010 12:25
Show Gist options
  • Save ryopeko/390707 to your computer and use it in GitHub Desktop.
Save ryopeko/390707 to your computer and use it in GitHub Desktop.
# -*- ruby -*-
# require 'autotest/autoupdate'
# require 'autotest/once'
# require 'autotest/rcov'
# require 'autotest/restart'
# require 'autotest/timestamp'
# Autotest::AutoUpdate.sleep_time = o
# Autotest::AutoUpdate.update_cmd = o
# Autotest::RCov.command = o
# Autotest::RCov.pattern = o
module Autotest::Growl
def self.growl title, msg, img="~/images/rails_ok.png", pri=0, sticky=""
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
results = [at.results].flatten.join("¥n")
output = results.slice(/\d+\s+examples,\s*(\d)\s*failure/)
if output
if $~[1].to_i > 0
growl "Tests Failed", "#{output}", "~/images/rails_fail.png", 2
else
growl "Tests Passed", "#{output}", "~/images/rails_ok.png", 2
end
else
growl "Tests Errored", "errors", "~/images/rails_fail.png", 2
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment