Rspec 2, Rails 3, Autotest, and Spork

So I spent a little bit of time getting all of these kids to play nice together and I figured I’d save someone else the hassle of figuring it out.

Initially I configured my spec_helper.rb to use spork, fired it up and tried running ‘autotest —drb’ which didn’t work. Then I realized I should try and use autospec, since —drb is an rspec specific argument, but that didn’t work either.

After some googling I discovered that autospec has been deprecated in favor of creating a configuration file for autotest in your project directory which indicates what test framework your using (‘autotest/discovery.rb’).

Since autospec has been deprecated, there’s no way to specify ‘—drb’ as a command line option to autotest, which led me to try adding ‘—drb’ to ‘spec/spec.opts’ (the file that specifies the default command line options passed to rspec) but it didn’t seem to impact my specs execution speed. After some more googling, I discovered this which indicated that spec/spec.opts has been deprecated in favor if a .rspec file in either your home directory or the root directory of your project.

All that to say, the magical key ingredient turned out to be stupid simple. Add ‘—drb’ to the .rspec file in the base directory of your rails app, start up spork and autotest and voilĂ , your tests are running much faster.

Edit

Make sure you specify gem ‘spork’, ‘>=0.9.0.rc2’ in your rails app Gemfile. The stable version of spork doesn’t seem to reload models when you change things.

posted 1 year ago on October 15th, 2010 at 15:43 /