thoughtbot/shoulda-context

context/should make rails test output not correct.

Closed this issue · 4 comments

zw963 commented

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:

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.

This was fixed on 7d496b5 (ie, 1.2.2 does not have the problem), but the fix was lost on 9b791b4 .

@fsateler Oh I didn't realize that's what that was doing 🤦‍♂️ I'll change this back.

This should be fixed. ^