Spork Local Process¶ ↑
-
Author: Jarmo Pertman (jarmo.p[at]gmail.com)
<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¶ ↑
-
Install the gem:
gem install spork-local_process
-
Edit your spec_helper.rb file:
require "spork" require "spork/local_process"
-
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
-
Run specs from command line:
rspec spec
-
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
-
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¶ ↑
Copyright © Jarmo Pertman. See LICENSE for details.