-
-
Notifications
You must be signed in to change notification settings - Fork 397
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
it { should include foo } fails or provides unexpected output if foo.respond_to?(:description) #260
Comments
Can you try |
My bad, I was thinking of rspec/rspec-mocks#288 carry on :) |
alindeman
added a commit
that referenced
this issue
Jun 5, 2013
* `#description` is only used for matchers. [Fixes #260] Signed-off-by: Andy Lindeman <[email protected]> Signed-off-by: Sam Phippen <[email protected]>
alindeman
added a commit
that referenced
this issue
Jun 5, 2013
* `#description` is only used for matchers. [Fixes #260] Signed-off-by: Andy Lindeman <[email protected]> Signed-off-by: Sam Phippen <[email protected]>
yujinakayama
pushed a commit
to yujinakayama/rspec-monorepo
that referenced
this issue
Oct 6, 2021
* `#description` is only used for matchers. [Fixes rspec/rspec-expectations#260] Signed-off-by: Andy Lindeman <[email protected]> Signed-off-by: Sam Phippen <[email protected]> --- This commit was imported from rspec/rspec-expectations@5412202.
yujinakayama
pushed a commit
to yujinakayama/rspec-monorepo
that referenced
this issue
Oct 6, 2021
This commit was imported from rspec/rspec-expectations@cbafe24.
yujinakayama
pushed a commit
to yujinakayama/rspec-monorepo
that referenced
this issue
Oct 6, 2021
* `#description` is only used for matchers. [Fixes rspec/rspec-expectations#260] Signed-off-by: Andy Lindeman <[email protected]> Signed-off-by: Sam Phippen <[email protected]> --- This commit was imported from rspec/rspec-expectations@5d541bb.
yujinakayama
pushed a commit
to yujinakayama/rspec-monorepo
that referenced
this issue
Oct 6, 2021
This commit was imported from rspec/rspec-expectations@618fb8c.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is probably a pretty weird edge case, but here goes:
I have a kind of wrapper object that behaves like this (the details have been abstracted away for hopefully clearer presentation):
Now, it's normally the case that the kind of object passed into
@feature
responds to:description
. But I had a test that looked like this:This passed when I was using v2.6, but after upgrading to 2.13 it started failing with a
NoMethodError: undefined method 'description'
. I was surprised by this, because instantiating aHandler
should not call thedescription
method. When I tried stubbing the Object.new with adescription
method that said "This shouldn't be here", I got a passing test that looked like:So it appears to me that what's going wrong is that the
to_word
method inrspec-expectations/lib/rspec/matchers/pretty.rb
is usingrespond_to?(:description)
not just to check that the argument responds to:description
, but also (implicitly) as a duck-type check -- it's expecting that if the object does respond to:description
, we'll have an object of typeRSpec::Core::Example
or some other rspec object. But obviously that assumption fails in my weird edge case!I thought about submitting a patch along with this issue report but I'm not really sure what the correct fix is. More explicit type-checking? Differently named methods so that there's even less likelihood of unintended collisions?
The text was updated successfully, but these errors were encountered: