Skip to content
turadg edited this page Jan 21, 2013 · 7 revisions

If your test_helper.rb or spec_helper.rb has require 'rails/autorun', that's probably there for Spork. When using Zeus, remove that to avoid #180.

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.

# test/test_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