Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise_error + an exception object produces wrong failure message #94

Open
mcmire opened this issue Jun 29, 2020 · 4 comments
Open

raise_error + an exception object produces wrong failure message #94

mcmire opened this issue Jun 29, 2020 · 4 comments
Labels

Comments

@mcmire
Copy link
Collaborator

mcmire commented Jun 29, 2020

This may be fixed already, but the gem raises an error on this line when you attempt to use raise_error with a single exception object and the matcher fails:

https://github.com/mcmire/super_diff/blob/master/lib/super_diff/rspec/monkey_patches.rb#L664

(undefined method name for SomeExceptionClass)

@pavolzbell
Copy link

Hello @mcmire, maybe I bumped into this one (or a very similar one) today too:

expect { raise 'x' }.to raise_error(start_with('x')) #=> true
expect { raise 'x' }.to raise_error(start_with('y'))

NoMethodError: undefined method `name' for #<RSpec::Matchers::BuiltIn::StartWith:0x63306e58>
from .../gems/super_diff-0.5.2/lib/super_diff/rspec/monkey_patches.rb:668:in `expected_for_matcher_text'

How can I help fixing it?

@mcmire
Copy link
Collaborator Author

mcmire commented Oct 22, 2020

I think that might be technically a different issue, but I guess it's the same message so perhaps it's related. That is happening because super_diff doesn't support all of the matcher objects yet. It sounds like in this case your matcher failed so you would need to debug/resolve it manually, but obviously it would be great if there were a useful error message here. :) But yeah, super_diff needs to know how to handle start_with and end_with.

@pavolzbell
Copy link

pavolzbell commented Oct 24, 2020

Ok, so I'm thinking, would it be better to add support for start_with and end_with matchers or fallback to default RSpec matcher's failure_message if we encounter an error in super_diff monkey patches? The latter will probably solve similar cases for various custom matchers as well (not sure how much are custom matchers supported), what do you think?

@mcmire
Copy link
Collaborator Author

mcmire commented Oct 26, 2020

Yeah, it might be a good idea to fall back if there is an error. There's an issue I made in #44 around this, so I've been thinking about doing this anyway (probably should have done it all this time). I don't have a ton of time these days so I'm not sure if I could get to either one soon, but falling back is probably a good strategy overall regardless.

@mcmire mcmire changed the title raise_error with an exception object raise_error + an exception object produces wrong failure message Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants