Installing GrowlNotify and Autotest for BDD use with Rspec on Leopard

Ruby on Rails Add comments

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:

rails_ok.png rails_pending.png rails_fail.png

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..

Growlnotify Green

Growlnofity Red

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/


Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.

  • Digg
  • del.icio.us
  • DZone
  • BlinkList
  • Furl
  • Reddit
  • StumbleUpon
  • Technorati

10 Responses to “Installing GrowlNotify and Autotest for BDD use with Rspec on Leopard”

  1. Toby Says:

    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.

  2. Toby Says:

    Instructions for snarl: http://wiki.futuretoby.com/Autotest_popup_notifications_with_Snarl

  3. RAILroading » Blog Archive » links for 2008-04-12 Says:

    [...] Midnight Oil » Blog Archive » Installing GrowlNotify and Autotest for BDD use with Rspec on Leopar… (tags: growl autotest) [...]

  4. Jon Crawford Says:

    Hey thanks for that permissions tip. I’d actually given up on growlnotify for months because I thought it simply didn’t work.

    !jon

  5. Matt Schick Says:

    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?

  6. Ryan Says:

    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

  7. Matt Schick Says:

    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.

  8. Notional Slurry » links for 2008-04-25 Says:

    [...] 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) [...]

  9. Alexander Says:

    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)?/)

  10. Ryan Says:

    Alexander,

    Thanks for the comment… I’ve update my post with your code..

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in