I want to disable ActiveAdmin when running the tests.
So I add require: false
to the Gemfile and checking if defined?(ActiveAdmin)
in routes and initializer.
But Rails still loads the models form app/admin
thus I am getting error similar to /app/admin/admin_user.rb:1:in
': uninitialized constant ActiveAdmin (NameError)`
What is the best way to "blacklist" the app/admin
directory from being loaded?
# config/environments/test.rb
path_rejector = lambda { |s| s.include?("app/admin") }
# Remove the path from being loaded when Rails starts:
config.eager_load_paths = config.eager_load_paths.reject(&path_rejector)
# Remove the path from being lazily loaded
ActiveSupport::Dependencies.autoload_paths.reject!(&path_rejector)
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