Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Spork

Elliot Winkler edited this page · 7 revisions

If your test_helper.rb or spec_helper.rb has require 'rspec/autorun', that's probably there for Spork. When using Zeus, remove that to prevent running specs twice. (More on moving from Spork).

If you need to run certain tasks after forking specifically in your test environment, as Spork supported, this pattern will be of use to you.

Zeus will eventually have a better mechanism to accomplish this.

# spec/spec_helper.rb

prefork = lambda {
  # ...
}

each_run = lambda {
  # ...
}

if defined?(Zeus)
  prefork.call
  $each_run = each_run
  class << Zeus.plan
    def after_fork_with_test
      after_fork_without_test
      $each_run.call
    end
    alias_method_chain :after_fork, :test
  end
elsif ENV['spork'] || $0 =~ /\bspork$/
  require 'spork'
  Spork.prefork(&prefork)
  Spork.each_run(&each_run)
else
  prefork.call
  each_run.call
end
Something went wrong with that request. Please try again.