Rails在测试失败时最小的崩溃

当我运行rails test (Rails 5和Ruby 2.4.2)时,每次测试失败时Minitest都会崩溃。 例如,我通过将assert切换为assert_not强制简单测试失败:

 Failure: TransactionTest#test_transaction_should_be_valid [/home/.../test/models/transaction_test.rb:11]: Expected true to be nil or false /home/.../.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/test_unit/reporter.rb:70:in `method': undefined method `test_transaction_should_be_valid' for class `Minitest::Result' (NameError) 

如果测试通过,那么整个报告都会成功,我会收到报告摘要。 如果只有一个测试失败,我会得到上面的错误报告。 我在transaction_test.rb文件中定义了test_transaction_should_be_valid ,certificate它在测试通过时运行顺畅。

我现在坚持这个。 关于可能导致这种情况的任何想法?

显然Rails还不能与Minitest 5.10 / 5.11完全兼容: https : //github.com/seattlerb/minitest/issues/730他们发布了一个monkeypatch来帮助我们度过难关。

Rails显然也在边缘修复了这个问题。 https://github.com/rails/rails/pull/31624

当我从主分支中拉出时,这个错误消失了。 把它放在你的Gemfile中:

 gem 'rails', git: 'https://github.com/rails/rails.git' 

编辑:从评论中推广 (感谢coco9nyc):

或者您可以尝试降级minitest:

 gem 'minitest', '5.10.3'