This is me (and apparently my brother too):
Introverted iNtuitive Thinking Judging
Portrait of an INTJ
The Portrait of the Mastermind
The Free Thinker

This is me (and apparently my brother too):
Introverted iNtuitive Thinking Judging
Portrait of an INTJ
The Portrait of the Mastermind
The Free Thinker
So, you’re developing Ruby on Rails apps on your shiny Mac and you want to get Growl notifications when your rake tasks are complete. Below, I will illustrate a fairly simple way to get Growl notifications when the test_units and test_functional tasks are complete. This method can be easily extended to any of the other tasks as well.
Prerequisites
Integration with Rails
First, copy the Growl.rb file that you extracted from the Growl source into your Rails application’s lib directory. Name it growl.rb (all lowercase).
Next, create a new file called growl_notifications.rake in your Rails application’s lib/tasks directory. Copy and paste the following code into this file:
task :test_units do
task_notifier 'Rake Task', 'Unit testing has completed.'
end
task :test_functional do |t|
task_notifier 'Rake Task', 'Functional testing has completed.'
end
def task_notifier(title, message)
begin
require 'growl'
n = GrowlNotifier.new('Rake',['RakeTask'],nil)
n.register()
n.notify('RakeTask', title, message)
rescue
end
end
Growl’s Ruby bindings allow you, among other things, to customize the icon that is displayed in the notification. Take a peek inside the growl.rb file for details.
I would like to extend this further to show the results from the tests in the notification message body. The results are part of a TestResult object, but I’m not sure if there is a way to get at this object by the time I create the notification. If you how I can do this, please let me know!