I'm hoping to better understand the process of using TDD with a Rails 4 application.
The best post I've found on the subject to date is 15 TDD steps to create a Rails application. It suggests following these steps:
- scaffold a model
- create unit test for the model --> test fails
- create migration for model --> test passes
- scaffold a controller with desired actions
- create functional test for the controller --> test fails
- add code to controller action --> test passes
- create functional test for the view --> test fails
- create view --> test passes
This approach leads to a lot more work that just rails g scaffold Foo
. But using the scaffolder would result in tests (if built) that would pass, violating a core TDD principle.
I've also read that one shouldn't test functionality that is provided by the framework (e.g. unit tests for validates_presence_of
).
Which leads me to ask: should I skip unit and function tests for code that is generated by the scaffolder and just test my customizations or should follow the layer-at-a-time pattern used by the blog posting's author?