-
Notifications
You must be signed in to change notification settings - Fork 228
Spork
burke edited this page Dec 3, 2012
·
7 revisions
If you have used spork in the past, or need to run certain tasks after forking specifically in your test environment, this pattern will be of use to you.
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