“Could not find a valid mapping for #” only on second and successive tests

后端 未结 9 1964
花落未央
花落未央 2020-12-28 13:28

I\'m trying to write a request test that asserts that the proper links appear on the application layout depending in whether a user is logged in or out. FWIW, I\'m using Dev

9条回答
  •  一整个雨季
    2020-12-28 14:17

    Halfnelson's solution worked for me too, but since I'm using the Fabrication gem instead of FactoryGirl, I needed to make some adjustments. Here's the code I droped into a initializer:

    if Rails.env.development? || Rails.env.test?
      ActionDispatch::Callbacks.after do
        Fabrication.clear_definitions
        Rails.logger.debug 'Reloading fabricators'
      end
    end
    

提交回复
热议问题