Speedup Testing with Spork

Speeding up Testing

Testing a rails app can sometimes really suck… Part of it is loading the rails stack (20-30s), and part of it is how you design some aspects around test data creation (if it is expensive) and user login, etc.

A good combination to help on the technical side of things is spork and guard, as outlined here.

You have to use whatever code you currently have in your startup/spec_helper stuff for cucumber or rspec. And maybe add some more code when things still aren’t quite right! Or maybe remove some… Basically, move all of your spec_helper code into the prefork block, and adjust as necessary to make errors go away.

install Guard

Gemfile

gem 'rb-fsevent'
gem 'guard-spork'

initial config

guard init spork

trial run

bundle exec guard start

Get it to work

You might need to add some tweaks to the Guardfile. For example, increasing the wait time, and maybe adding other files to watch over for changes.