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

NoMethodError: undefined method `first' in NegativeExpectationHandler #115

Closed
rkistner opened this issue Feb 6, 2012 · 5 comments
Closed

Comments

@rkistner
Copy link

rkistner commented Feb 6, 2012

In RSpec 2.8.0, I believe the line rspec-expectations-2.8.0/lib/rspec/expectations/handler.rb:42 which contains:

::RSpec::Expectations.fail_with message, matcher.expected.first, matcher.actual

should be:

::RSpec::Expectations.fail_with message, matcher.expected, matcher.actual

Simple check to test this (the test should fail, but not raise this error):

"test".should_not RSpec::Matchers::Eq.new("test")

NoMethodError: undefined method `first' for 1:Fixnum
from /usr/local/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.8.0/lib/rspec/expectations/handler.rb:42:in `handle_matcher'
from /usr/local/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.8.0/lib/rspec/expectations/extensions/kernel.rb:24:in `should_not'
from (irb):28
from /usr/local/bin/irb:12:in `<main>'
@dchelimsky
Copy link
Contributor

There is some unfortunate legacy around matcher.expected.first so it can't just be changed without breaking a bunch of stuff out in the wild. What problem are you experiencing as a result?

@rkistner
Copy link
Author

rkistner commented Feb 6, 2012

Why is it only matcher.expected.first in NegativeExpectationHandler, but matcher.expected in PositiveExpectationHandler?

My test is a simple

a.should_not equal(b)

However, when the test fails, the above error is spewed instead of a descriptive message.

dchelimsky added a commit that referenced this issue Feb 6, 2012
@e2
Copy link

e2 commented Mar 9, 2012

Could you bump Rspec to 1.8.1 to release this? Thanks.

@dchelimsky
Copy link
Contributor

Released 2.9.0.rc2 this morning. 2.9 to follow by the weekend barring any unforeseen issues.

@e2
Copy link

e2 commented Mar 12, 2012

Thanks! :)

On Mon, Mar 12, 2012 at 02:15:40PM -0700, David Chelimsky wrote:

Released 2.9.0.rc2 this morning. 2.9 to follow by the weekend barring any unforeseen issues.


Reply to this email directly or view it on GitHub:
#115 (comment)

Cezary Baginski

nevinera added a commit to nevinera/rspec-support that referenced this issue May 9, 2024
(instead of skipping them). This behavior was originally added in in
rspec-expectations commit 044b0a6, as part of
rspec/rspec-expectations#115, which was
intended to `expect("a").to eq("b")` from showing an extra diff, when
the error message already showed the whole diff (so the diff itself was
kind of unnecessary). There are tests already enforcing _that_, so we
don't need to add any, but this change retains that behavior (though
single-element single-line array comparisons do now get a diff).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants