I am currently using Spork with Guard, Rspec, and Cucumber. I'd like to move to Spring, but can't find any documentation on what I need to change.
Specifically, I'm curious if I need to change out my:
require 'spork'
Spork.prefork do
# ...
end
Spork.each_run do
# ...
end
...with something like:
require 'spring'
Spring.prefork do
# ...
end
Spring.each_run do
# ...
end
However, I know that there isn't a Spring.prefork
because the documentation says so. So should I simply remove the references to Spork
or do I need to replace them with something?
As you mention in your question, there is no Prefork block. The docs provide a workaround: simply move your existing Spork.prefork
block to an initializer or anywhere that it will be picked up and run at load time by Rails.
From https://github.com/rails/spring#running-code-before-forking:
There is no Spring.before_fork callback. To run something before the fork, you can place it in
~/.spring.rb
orconfig/spring.rb
or in any of the files which get run when your application initializes, such asconfig/application.rb
,config/environments/*.rb
orconfig/initializers/*.rb
.
As for your Spork.each_run
block, since you're using Rspec you could move it into a before(:suite)
block. See the Rspec docs on before and after hooks