How Test-Driven Development can dig you out of a hole (17 feb 13)
I'm going to use it to demonstrate coding a Rails 4 app. It'll be a simple example of a site where you
To make it compatible with the latest Rails 4 beta release, I had to make many changes. I tried to make all the changes to the existing app, but each fix broke something else.
Then I realized what to do: start with a blank Rails app, and introduce lines of code from the existing app, one at a time, always driven by tests.
For example, I wrote a test which creates a user. The test framework said there is no 'user' model. So I created one. Then the test said there is no 'users' table. So I wrote a migration. Etc..
Having tests drive the gradual import of bits and pieces from the old project is a much better way of recreating the app. I only import what's needed, I solve each issue one at a time, and the site will end up fully tested.