This post originated from an RSS feed registered with Python Buzz
by Phillip Pearson.
Original Post: rspec and spec_server
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Not immediately obvious when you start using RSpec is that there's a way to get around the huge Rails startup delay. If you've got a spare 80M of memory, you can tell RSpec to load up Rails in the background and hang around until you want to run tests.
rake spec:server:start
Then run your specs like this:
script/spec -X -o spec/spec.opts spec/whatever
The -X tells script/spec to connect to the spec server via DRb and tell it to run the tests, rather than to load up Rails and run the tests itself.
A few runs here show it running about 6 seconds faster with the server, which isn't a big deal over a full test suite but makes a nice difference when focussing on a single spec (1.9 s is much nicer than 8 s).