如何解决使用 Stimulus.js
在尝试使用 Stimulus.js 在 rails 6.1.0 中运行 RSpec 测试时,我遇到了一个问题,即我从终端获得的唯一输出
EPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper,DashboardHelper,WelcomeHelper,FontAwesome5,FontAwesome5::Rails,FontAwesome5::Rails::IconHelper,Stimulus::StimulusHelper,DeviseHelper,ApplicationController,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 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 /Users/user/freelance/OneHR/config/environment.rb:5)
^C
RSpec is shutting down and will print the summary report... Interrupt again to force quit.
我已经在不同的网站上进行了一些搜索,但没有运气得到任何东西来运行我的测试。
我认为我必须在我的测试环境文件中用我的类添加代码块,但还没有任何结果。在此错误输出到控制台后,RSpec 挂起,我必须使用 Command + C 退出。不确定是我遗漏了什么还是我搞砸了什么。
解决方法
尝试如下包装 TurboFailureApp
Rails.application.reloader.to_prepare do
class TurboFailureApp < Devise::FailureApp
def respond
...
end
class TurboController < ApplicationController
...
end
end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。