使用 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...