Jonathan Conway of New Bamboo (more on this at the end of this post) has put together a rather comprehensive walkthrough on using mocks with Rails and using them to define your interfaces. Not having cut my teeth with mocks yet, I took the rare step of asking for a personal summary of the article by the author himself, and Jonathan delivered!
Everyone’s heard of using stubs and mocks to replace external systems or third party libraries within their applications tests, but something a lot of people don’t realise is that by stubbing and/or mocking associated models in unit tests it allows them to think more clearly about the interfaces in which they communicate with each other, hopefully leading to less coupling and a cleaner design. Read More