Rails 6.1 升级:未定义的方法 `assert_nothing_raised'

alf*_*alf 4 rspec ruby-on-rails rspec-rails ruby-on-rails-6

从 Rails 6.0.3 升级到 6.1 时,我遇到了这个错误:

  NoMethodError:
    undefined method `assert_nothing_raised' for #<RSpec::ExampleGroups::EmailJob:0x00005572d8a00758>
    Did you mean?  assert_raises
Run Code Online (Sandbox Code Playgroud)

每次测试调用时都会发生这种情况perform_enqueued_jobs。我正在使用 RSpec 3.9。

alf*_*alf 6

显然assert_nothing_raised是 ActiveSupport 定义的辅助方法。我能够通过显式包含帮助程序来解决这个问题spec/rails_helper.rb

RSpec.configure do |config|
  config.include(ActiveSupport::Testing::Assertions)
  # ...
Run Code Online (Sandbox Code Playgroud)