It seems like my helpers (and sometimes my models) aren't being reloaded on each run with Spork. What should I be putting into my "Spork.each_run" block?
I had the same issue, so I set this in my each_run block:
Spork.each_run do
# This code will be run each time you run your specs.
ActiveSupport::Dependencies.clear
ActiveRecord::Base.instantiate_observers
FactoryGirl.reload
Dir[File.join(File.dirname(__FILE__), '..', 'app', 'helpers', '*.rb')].each do |file|
require file
end
end
Also, don't forget this in your config/environments/test.rb:
config.cache_classes = !(ENV['DRB'] == 'true')
It may be because you load them in the prefork block. If you load the stuff there, your test run faster, but sometimes you need to reload. You could load on the "each_run" block, but test would be slower. If you prefer speed, you can restart the Spork server when you see that you need the reload. This way, the prefork block will run again and your models and helpers will be reloaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With