I’m a big fan of Behavior Driven Development (BDD). It really illustrates how one little change in your code can have significant impact on the rest of you application, which you would never be able to catch without testing. Not to to mention the benefit of being able to write code and make sure it works even if you don’t have production data available.
So, upon completing a clean upgrade to Leopard I noticed that after installing Growl and growlnotify, that growlnotify would not work even through Growl itself was working.
1) First let’s set up the .autotest file. For this you’ll need the gems rspec (1.1.3), ZenTest (3.9.1), and redgreen since ZenTest change how it handled exceptions in 3.9.
Now open up your ~/.autotest file in Textmate
Paste in the following code. Notice the exceptions at the bottom of the file that really helps speed up autotests as well as keeps your cpu usage low. My Macbook would get really hot really fast prior to using this execptions.
Next, you’ll want to download the Pass, Fail, and Pending images below:
First, the prerequisite to growlnotify is Growl. You can download it from http://growl.info/. It’s a graphical installer, so you shouldn’t have an issues.
Once you’ve installed Growl, pop open the terminal and enter the following commands.
Give it a test run:
So if that doesn’t work, it’s probably because of an issue with the default permissions and Mac OS X 10.5 Leopard. Here’s what my permssions were. (I have no idea why the @ symbol is there)
To fix the permissions, I ran the following:
Resulting in the following permssions:
Give it a test run again:
Now you can change directories to your rails app and run autotest and growlnotify should be working now..
References:
http://blog.codefront.net/2007/04/01/get-your-testing-results-via-growl-notifications/
http://www.danielfischer.com/2007/05/14/ruby-on-rails-bdd-with-autotest-growl-rspec/
http://railsontherun.com/2008/1/30/misc-tips-and-tricks/

















March 14th, 2008 at 5:28 am
How’s it going Micah? Couldn’t find you on fb so found your blog. Nice write up. Growl is pretty cool. I am going to play with its windows equivalent-Snarl.
March 14th, 2008 at 7:20 am
Instructions for snarl: http://wiki.futuretoby.com/Autotest_popup_notifications_with_Snarl
April 11th, 2008 at 6:35 pm
[...] Midnight Oil » Blog Archive » Installing GrowlNotify and Autotest for BDD use with Rspec on Leopar… (tags: growl autotest) [...]
April 18th, 2008 at 1:21 pm
Hey thanks for that permissions tip. I’d actually given up on growlnotify for months because I thought it simply didn’t work.
!jon
April 19th, 2008 at 9:41 am
I’ve got something really weird happening, I’ve followed your instruction to the T but growl notifications don’t work. So I wanted to make sure the Autotest.add_hook :ran_command was running, so I put in the classic “puts ‘here’” at the top of the hook and oddly the growl notifications show up. But if I pull out the puts statement growl notifications stop working again.
this is too weird…any thoughts?
April 19th, 2008 at 11:52 am
Matt,
Are you doing the autotest with rSpec? I’ve had problems with it running test unit.
If you are using with with test unit, check this one out:
http://blog.codefront.net/2007/04/01/get-your-testing-results-via-growl-notifications/
Autotest.add_hook :ran_command do |at|
output = at.results.last.slice(/(\d+)\s.*specifications?,\s(\d+)\s.*failures?/)
if output =~ /[1-9]\sfailures?/
growl “Test Results”, “#{output}”, “/Data/Pictures/Icons/rails_fail.png”, 2, “-s”
else
growl “Test Results”, “#{output}”, “/Data/Pictures/Icons/rails_ok.png”
end
end
If not, let me know..
Ryan
April 19th, 2008 at 1:11 pm
Nope, I’m using rspec. Can’t seems to figure this one out. Also the growl plugin that is built into rspec that you can use via “require ‘autotest/growl’” isn’t working for me either. I double checked the permissions on growlnotify and they are just as you have them listed above. Calling growlnotify from the command line works just fine.
So needless to say, I’m a bit stumped.
April 24th, 2008 at 10:40 pm
[...] Midnight Oil » Blog Archive » Installing GrowlNotify and Autotest for BDD use with Rspec on Leopar… Installation path works fine with PeepCode graphics and ~/.autotest script as well. (tags: BDD Leopard Growl growlnotify autotest ZenTest rspec Ruby) [...]
May 7th, 2008 at 5:39 am
if there are currently no specs the following is needed:
filtered = autotest.results.grep(/\d+\s.*examples?/)
output = filtered.empty? ? “” : filtered.last.slice(/(\d+)\s.*examples?,\s(\d+)\s.*failures?(?:,\s(\d+)\s.*pending)?/)
May 9th, 2008 at 8:55 pm
Alexander,
Thanks for the comment… I’ve update my post with your code..