New Mocha Docs
Posted by James Mead Sun, 03 Sep 2006 18:20:00 GMT
Spurred on by Thorsten’s comment on Gluttonous’ blog and a mention of Mocha in the Top 5 Rails Stories of the Week, I’ve given the Mocha documentation a major overhaul.
Now the RDoc only shows the public API which should hopefully improve the signal-to-noise ratio and show how simple it is to use.
- Create traditional mock objects
- Set expectations on traditional mock objects
- Set expectations on real (non-mock) classes
- Make expectations more specific or define behaviour of stub
Good general information on mocking…

This is just wonderful. Thank you for taking the time out to put this together.
Wahoooo! Thanks a million or taking the time to write this up. I’m sure we’ll come up with more details for you to fill in :-).
The documentation says :
“One of its main advantages is that it allows you to mock and stub methods on real (non-mock) classes and instances. [...]. This is a feature that is not currently offered by other Ruby mocking libraries like FlexMock and RSpec.”
Inspired by Mocha, it looks like FlexMock now has stubs – see http://onestepback.org/software/flexmock/
Thanks for the link. It’s nice of Jim to credit Mocha as the inspiration for the flexstub stuff. I’d better update the Mocha README :-)
We went down the road of using blocks in earlier incarnations of Mocha, but we decided they didn’t do much for readability. Take a look at the comparison…
FlexMock Mocha