Ben Woodall

Last of the freelance hackers - Greatest sword fighter in the world

OSX Rspec Autotest Notifications

rspec, ruby

This uses growl notifications to alert you to your autotest status

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Autotest::Growl
  def self.growl title, msg, img, pri=0, stick=""
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
  end

  Autotest.add_hook :ran_command do |at|
    results = [at.results].flatten.join("\n")
    output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+pending)?/)
    if output =~ /[1-9]\sfailures?/
      growl "Test Results", "#{output}", '~/Dropbox/Photos/autotest/rails_fail.png', 2 #, "-s"
    else
      growl "Test Results", "#{output}", '~/Dropbox/Photos/autotest/rails_ok.png'
    end
  end
end

Comments