[ACCEPTED]-RSpec: Expecting a message multiple times but with differing parameters-rspec

Accepted answer
Score: 12

Try creating your mock as a null object 9 to ignore extra method calls. Each of your 8 expectations will still have to be met, but 7 they won't step on each other.

@my_mock = mock("a_mock").as_null_object

This follows 6 the Null Object pattern, in which any extraneous messages 5 are just ignored. It is useful with mocks 4 when you want to make sure a method gets 3 called with certain parameters, but you 2 don't care if it is called with other parameters 1 or if any other methods get called.

More Related questions