Using Spork to speed up RSpec and Cucumber

Vlcsnap-2009-09-15-18h25m13s110

Click on image above for a preview

Released: Sep 15, 2009, Running time: 14 min

In this episode:

Installing and configuring Spork to make RSpec and Cucumber load specs and features faster.

Tags: autospec, spork, rspec, cucumber, textmate

FREEWatch episode

Downloads

Item Size
Quicktime (MP4) 91.25 MB
iPhone 28.99 MB
  • Share

Spork is a tool used to preload your environment so you don’t have to load it each time you run your features or specs.

URLAgghttp://github.com/jschoolcraft/urlagg – is a project built with Ruby on Rails, having 198 RSpec examples and 548 Cucumber steps in 90 scenarios.

We use Spork to reduce the startup time for running specs and features for URLAgg with autospec.

A couple of gotchas come up as we add Spork to our initialization files and you can see how to go around them.

Also, for Textmate users using the RSpec bundle, a quick tip on how to use Spork when running features from within Textmate.

You can read more about using Spork on the Github wiki for Cucumber and on the Spork homepage.

Screenshots

  • Vlcsnap-2009-09-15-18h50m18s189
  • Vlcsnap-2009-09-15-18h50m41s153
  • Vlcsnap-2009-09-15-18h50m45s0
  • Vlcsnap-2009-09-15-18h50m55s37
  • Vlcsnap-2009-09-15-18h51m14s233
  • Vlcsnap-2009-09-15-18h51m24s77
  • Vlcsnap-2009-09-15-18h51m31s119
  • Vlcsnap-2009-09-15-18h51m49s0

7 comments

I’ve been trying to apply this to Brandizzle. Here’s where I’m stuck. Spork doesn’t seem to load factory-girl properly:

Anonymous modules have no name to be referenced by (ArgumentError)
/home/tick/work/brandizzle/features/step_definitions/brand_steps.rb:2:in `/^an existing brand "([^\"]*)"$/'
features/manage_brands.feature:8:in `Given an existing brand "BDDCasts"'

Make sure you have something like this in your cucumber.rb environment file.

config.gem "thoughtbot-factory_girl", :version => ">=1.2.2",  :lib => 'factory_girl'

To debug the requirement of factory_girl, you could run “script/console cucumber” and “Factory.create(:brand)”.

I get the impression that most of the work after choosing to use Spork is working around Spork breaking things, or changing how RSpec works. It’s hardly a drop-in solution.

In reply to Matijs van Zuijlen

I get the impression that most of the work after choosing to use Spork is working around Spork breaking things, or changing how RSpec works. It’s hardly a drop-in solution.

You are right, it really is not a drop-in solution. For smaller projects it is probably not worth the hassle of setting it up. But when you reach a certain number of steps and specs in your project, the benefit of speeding up the load time outweighs the hassle of setting it up.

How does `AUTOFEATURE=true autospec` connect to drb for both cucumber and rspec? Do you run two instances of spork for this?

In reply to Andrew Vit

How does `AUTOFEATURE=true autospec` connect to drb for both cucumber and rspec? Do you run two instances of spork for this?

Yes, I load spork in two terminal tabs:

spork cucumber
spork rspec

When I run spork rspec I always get the message
bc. No server is running
Running specs locally:

Which I don’t understand. What is spork trying to tell me?

Commenting is disabled.