If I am not mistaken, the essence of this question is here
@dummy_presenter.should_receive(:change_child_dummy_name).at_least(:once).with(child_dummy_id, 'Child Dummy network').and_return(@child_dummy)
should_receive
actually stubs the method's result.
if and_returns
is used, its operand is the new value, if not the stubbed value is nil
.
In your case that is the @child_dummy
object. Which by the way is the reason your test passed the first time as well!
One way to bypass this behavior is to use .and_call_original
which will do what you expect.
You should rewrite it as two tests:
- one that tests that
change_child_dummy_name
is called (maybe it is not necessairy) - one that will test that the desired attributes of
@child_dummy
(because the object you create in your rspec test will not be the same that the method will return).