Skip to content

Instantly share code, notes, and snippets.

@kasei-san
Created June 25, 2013 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasei-san/5856326 to your computer and use it in GitHub Desktop.
Save kasei-san/5856326 to your computer and use it in GitHub Desktop.
autospec で、結果を Growl で通知 【参考】autotest + growl で楽々テスト - 僕は発展途上技術者 http://blog.champierre.com/774
# vim: set ft=ruby
module Autotest::Growl
def self.growl title, msg, pri=0, sticky=""
msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
system "growlnotify -n autotest -p #{pri} -m #{msg.inspect} #{title} #{sticky}"
end
Autotest.add_hook :ran_command do |at|
output = at.results.last
output = output.gsub!(/\e\[\d+m/,'').gsub!(/\n/,'')
if output =~ /(\d+)\s+failure/
if $1.to_i > 0
growl "Tests Failed", "#{output}", 2, "-s"
else
growl "Tests Passed", "#{output}", -2
end
else
growl "Tests Failed", "errors", 2, "-s"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment