Rails6.1升级:未定义的方法`assert_nothing_raised'
从 Rails 6.0.3 升级到 6.1 时,我遇到了这个错误:
NoMethodError:
undefined method `assert_nothing_raised' for #<RSpec::ExampleGroups::EmailJob:0x00005572d8a00758>
Did you mean? assert_raises
每次测试调用时都会发生这种情况perform_enqueued_jobs。我正在使用 RSpec 3.9。
回答
显然assert_nothing_raised是 ActiveSupport 定义的辅助方法。我能够通过显式包含帮助程序来解决这个问题spec/rails_helper.rb:
RSpec.configure do |config|
config.include(ActiveSupport::Testing::Assertions)
# ...
THE END
二维码