minitest-spec-rails
minitest-spec-rails copied to clipboard
Deprecation warning when used with flipper/prawn-rails
As demonstrated in this sample app: https://github.com/clinejj/flipper-prawn-minitest-spec-autoload
When running the test suite (bin/rails test
), there is an autoload deprecation warning shown in the console. This only occurs in the test suite, not during the app, leading me to believe the issue is with this gem. Example output:
> bin/rails test
DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper and ArticlesHelper.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ApplicationHelper, for example,
the expected changes won't be reflected in that stale Module object.
These autoloaded constants have been unloaded.
In order to autoload safely at boot time, please wrap your code in a reloader
callback this way:
Rails.application.reloader.to_prepare do
# Autoload classes and modules needed at boot time here.
end
That block runs when the application boots, and every time there is a reload.
For historical reasons, it may run twice, so it has to be idempotent.
Check the "Autoloading and Reloading Constants" guide to learn more about how
Rails autoloads and reloads.
(called from <top (required)> at /demo-app/config/environment.rb:5)
Run options: --seed 54308
# Running:
.
Finished in 1.107565s, 0.9029 runs/s, 0.9029 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
The issue doesn't occur if either Flipper or prawn-rails are removed, and only started occurring after updating to Flipper 0.21 (see issue with that gem here: https://github.com/jnunemaker/flipper/issues/532)
Thoughts on what might be going on?
I have no idea. But here is what I would do to find out.
- Does it not happen if you change
config.load_defaults 6.1
to another version? - Find any documentation in Rails on the deprecation. Are there warning on behaviors to avoid? When looking I would put a focus on how
ActiveSupport.on_load
behaves and maybe how this project (or others) require ActionView? - Do a bundle config with that demo project to ensure gems are installed into vendor/bundle. I would then make small changes to a target gem like this one and toggle some code to see what happens. I might start with this file https://github.com/metaskills/minitest-spec-rails/blob/master/lib/minitest-spec-rails/railtie.rb
@metaskills I've experienced something similar: https://github.com/metaskills/minitest-spec-rails/pull/105#issuecomment-864950981