Giter Club home page Giter Club logo

spork's Introduction

Spork

SYNOPSIS:

Spork is Tim Harper’s implementation of test server (similar to the script/spec_server that used to be 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, it can work with any ruby framework, and it properly handles modules and any voodoo meta programming you may have put in your app.

Spork runs on POSIX systems using fork. It also runs on windows by pre-populating a pool of ready processes (referred to here as the “magazine” strategy).

Supported Testing Frameworks

  • Rspec

  • Cucumber

  • Test::Unit (via ‘gem install spork-testunit’)

Supported Application Frameworks

Actually, Spork ~can~ work with any application framework. But, it ships with hooks and helpers to make an “out of the box” experience.

  • Rails 3.0 (for Rails 2.{1,2,3}.x, please try spork 0.8.x)

  • Padrino

INSTALL:

rubygems:

[sudo] gem install spork --prerelease

(Rails 2.x)

[sudo] gem install spork --version 0.8.4

bundler:

Add to your Gemfile:

gem 'spork', '~> 0.9.0.rc'

(Rails 2.x, use this)

gem 'spork', '~> 0.8'

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 | less
(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.

You may find this wiki page useful for common ways to battle a variety of common pre-loading issues: github.com/timcharper/spork/wiki/Spork.trap_method-Jujutsu

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:

rspec --drb spec/lib/my_spec.rb

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

--drb

Cucumber

Cucumber has DRb support (see wiki.github.com/aslakhellesoy/cucumber/spork-and-drb )

cucumber --drb features/my.feature

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

http://gist.github.com/123370

Running the Spork test suite

If you wish to hack on spork, you will want to run the automated test suite to make sure your changes don’t break anything. Spork uses bundler to manage and install dependencies. To start:

bundle install

Then, to run the specs:

bundle exec rspec spec/

(or, alternatively…)

bundle exec rake

running features ===

Essentially:

bundle exec cucumber features

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.

  • LeadTune - just for being an awesome place to work.

  • Alan Aslak - for the fine Cucumber testing framework, and for much collaboration getting cucumber working with spork.

  • Roger Pack - JRuby support / Windows

  • Donald Parish - Windows support (Magazine strategy)

Spork © 2011 Tim Harper, released under the MIT license

spork's People

Contributors

timcharper avatar aslakhellesoy avatar milhouse avatar bmabey avatar cflipse avatar rdp avatar mcmire avatar joliss avatar marcandre avatar mattwynne avatar scudco avatar bcardarella avatar e2 avatar edendevelopment avatar dblock avatar garygreyling avatar msch avatar pk avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.