context/should make rails test output not correct.
Closed this issue · 4 comments
Rails 5 give us a new function which can output can rerunable command with
following format:
bin/rails test the/path/of/failed/test/file
But, use with shoulda, we always got the following content.
bin/rails test /home/zw963/.rvm/gems/ruby-2.2.4@ershou_web/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:399
Hey, just going over old issues and seeing whether they are relevant or not. I didn't even know this was a thing in Rails 5, but I found where in the Rails source that this gets added:
- https://github.com/rails/rails/blob/4d9ba8b50b0ff01d19ff786aa64c9da0fb31aa7e/railties/lib/minitest/rails_plugin.rb (Minitest will load this file automatically)
- https://github.com/rails/rails/blob/4d9ba8b50b0ff01d19ff786aa64c9da0fb31aa7e/railties/lib/rails/test_unit/reporter.rb#L71-L79
Essentially, though, Rails looks at the source location of the test method to know what to print out. The issue here is that since Shoulda Context adds the test methods from within the gem itself, the source location of the method is shoulda/context/context.rb instead of the test file. There's really not a great way to fix this other than rewriting how Shoulda Context fundamentally works. I am planning on possibly rearchitecting Shoulda Context anyway, so ideally I could fix this bug as a part of that, but I'm not sure how long that's going to take. I'll keep this issue open in the meantime.
@fsateler Oh I didn't realize that's what that was doing 🤦♂️ I'll change this back.
This should be fixed. ^