似乎我的助手(有时是我的模型)在Spork的每次运行中都没有被重新加载.我应该把什么放进我的“Spork.each_run”区块?
解决方法
我遇到了同样的问题,所以我在each_run块中设置了它:
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
另外,请不要忘记在config / environments / test.rb中:
config.cache_classes = !(ENV['DRB'] == 'true')