Autotest is a great idea. When it worked for me, I loved it. But I hardly ever used it. Our complicated codebase choked on it - something to do with accounts as subdomains or double-loading of test_helper when running the test suite or some such. Frankly, I don’t remember the details, but I do remember the multiple two-hour wild goose chases to try to get the lovely software to work for me. Unfortunately I wasn’t up to the task.

And the Growl integration problems? Oi!

So this afternoon I decided to give watchr a try. I wasn’t hopeful and time-boxed myself at an hour. No rat hole for me, no sir.

Imagine my surprise when 45 minutes later I not only had watchr working, but I placed it just so in my environment. I could use my script on any Rails app on my system with full growl notification and more!

Automatic testing with Rails

The steps for me to setup watchr were fairly straightforward. On the command line (your symlink will vary, natch):

gem install watchr
ln -s /Users/barry/.gem/ruby/1.8/gems/watchr-0.6/bin/watchr /usr/local/bin/watchr

I am using this Rails watchr script - I haven’t modified it as of yet. I placed it in ~/.watchr/rails.rb.

I placed the following two images into ~/.watchr_images/passed.png and ~/.watchr_images/failed.png respectively:

Rails tests passed

Rails tests failed

To run watchr on my Rails app, from the code directory:

watchr ~/.watchr/rails.rb

To make this less super-annoying I set a bash alias:

alias watch="watchr ~/.watchr/rails.rb"  # default is Rails cause that's my most frequent workspace

So tomorrow morning I’ll open a terminal window and type:

watch

Life is good!

(My watchr links at Delicious.)

Feb 23, 2010 · Subscribe · Archive · Projects · Twitter · GitHub · Flickr