public
Description: A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state.
Homepage: spork.rubyforge.org
Clone URL: git://github.com/timcharper/spork.git
timcharper (author)
Wed Sep 23 16:41:41 -0700 2009
commit  b630818dce80e47d05f19aa6c08e53153655639c
tree    59602fca4972981b00314fe8d55bfb81c89873e6
parent  129a9c8d6c48cd6251de74a9d2967fda22c1dcc6
spork /
name age message
file .gitignore Wed Jun 03 23:08:03 -0700 2009 ignore tmp directory [timcharper]
file History.txt Loading commit data...
file MIT-LICENSE Sat May 30 00:22:53 -0700 2009 added license information [timcharper]
file README.rdoc Wed Jun 24 16:30:12 -0700 2009 see wiki for troubleshooting [timcharper]
file Rakefile
file VERSION.yml
directory assets/ Mon Jun 08 11:38:44 -0700 2009 cleaned up features to make them more suitable ... [timcharper]
directory bin/ Wed Aug 12 03:19:11 -0700 2009 Add compatibility for Cucumber 0.4 [aslakhellesoy]
directory features/
directory lib/
directory spec/ Wed Sep 16 21:43:46 -0700 2009 implements Spork#using_spork? [timcharper]
file spork.gemspec
README.rdoc

Spork

SYNOPSIS:

Spork is Tim Harper’s implementation of test server (similar to the script/spec_server provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn’t get corrupted over time, and it properly handles modules and any voo-doo meta programming you may have put in your app.

Because Spork uses Kernel.fork, it only works on POSIX systems. This means Windows users are not invited to this party. Sorry :(

Supported Testing Frameworks

  • Rspec
  • Cucumber

And more to come! Vote for your favorite at github.com/timcharper/spork/issues

Supported Application Frameworks

Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to help make the experience much more "out of the box"

  • Rails

More can be added! Vote for your favorite at github.com/timcharper/spork/issues

INSTALL:

  [sudo] gem install spork

alternatively:

  git clone git://github.com/timcharper/spork.git
  cd spork
  gem build spork.gemspec
  sudo gem install spork.gemspec

Usage

From a terminal, change to your project directory.

Then, bootstrap your spec/spec_helper.rb file.

  spork --bootstrap

Next, edit spec/spec_helper.rb and follow the instructions that were put at the top.

Finally, run spork. A spec DRb server will be running!

  spork

Diagnostic mode

Initially, you may find that a few files don’t reload automatically. This is because they are being loaded during Spork startup. To identify which project files are being pre-loaded, and why, run:

  spork --diagnose
  (or spork -d, for short)

It will output a lot of stuff. At the top you’ll find a summary of all project files loaded. Down below, the stack trace for each file (how it got loaded). Spork hooks into Rails and does some magic (TM) to prevent ApplicationController observers, etc from pre-loading. Similar hooks for other ruby frameworks may come as support demands.

Running specs over Spork

RSpec

To get the TextMate RSpec bundle to use spork, go to config->advanced->shell variables, and add:

  TM_RSPEC_OPTS=--drb.

To run from the command line, use:

  spec --drb spec/lib/my_spec.rb

Or, you could add the following flag to your +spec.opts+ file.

  --drb

Cucumber

Cucumber —drb support for spork is not official yet (but it works). It’s the hottest sauce boiling on the world wide web right now. If you can’t wait to try it, head on over to Cucumber core-team member Ben Mabey’s drb branch and build your own cucumber gem:

  http://github.com/bmabey/cucumber/tree/drb_server

Use this as a guideline when "Sporking" your features/support/env.rb file

  http://gist.github.com/123370

Some potential issues and ways to overcome them:

See wiki.github.com/timcharper/spork/troubleshooting

Kudos to

  • Ben Mabey - help with documentation, testing, suggestions, patches, and bringing Cucumber support.
  • David Chelimsky - for the fine RSpec testing framework, and the original rspec-rails spec_server implementation, which Spork has built upon.
  • Lead Media Partners - just for being an awesome place to work.

Spork © 2009 Tim Harper, released under the MIT license