Autotest Notifications in Ubuntu with Mumbles

7 10 2008

Autotest is a nice utility that automatically run your rails tests whenever you make a change to one of your source files. It is part of the ZenTest package from Ryan Davis.

It would be nice if you could be notified of the test results without having to switch to the terminal window running AutoTest. Some Mac users already found a way to do this using Growl. However, that only works if you have a Mac, and I don’t have one, so I figured out a way to do something similar in Ubuntu. Let’s get going.

Step 1: Install Mumbles

Mumbles is a ‘plugin-driven, modern notification system for Gnome’. It is very similar to Growl and even speaks the Growl protocol if you want to receive growl notifications on your Ubuntu/Linux desktop. Installing Mumbles is a breeze thanks to the deb package that you can download here.

Once installed, you can start Mumbles by going to Applications -> Accessories –> Mumbles. You will then see the Mumbles icon Gnome panel applet, as shown in the picture below:

Mumbles Icon in Gnome Panel Applet

Mumbles Icon in Gnome Panel Applet

You can right-click on the Mumbles icon, and edit the preferences. In particular, you can change the theme of your notifications. I like the mumbles-round theme.

Mumble Preferences

Mumble Preferences

If you do not want Mumbles to show up in your Gnome Panel applet, you can start it from a shell using the ‘mumbles -d’ command.

If you want Mumbles to be automatically started when you login, go to System –> Preferences –> Session. On the startup tab, add mumbles with the ‘mumbles’ command.

Step 2: Test Mumbles Installation

Mumble ships with a ‘mumbles-send’ utility. To test it out, type the following in your shell: mumbles-send --help As you can see, mumbles-send takes in a title and an optional message. Let’s try it out now: mumbles-send 'Testing Title' 'This is a test of mumble-send' You should see the notification in the top right of the screen:

Step 3: Installing AutoTest

Autotest is part of the ZenTest Ruby gem. To install it, run: sudo gem install ZenTest That’s about it. Now go to the RAILS_ROOT directory of your application, and run: autotest Autotest should start running your tests.

Step 4: Adding Autotest hooks to Mumbles

To have Autotest results show up as Mumbles notifications, create a file called .autotest and save it in your $HOME directory. Copy the following content into that file:

module Autotest::Mumbles
  def self.mumbles title, msg
    system "mumbles-send \"#{title}\" \"#{msg}\""
  end

  Autotest.add_hook :red do |at|
    errors = at.files_to_test.map { |k, v| "#{k}:\n #{v.join("\n ")}"}.join("\n\n")
    mumbles "TESTS FAILED", errors
  end
  
  Autotest.add_hook :green do |at|
    #res = at.results[/\d+ tests.*$/]
    res = at.results.scan(/Finished.*failures/m).to_s.gsub(/\e\[32m/,'')
    mumbles "TESTS PASSED", res
  end
end

Step 5: Verify everything is running smoothly

At this point, you should be done. Go back to your RAILS_ROOT directory and start autotest. It should now report whether the tests PASSED or FAILED via Mumbles, as shown below:

I hope this helped! Enjoy your Mumbles Autotest notifications


Actions

Information

13 responses

8 10 2008
Notificaciones en Ubuntu con Mumbles « Ubuntu Life

[...] Mas informacion | Dambalah [...]

18 10 2008
Jan Wikholm

This is freakin’ awesome! Thanks!

18 10 2008
Dennis Rogenius

thx man. this is great

18 10 2008
David Parker

This is excellent. I hadn’t heard of Mumbles before this, and your autotest hook is great. Thanks!

23 10 2008
Colin Jones

This works great! Also, great talk on Ramaze at SC RubyConf!

24 10 2008
spyou

Ho gosh, I’ll test that next week for sure …

8 11 2008
agionagile

i’ve got an error while starting autotest

/usr/local/lib/site_ruby/1.8/rubygems.rb:578:in `report_activate_error’: RubyGem version error: hoe(1.7.0 not >= 1.8.0) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:134:in `activate’
from /usr/local/lib/site_ruby/1.8/rubygems.rb:158:in `activate’
from /usr/local/lib/site_ruby/1.8/rubygems.rb:157:in `each’
from /usr/local/lib/site_ruby/1.8/rubygems.rb:157:in `activate’
from /usr/local/lib/site_ruby/1.8/rubygems.rb:49:in `gem’
from /usr/bin/autotest:18

8 11 2008
Luc Castera

Agi,

Looks like you need the latest version of hoe installed. Just run:

sudo gem install hoe

8 11 2008
agionagile

oh, it’s working now on my machine!!
fixed by updating gem:
sudo gem update hoe

thanks!!!!

31 12 2008
j0ban

Thanks for the tips

26 03 2009
Roger

Thanks for the tips, it works like a charm!!!

12 04 2009
Olivier

I’m late to this party, but thanks a lot!

15 07 2009
Lee Richmond

that is awesome!! thanks very much for this helpful tutorial

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.