-
-
Notifications
You must be signed in to change notification settings - Fork 394
raise_error with ArgumentError fails with incorrect message #1388
Comments
I’m 99% sure this is caused by error_highlight. I’m not sure whether this really is a RSpec issue, but… if it is not, would it be good for |
|
It looks like |
Relevant issue in |
Thanks for reporting.
Is this right? Do I understand it correctly that there's a regression in Would version pinning in Rails gem "error_highlight", ">= 0.4.0", "< 0.5.0" fix the issue? Can we just recommend using the next Rails version to fix this for our users? I would like to point out that If you run your example on a blank slate project without A related fix mentioning Do you think there is anything we can fix by making changes in |
That is correct:
Yes
I can definitely pin the
Yes and no --
It’s a good question! It’s also a question that might not need to be answered right now, depending on how/if ruby/error_highlight#28 gets resolved. As a hack, I imagine rspec-expectations could strip off a trailing |
I think the better way forward might be to encourage people to not write
but rather use an anchored regex:
|
Is it just new line characters added? |
I believe error_highlight 0.5.1 including ruby/error_highlight#29 address this issue. |
Just updating error_highlight version to 0.5.1 is fine.
|
@denisdefreyne @JonRowe Any objections on closing this issue? |
I think as |
Perfect, thanks :) |
Subject of the issue
A
raise_error
expectation withArgumentError
will not match the correctmessage
.Your environment
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin22]
3.12.0
Steps to reproduce
Write the following to
spec/foo_spec.rb
:Run
bundle exec rspec spec/foo_spec.rb
.Expected behavior
Spec passes.
Actual behavior
The
message
of the raisedArgumentError
is a String with the following contents:More details
This only appears to be an issue for
ArgumentError
.This started failing in the week or so. I’ve not been able to narrow down the cause just yet.
This fails with stock Ruby, no gems loaded.
To reproduce without RSpec:
This prints
"zing\n\n raise ArgumentError, 'zing'\n ^^^^^^^^^^^^^^^^^^^^^"
.It should (I think) print
"zing"
instead.The text was updated successfully, but these errors were encountered: