Using Watchr to Check on Your Tests
I started using Watchr in a couple of projects. An interesting use of Watchr is to check on your tests. I have been using this script with great success so far:
test.watchr
1 def failed
2 system("growlnotify —name adgear-reporting-tests —image /Applications/Mail.app/Contents/Resources/Caution.tiff -m ‘Oops, tests failed’")
3 system("say ‘failed’")
4 end
5
6 def succeeded
7 system("growlnotify —name adgear-reporting-tests -m ‘Green tests’")
8 system("say ‘pass’")
9 end
10
11 watch(‘(lib|test)/.+\.(js|rb)’) do |_|
12 system("rake")
13 $?.success? ? succeeded : failed
14 end
Notice I’m using Mac OS X application paths, but it works just fine for me. And the regular “pass” and “failed” messages keep me abreast of what’s going on. But this style of continuous testing only works when your tests take a few seconds at most. When my tests take much longer than that, I start fiddling, opening Google Reader, checking news, whatever.
Your mileage may vary.
