[mocha-developer] Returning the mock associated with an expectation.

Duncan Beevers duncanbeevers at gmail.com
Sun Nov 4 11:28:25 EST 2007

I was reading through the FlexMock docs and noticed the expectation
method .mock, which returns the original mock associated with an

It looks really handy for writing nice all-in-one mocks like:

mock_user = mock('User').expects(:first_name).returns('Jonah').mock

So I started playing around with mocha and found I could actually
already do this!
But I'm not sure how.  There's no attr_reader on @mock, and I couldn't
find out where this method is defined.

So, perhaps we could add this an explicit method on Expectation and
include a little rdoc on it?
I think a lot of people would get benefit from making this explicit.


More information about the mocha-developer mailing list