Eric-Guo / wechat

API, command and message handling for WeChat in Rails
MIT License
1.31k stars 372 forks source link

Ruby 3.0 + Rails 6.1 shows DEPRECATION WARNING running rspec #294

Closed xinyifly closed 3 years ago

xinyifly commented 3 years ago

Output

DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.

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 ActionText::ContentHelper, 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 /path/to/my/rails/project/config/environment.rb:5)

Versions

# ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
# rails --version
Rails 6.1.3
# rspec --version
RSpec 3.10
  - rspec-core 3.10.1
  - rspec-expectations 3.10.1
  - rspec-mocks 3.10.2
  - rspec-rails 4.0.2
  - rspec-support 3.10.2

Notes

Eric-Guo commented 3 years ago

Can you try gem "wechat", git: "https://github.com/Eric-Guo/wechat", branch: :zeitwerk, I plan to only support Rails 6 and using zeitwerk mode in next release, but still under test.

xinyifly commented 3 years ago

@Eric-Guo With gem 'wechat', git: 'https://github.com/Eric-Guo/wechat', branch: :zeitwerk , the DEPRECATION WARNING still exists. With bin/spring stop , with config/initializers/wechat_redis_store.rb deleted, it exists as well.

goofansu commented 3 years ago

See the same issue after upgrading Rails 6.1, but I'm not sure it caused by this gem.

Eric-Guo commented 3 years ago

I can not reproduce in Rails 6.1 without Rspec project, but I do see some change suggesting like https://github.com/Sorcery/sorcery/pull/255

Eric-Guo commented 3 years ago

@goofansu @xinyifly Not sure if it's works, but seems should be a valid fix, so kindly test?

xinyifly commented 3 years ago

@Eric-Guo LOL, with latest zeitwerk branch, the DEPRECATION WARNING disappeared. Nice work, Thank you!

Eric-Guo commented 3 years ago

Release 0.13.0 now in zeitwerk mode and support Rails 6.0+ only.