Autotest (part of ZenTest) now supports RSpec. This is fantastic news! For those of you who do not know about autotest, it is a program that runs in the background while you are writing your tests and code. Each time you make a change it automatically reruns your tests – and now your specs, too! This is a powerful addition to the TDD/BDD experience.
Recent releases of both tools overlapped a bit so there are changes in RSpec-0.9.1 that are not reflected yet in ZenTest. Also, while ZenTest-3.5.2 supports Spec::Rails, RSpec’s Ruby on Rails plugin, it does not support non-Rails Ruby projects.
I’ve submitted a patch to the ZenTest project which addresses both of these issues. Until the patch is applied, or the issues are addressed in some other way, you can apply it yourself to get autotest working with RSpec for Rails and other projects. These steps work on a mac. I assume that the commands are quite similar for Linux and Cygwin users.
Go to http://rubyforge.org/frs/?group_id=419 and download ZenTest-3.5.2.tgz
Unpack the tar and
tar zxvf ZenTest-3.5.2.tgz cd ZenTest-3.5.2
Get and install the patch
curl -O http://blog.davidchelimsky.net/files/ZenTest-3.5.2-rspec.patch patch -p0 < ZenTest-3.5.2-rspec.patch
Build and install the gem
rake gem sudo gem install pkg/ZenTest-3.5.2.gem
Once you’ve built and installed the patched gem, you run autotest as normal. Stand in the root of your project and say:
If you have a
spec directory at the root of your project, autotest will load up rspec_rails_autotest for Rails projects and rspec_autotest for everything else.
To quote Josh Knowles, Happy (Auto)Specing!