Personally, given than spec-mocks is primarily intended for creating test 
doubles and stubbing objects I feel this would be a perverse default, in the 
limited cases where stubbing a real object is a good idea you almost never want 
this to happen, I can kind of see this sort of behaviour might be expected in 
rspec-expectations but I don’t feel like it should be the default in mocks.

Remember that the majority of `expect(something).to receive` calls are going to 
be in cases where something is a double and has no real behaviour in the first 
place.  

Jon Rowe
---------------------------
[email protected]
jonrowe.co.uk


On Tuesday, 15 September 2015 at 11:49, Brian John wrote:

> I've been using rspec for a few years now and one thing has bothered me since 
> the switch to the new expect syntax. For partial mocks, when using 
> allow/expect(something).to receive... it reads more like a spy to me than a 
> stub. Using an example from the README:
>  
> expect(Person).to receive(:find)
>  
> Reading this like a sentence, I would expect Person to receive a call to 
> find...and that's it. Nothing in the above indicates to me that the find 
> method should also be stubbed. The stub behavior seems like a side effect.  
>  
> My proposal would be to change the default behavior of receive so that 
> and_call_original is the default behavior. An additional method could be 
> added to to trigger the stub behavior. So the equivalent behavior for the 
> above example would read something like this:
>  
> expect(Person).to receive(:find).and_stub
>  
> Obviously making this change would be relatively painful in that:
> * some may not agree that this is the correct behavior
> * those that are used to the prior behavior would have to get used to the new 
> behavior
> * it would break a lot of existing tests
>  
> Given the above I wanted to post here to see how others felt before 
> submitting a pull request. My apologies if this has already been discussed, I 
> did a search of the issues in the rspec-mocks repository and this forum and I 
> couldn't find anything.  
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> (mailto:[email protected]).
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rspec/8d5d5525-5749-4284-b8d7-e38833758d13%40googlegroups.com
>  
> (https://groups.google.com/d/msgid/rspec/8d5d5525-5749-4284-b8d7-e38833758d13%40googlegroups.com?utm_medium=email&utm_source=footer).
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/E66977996C89404F837AD40B422F324A%40jonrowe.co.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to