Understanding and Using Spork

Posted . Visible to the public.

Background

The spork Show archive.org snapshot gem Show archive.org snapshot preloads your application, thus facilitating running a small set of tests repeatedly. It works by running your test over a DRb server Show archive.org snapshot .

With Spork there are two points in time where code can be loaded: Either once at startup of the DRb server or before every run of your tests. This configuration is set in spec/spec_helper for your RSpecs and in features/support/env.rb for your Cucumbers. In both of these files you will find a Spork.prefork and a Spork.each_run block. In order to get most out of Spork, as much of the original content of these files as possible should be placed in the prefork block. Notice, however, that any changes you make to code that resides in that prefork block will not get picked up by the DRb server unless you restart it. This typically affects fixtures. You should either be aware of this issue or move your fixtures in the each_run block and deal with the performance loss.

Installation

See the Github pages for spork Show archive.org snapshot and / or spork-rails Show archive.org snapshot .

Usage

In seperate terminal tabs fire up

spork rspec

and

spork cucumber

… then in a seperate tab proceed to run a small set of tests with the cucumber or rspec command, passing in the --drb option. Example:

rspec models/user_spec.rb:3 --drb

If my instructions confuse you, seek help from Ryan Bates :) Show archive.org snapshot

Last edit
Posted by Philipp Antar to Distribusion IT (2013-11-13 08:23)