Open jeromedalbert opened 3 months ago
Mine worked after adding
devise_for :users
in the route file.
Note: Mine was graphql application so, I did not have this added initially.
Temp workaround:
RSpec.configure do |config|
…
# TODO Remove when Devise fixes https://github.com/heartcombo/devise/issues/5705
config.before(:each, type: :controller) do
Rails.application.reload_routes_unless_loaded
end
end
In my case, the tests that were failing were the ones indirectly involving Devise::Mailer
. This mailer actually gets invoked pretty often, because creating a user in a test (e.g. via FactoryBot) will try to send a confirmation email by default as a side-effect.
Anyway, here is the workaround I added to my test_helper.rb
:
ActiveSupport.on_load(:action_mailer) do
Rails.application.reload_routes_unless_loaded
end
This also worked for me in my test_helper.rb
. Thanks for sharing, I never would have grokked this fix!
Looks like it is influence not only on tests, but also registration is not working in application due to same error
Environment
Steps to reproduce
Run the following bash commands (tested on macOS):
Current behavior
I get the following error:
Expected behavior
Test should pass:
Workaround
A workaround is to use one of those before the
sign_in
call:Rails.application.routes_reloader.execute_unless_loaded
(public API)Rails.application.reload_routes_unless_loaded
(private API)Additional information