I got sick of typing `rake recent` every time I wanted to test a change in my current programming project, and remembered something I’d downloaded a while ago but didn’t have a use for at the time: a little utility called [Stakeout][stake] for the Mac OS X command line. Its purpose in life? To watch a file or list of files for changes and do something whenever one of those files changes.
So after a few tries, I came up with this little… er… **gem**.
stakeout “rake recent” `find . -name ‘*.rb’`
This finds all of the files with an `.rb` extension and runs the appropriate tests when it detects you’ve saved the file to disk. I haven’t tried it, but I believe that you could watch .rhtml too files by simply adding `find . -name ‘*.rhtml’` to the above command.
[stake]: http://michael-mccracken.net/blog/blosxom.pl/2004/07/28
Now I can save and let the computer do its testing in the background…
(See also [Continuous Integration][ci] for more on testing automation and Rails)
[ci]: http://blog.innerewut.de/articles/2005/05/12/continuous-integration
4 Comments
Here’s a version compiled on Tiger (10.4) using the updated Growl framework in 0.6.1: stakeout & gstakeout
This approach appears to be much more practical than something such as CIA. Most of the time, the test database is not available on the production server. This works on the local machine. Very nice, I’ve downloaded it and started using it.
Now I can see exactly when I make changes which affect the tests.
Matt - Yeah, I like to have that instant feedback on my progress. When I’m doing TDD, it helps me to know when I’ve successfully completed the ‘goal’, ie gotten all the tests passing, before I commit the changes to subversion. Personally I like to commit only code that fully passes the tests.
That way I can svn checkout the code from anywhere and I know it will run and I can work on it.
Just checking to see if any relation are out here
http://swarovski.searchcar.org/daniel_swarovski/
Post a Comment