Rails Minitest crashing when tests fail

牧云@^-^@ 提交于 2019-12-10 13:34:36

问题


Minitest crashes every time a test fails when I run rails test (Rails 5 and Ruby 2.4.2). For example, I forced a simple test to fail by switching the assert to 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)

If the test passes, then the entire report is successful and I get the report summary. If only one test fails I get the error report above. I defined test_transaction_should_be_valid in my transaction_test.rb file and the proof of it is that it runs smoothly when the test passes.

I'm stuck on this now. Any ideas as to what might be causing this?


回答1:


Apparently Rails is not yet quite compatible with Minitest 5.10/5.11: https://github.com/seattlerb/minitest/issues/730 They have posted a monkeypatch to tide us over.

Rails has apparently also fixed this in edge. https://github.com/rails/rails/pull/31624

This error disappeared for me when I pulled from the master branch. Put this in your Gemfile:

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

edit: promoting from comments (thanks coco9nyc):

or you can try downgrading minitest:

gem 'minitest', '5.10.3'


来源:https://stackoverflow.com/questions/48229515/rails-minitest-crashing-when-tests-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!