RSpec and Autotest
I am getting all parts of my Rails development environment settled. In addition to vanilla Rails, I am currently using RSpec, Selenium and Autotest. I am seriously considering Haml and Sass as well.
When googling arounf to learn more about Autotest, I realized that people are using together with Growl. It works out-of-the-box with Test::Unit, but RSpec needs a little tweaking. I took the basics from here and modified to my liking. The following is what my .autotest looks like.
1 module Autotest::Growl
2 def self.growl title, msg, img, pri=0, stick=""
3 system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}"
4 end
5
6 Autotest.add_hook :ran_command do |at|
7 puts "at: '#{at.results}'"
8 output = at.results.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/)
9 puts "out: #{output}"
10 if output =~ /[1-9]\sfailures?/
11 growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s"
12 else
13 growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
14 end
15 end
16 end