undefined method `stored’ for #<RSpec::Mocks::MessageExpectation:
0xb688bb78>
I always thought both were equivalent. Can someone enlighten me?
This error message tells you the problem: the stub method in the
second example returns an instance of RSpec::Mocks::MessageExpectation,
not the double itself. If you did it this way, you’d get what you were
looking for:
hit = mock(‘hit’)
hit.stub(:stored) { 5 }
hit.stored.should eq(5)