May 1st, 2007
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.
<p>Recent releases of both tools overlapped a bit so there are changes in <a href="http://rubyforge.org/frs/shownotes.php?release_id=11423">RSpec-0.9.1</a> that are not reflected yet in ZenTest. Also, while ZenTest-3.5.2 supports <a href="http://rspec.rubyforge.org/documentation/rails/index.html">Spec::Rails</a>, RSpec’s <a href="http://rubyonrails.com">Ruby on Rails</a> plugin, it does not support non-Rails Ruby projects.</p> <p>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.</p>
- 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.
<p>To quote <a href="http://joshknowles.com/2007/4/13/zentest-3-5-rspec-0-9-autospec">Josh Knowles</a>, Happy (Auto)Specing!</p>