Oef…. ff rspec opzetten was niet zo gemakkelijk als de screencast op railsenvy doet geloven. Er is hier en daar wat veranderd in de library’s en deze kun je overrulen met een .autotest bestand. Helemaal zelf bedacht heb ik het niet maar het een en ander van andere weblogs geplukt.
# -*- ruby -*-
require 'autotest/growl'
require 'autotest/redgreen'
module Autotest::Growl
# save the name of the working directory (e.g., the app name)
# to be used as a key to identify this particular run of autotest
# so the same growl notification will be reused for updates,
# instead of a new growl window for every posting.
@@current_directory_name = Dir.pwd.match(/([^\/]+)\z/).to_s
def self.growl title, msg, pri=0, img=""
title += " in #{@@current_directory_name}"
msg += " at #{Time.now}"
system "growlnotify -n autotest #{pri > 0 ? '-s ' : ''}--image #{img} -p #{pri} -d '#{Dir.pwd}' -m #{ msg.inspect} #{title}"
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)?/)
if output =~ /[1-9]\sfailures?/
growl "FAIL:", "#{output}", 2, "~/Library/autotest/rails_fail.png"
elsif output =~ /[1-9]\spending?/
growl "PENDING:", "#{output}", 1, "~/Library/autotest/rails_pending.png"
else
growl "PASS:", "#{output}", 0, "~/Library/autotest/rails_ok.png"
end
end
end
Get the pictures from here:



Noot: Bij het schrijven van deze blogentry kwam ik een andere .autotest tegen op http://pastie.caboo.se/96573/download. Met logging, stripping van color codes, uitgebreidere foutafhandeling. wat ik er nog bij heb getikt is de extra optie voor reuse van de notificatie:
system "growlnotify -n autotest --image #{img} #{pri > 0 ? '-s ' : ''}-p #{pri} -d '#{Dir.pwd}' -m #{msg.inspect} #{title} #{stick}"
☯
[...] Icons for the messages can be found here [...]