Closed kg8m closed 1 year ago
We are experiencing the same issue.
3.0.0
3.1.2
6.0.6
Rspec error when running specs:
Failure/Error: require "rspec/rails"
GoogleAuthenticatorRails::ActionController::RailsAdapter::LoadedTooLateError:
GoogleAuthenticatorRails is trying to prepend a before_filter in ActionController::Base. Because you've already defined ApplicationController, your controllers will not get this before_filter. Please load GoogleAuthenticatorRails before defining ApplicationController.
Heya @kg8m and @renodor just pushed 3.1.0 of the gem with your changes; should be fixed!
Thank you so much!
Hi. Thank you for developing this gem.
I have an issue where
GoogleAuthenticatorRails::ActionController::RailsAdapter::LoadedTooLateError
occurs when running RSpec tests on Rails with Zeitwerk. This issue is the same as mentioned in https://github.com/jaredonline/google-authenticator/pull/63#issuecomment-1159866679.This issue is caused by
defined?(::ApplicationController)
always returning"constant"
when Zeitwerk is enabled. Zeitwerk uses Ruby's built-inautoload
, so this issue is originally caused byautoload
.I'll create a pull request to fix this issue soon. I hope you can check it out.
Note: You can reproduce the
autoload
anddefined?
behavior as follows:sample.rb
:ruby -e 'p defined?(Sample)'
in your shell:nil
becauseSample
isn't loadedruby -e 'autoload :Sample, "./sample"; p defined?(Sample)'
in your shell:"constant"
even thoughSample
isn't loaded becauseSample
is an autoload constant