I am trying to set expectations on a mocked ActiveRecord model. I have created the following example, which should pass based on the documentation I can find.
it "should pass given the correct expectations" do
payment = mock_model(Payment)
payment.should_receive(:membership_id).with(12)
payment.membership_id = 12
end
It is failing with the error "…Mock 'Payment_1004' received unexpected message :membership_id= with (12)"
I realize I am testing the mocking framework, I am just trying to understand how to setup expectations.
Best Answer
You're setting the expectation on the wrong method name -
:membership_id
is the "getter",:membership_id=
is the "setter". The correct line would be: