RSpec-0.9.1 and Autotest (ZenTest-3.5.2)
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.
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:
autotest
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!

July 13th, 2008 at 06:06 AM
Nice work, thanks!
July 13th, 2008 at 06:06 AM
Thanks!
July 13th, 2008 at 06:06 AM
Thanks !
but i have two problem/questions: 1. If a example fails, autotest repeats the the execution of the failed example continiously.( although i didn’t change any file)
2. How to enable synstax coloring ?
July 13th, 2008 at 06:06 AM
Hussein – take a look at spec/spec.opts and get rid of everything related to—failures and—example. That should do the trick for the continuous run problem.
The coloring there is no solution for at the moment (that I am aware of).
July 13th, 2008 at 06:06 AM
I’m running ZenTest (3.5.2) and I’m using rspec 0.9.5. I got an error when running autotest; here is the log:
I guessed the fix pretty quickly. To run spec, I have to do `rake spec` or `script/spec`. Not just `spec`. So here is how I fixed the problem:
In my rspec_rails_autotest.rb, I noticed this line: Changing it to this solved my problem: Then, as mentioned in other places, I needed to install diff-lcs as well:Are others having the same problem? Did my fix work for you?
July 13th, 2008 at 06:06 AM
I’m running ZenTest (3.5.2) and I’m using rspec 0.9.5. I got an error when running autotest; here is the log:
I guessed the fix pretty quickly. To run spec, I have to do `rake spec` or `script/spec`. Not just `spec`. So here is how I fixed the problem:
In my rspec_rails_autotest.rb, I noticed this line: Changing it to this solved my problem: Then, as mentioned in other places, I needed to install diff-lcs as well:Are others having the same problem? Did my fix work for you?