On Feb 11, 9:20 pm, clay s <[email protected]> wrote: > On Monday, February 11, 2013 4:05:12 PM UTC-8, Myron Marston wrote: > > I consider the use of `should_receive` with a return value to be a code > > smell since I generally care about command/query separation. > > Combining should_receive with a return value is not in any way related to > command/query separation. You could replace the mock with a stub or (if the > return value isn't being used by the code under test) remove the return > value, and the test would be equivalent, and would still violate (or not > violate) command/query separation just as much as before.
Sure, you can violate command/query separation without using `should_receive` with a return value. My point was that: * As a rule of thumb, I only use `should_receive` for messages that produce side effects (e.g. commands). It's generally better to use a stub for a side-effect free message (e.g. a query). * If I also have to use `and_return` because the code-under-test cares about the return value, it's design feedback suggesting I'm combining a command and a query into one method call, when usually it's better to separate them. Myron -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
