Sunday, December 27, 2009

My dot-Autotest

Among the things that make me ga-ga for Ruby testing libraries is the ZenTest gem, which includes a super handy utility called 'autotest'. Autotest is meant to be run from the top of your project directory and it will search through your /test directory and run all test files it finds there (and report passes/failures on the console). My own development preference is writing specifications for my software using RSpec, which includes a tiny utility script called 'autospec' that enables 'autotest' to run anything it finds under the /spec directory of your project environment. As well, setting an environment variable called AUTOFEATURE=true tells autotest to search through your /features directory and run all your Cucumber features after file-system changes (this capability is added by Cucumber and not actually part of the ZenTest gem).

I have been running autospec nonstop as I tinker with a Sinatra app I have been writing. The normal behavior for autospec is that it runs all specs & features and then stops, watching the filesystem for any file changes that trigger it to run specs again. Recently, though, I noticed that the specs would start running and then go into an infinite loop of running and running and running... At first I thought that I'd updated a gem in the vendor directory of my Sinatra app that broke autospec somehow. After doing a lot of tinkering, I tracked it down to a Webrat log file that gets updated each time my Cucumber specs make it all the way through the login feature of my web app.

Autotest includes a configuration capability that lets you specify which file updates it should ignore (i.e. which files can be updated without triggering an execution of all the specs for your project). These exceptions can be declared in a .autotest file that needs to reside in the home directory of your development environment. I think I have covered all the bases for things that I want to keep from triggering my autospec runs. Here is what my file looks like:

The 'autotest/growl' require is so that I can see growl popups when my specs pass or fail. The gem for this is 'autotest-growl'.

UPDATE - 12/28/09: The 'autotest' script supports a '-v' flag which will cause it to report what file it saw changed to trigger your last test run. I only learned about this flag thanks to a comment on this original post by the great Ryan Davis.

8 comments:

Dreamr OKelly said...

How did you find out what file was changing?

thanks

Ryan Davis said...

I don't know about autospec, as it isn't actually part of zentest (unlike what the article claims, it ships with rspec, not zentest), but if you run `autotest -v` it will print out what is triggering a run.

Mario said...

My original post was loaded with incorrect assumptions. Thanks to zenspider for pointing out "autotest -v". That would have saved me loads of time. I have updated my post with more accurate attribution.

generic propecia said...

Hello people want to express my satisfaction with this blog very creative and I really like the views of the focus very good indeed Thank you for the helpful information. I hope you keep up the good work on making your blog a success!

Firesales Costa Rica said...

Hello .. firstly I would like to send greetings to all readers. After this, I recognize the content so interesting about this article. For me personally I liked all the information. I would like to know of cases like this more often. In my personal experience I might mention a book called Firesales Costa Rica in this book that I mentioned have very interesting topics, and also you have much to do with the main theme of this article.

Anonymous said...

Magnificent job! The comprehensive data provided was very beneficial. I really hope you sustain the good job done.
miami beach locksmith
Wellington Locksmith
Locksmith Berkeley CA
RedwoodCity locksmith
Sunnyvale locksmith
Milpitas locksmith
miami beach fl locksmith
pembroke pines locksmith
plano tx locksmith
locksmith miami
locksmith miami
irvine locksmiths
irvine ca locksmith
plano locksmiths
miami fl locksmith
locksmith miami fl
Locksmith Hialeah FL
Aventura FL locksmith
locksmith miami beach
Hialeah FL Locksmith
locksmith pembroke pines

Thinking said...

Thanks for pointing out the usefulness of this tool.

eddiehaagensen said...

Hard Rock Hotel & Casino Philadelphia - DrmCD
The Hard Rock Hotel & Casino 서귀포 출장샵 Philadelphia is the 속초 출장샵 premier destination for gaming, 김포 출장안마 dining and entertainment. Experience 김포 출장마사지 award-winning rooms, exciting restaurants, May 20, 통영 출장안마 2020 · Uploaded by Hard Rock Hotel & Casino