On Jan 28, 2008 12:01 PM, Jay D. [email protected] wrote:
I’m starting a new project and I want to try writing the client first. I.e. I want to write my ‘views’ first and I would like to mock out all the models in such a way that I can run the site and browse it with the mocked out models. Is it easy to use rspec’s mocking for this sort of thing and has anyone done it before? Does anyone know of a tutorial out there for doing something like this?
That’s not really what mocks are for. Mocks are a testing tool that
help you discover the interactions between objects in your code.
I’d say the best way is to develop in small iterations. Write a story
that represents a very small, but useful bit of functionality.
Implement it, going outside-in, and then when the story is completed
you’ve got something. Then work on the next story.
It would probably be a bad idea to implement the site backed by mocks,
because you end up going top-down instead of outside-in. There’s a
big difference. Top-down is implementing a layer for the entire
application, then moving to the layer it depends on, all the way down
until the app runs. The problem with that is that the feedback loop
is very wide, both in a development and business sense. In a
development sense, you don’t really know that your app works until you
type that final character that brings the whole thing together. In a
business sense, you end up doing a lot of dev work before you find out
if the feature you’ve built is acceptable (that’s where stories come
in as well, defining acceptance criteria).
It is a good idea to sometimes work on the interaction flow before
writing a bunch of Rails code, but that should really be done with
plain HTML wireframes, no application coding.