I'm working on my first app since I installed Rails 5. When I ran my specs for controller actions, I got the warning message below even though all my tests were passing.
自从我安装了Rails 5后,我正在开发我的第一个应用程序。当我运行控制器操作的规范时,即使我的所有测试都通过,我也会收到下面的警告信息。
[Devise] including `Devise::TestHelpers` is deprecated and will be removed from Devise.
For controller tests, please include `Devise::Test::ControllerHelpers` instead.
So in spec/rails_helper.rb
I change this line:
所以在spec / rails_helper.rb中我更改了这一行:
config.include Devise::TestHelpers, type: :controller
to
config.include Devise::Test::ControllerHelpers
This change made the warning go away, but now the specs for models are failing. (They were passing before the change.) How should I fix this? Thanks!
这一变化使警告消失了,但现在模型的规格都失败了。 (他们在改变之前就过世了。)我该如何解决这个问题?谢谢!
1 个解决方案
#1
15
You should change your spec/rails_helper.rb
file to the following:
您应该将spec / rails_helper.rb文件更改为以下内容:
config.include Devise::Test::ControllerHelpers, type: :controller
This will ensure that the Devise::Test::ControllerHelpers
module is only be included in your controller tests. The reason your model tests are failing is because that module is specific to controller tests.
这将确保Devise :: Test :: ControllerHelpers模块仅包含在您的控制器测试中。模型测试失败的原因是因为该模块特定于控制器测试。
#1
15
You should change your spec/rails_helper.rb
file to the following:
您应该将spec / rails_helper.rb文件更改为以下内容:
config.include Devise::Test::ControllerHelpers, type: :controller
This will ensure that the Devise::Test::ControllerHelpers
module is only be included in your controller tests. The reason your model tests are failing is because that module is specific to controller tests.
这将确保Devise :: Test :: ControllerHelpers模块仅包含在您的控制器测试中。模型测试失败的原因是因为该模块特定于控制器测试。