[rspec-devel] [ rspec-Patches-15471 ] [PATCH] & quot; better& quot; handling of with(:foo)

noreply at rubyforge.org noreply at rubyforge.org
Sun Nov 11 22:23:26 EST 2007


Patches item #15471, was opened at 2007-11-08 19:45
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=15471&group_id=797

Category: mock module
Group: None
Status: Closed
Resolution: Rejected
Priority: 3
Submitted By: Pat Maddox (pergesu)
Assigned to: Nobody (None)
>Summary: [PATCH] "better" handling of with(:foo)

Initial Comment:
my_mock.should_receive(:something).with(:foo)
my_mock.something :foo
my_mock.something :bar

will blow up saying that :something was expected with :foo but received it with :bar.

In my opinion it should pass, because it was called with the supplied argument at some point.  If you want to restrict it then you should use :once.

Here's my patch (against r2831).  Let me know what you think.

----------------------------------------------------------------------

>Comment By: Pat Maddox (pergesu)
Date: 2007-11-11 20:23

Message:
I'm pretty certain this just came from a brain fart.  Of
course if you want to swallow calls then you should just
stub the method, and then you can expect a call as well.  I
agree that the mock object should be kept very tight unless
explicitly configured otherwise.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-11-08 19:59

Message:
This would not only break with tradition (most mock frameworks complain on the second, unexpected call) but it would also result in false positives in the cases in which people expect that call to complain.

I'm rejecting this, but if you want to open up a discussion about it on the list, feel free.

----------------------------------------------------------------------

Comment By: Pat Maddox (pergesu)
Date: 2007-11-08 19:47

Message:
btw I put "better" in quotes because judging from the
existing specs it looks like someone might disagree with me.
 So, at the very least, I'd like to generate some discussion.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3151&aid=15471&group_id=797


More information about the rspec-devel mailing list