Misleading report with argument constraints in message expectations #34

Closed
txus opened this Issue Jan 29, 2011 · 3 comments

Comments

Projects
None yet
1 participant
@txus
Contributor

txus commented Jan 29, 2011

(Moved from https://github.com/rspec/rspec-expectations/issues#issue/42)

specify do
   @mymock = mock(:test)
   @mymock.should_receive(:test).with(1,2,3).once
   @mymock.should_receive(:test).with(3,2,1).once

   @mymock.test(1,2,3)
   @mymock.test(3,2,2)
 end

outputs:

Failures:
 1) TestTest test test
    Failure/Error: @mymock.test(3,2,2)
    Mock :test received :test with unexpected arguments
      expected: (1, 2, 3)
           got: (3, 2, 2)

Shouldn't it report:

expected: (3,2,1)
     got: (3,2,2)
@txus

This comment has been minimized.

Show comment
Hide comment
@txus

txus Jan 29, 2011

Contributor

A failing spec is provided in this commit: txus/rspec-mocks@e83f229

Contributor

txus commented Jan 29, 2011

A failing spec is provided in this commit: txus/rspec-mocks@e83f229

@txus

This comment has been minimized.

Show comment
Hide comment
@txus

txus Jan 29, 2011

Contributor

The thing was: when RSpec fails to match the arguments (3,2,2), it looks for similar argument expectations (i.e, with the same method), and the first it finds is (1,2,3), although :test has already been called with those arguments. Instead of this, it should take into account whether the method has already been called with those arguments.

I've fixed it in this commit, and moved the bug_report_34_spec into its proper place:

txus/rspec-mocks@e2f7923

Contributor

txus commented Jan 29, 2011

The thing was: when RSpec fails to match the arguments (3,2,2), it looks for similar argument expectations (i.e, with the same method), and the first it finds is (1,2,3), although :test has already been called with those arguments. Instead of this, it should take into account whether the method has already been called with those arguments.

I've fixed it in this commit, and moved the bug_report_34_spec into its proper place:

txus/rspec-mocks@e2f7923

@txus

This comment has been minimized.

Show comment
Hide comment
@txus

txus Feb 5, 2011

Contributor

Fix failure message when message received with incorrect args.

Contributor

txus commented Feb 5, 2011

Fix failure message when message received with incorrect args.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment