it tells the double to only call the methods we tell it to expect and ignore any other methods
Example:
it “should receive sth.a”
a = double(‘model’)
model = Model.new(a)
a.should_receive(:method_a).with(sth.a)
model.start
end
def start
method_a(sth.a)
method_a(sth.b)
end
+++++++++++++++++++++++++++++++++++++
if we add another example
it “should receive sth.b”
a = double(‘model’)
model = Model.new(a)
a.should_receive(:method_a).with(sth.b)
model.start
end
Both example will be failed
+++++++++++++++++++++solution ++++++++++++++++++
change a = double(‘model’) to a = double(‘model’).as_null_object