No commit activity in last 3 years
No release in over 3 years
Run your code in a local process with Spork again and again without reloading the whole environment each time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.9.0
 Project Readme

Spork Local Process¶ ↑

<img src=“https://secure.travis-ci.org/jarmo/spork-local_process.png” />

DESCRIPTION¶ ↑

Spork Local Process is a run strategy for the Spork (github.com/timcharper/spork) library. It will re-run all your tests in the same process again and again without using any fork-ing under *nix or DRb processes under Windows. This library is useful when you are having problems with the Spork server solutions (especially on Windows).

Make your tests run fast again!

USAGE¶ ↑

  1. Install the gem:

    gem install spork-local_process
    
  2. Edit your spec_helper.rb file:

    require "spork"
    require "spork/local_process"
    
  3. Add load statements into Spork.each_run block to load all files again before each test run:

    Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*.rb")).each {|f| load f}
    Dir.glob(File.join(File.dirname(__FILE__), "**/*.rb")).delete_if {|f| File.basename(f) =~ %r{(_)?spec(_helper)?.rb$}}.each do |f|
      load f
    end
    
  4. Run specs from command line:

    rspec spec
    
  5. Press ENTER to run the same specs again or specify some new spec file with the help of tab-completion-powered command line:

    spec/some_other_spec.rb # to run all the specs from that file
    spec/some_other_spec.rb:33 # to run spec within range of line 33
    spec/some_other_spec.rb "part of example name" # like -e option for RSpec when running from command line
  6. Type ‘exit’ to exit

That’s all you have to do. No additional changes needed usually. If Spork itself is started, then it is used normally instead making Spork Local Process totally backwards compatible.

RELOADING FILES¶ ↑

Make sure that you’re loading all interesting files in your Spork.each_run block. Use require_all (github.com/jarmo/require_all) gem’s #load_all method to do it more easily.

Sometimes only reloading the files is not enough since deleted methods/classes won’t disappear from the memory and reassigning values to constants will show warnings. In these cases you can unload constants from the memory before loading files.

For example, to unload everything in the module/class of MyApp and a specific constant do something like this:

Spork::RunStrategy::LocalProcess.unload :MyApp, "YourApp::SOME_CONSTANT"

Everything nested in these constants (e.g. submodules/subclasses) will be unloaded.

Copyright © Jarmo Pertman. See LICENSE for details.