Defining Interfaces through Mocking
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. This is part one of a two part article on this subject. The first part on this series is a gentle introduction to RSpec, mocking/stubbing and touches lightly on the subject I just explained.
In other news, Jonathan and Damien Tanner have collected their teams together to merge into New Bamboo, a London-based Rails consultancy. Check out their new blog and get subscribed.