(Red, Green, Refactor)
We wrote the test first, then fixed each subsequent failure(red), running the test again after each step, until it works (green).
- Write test first
- test “should get about” do
get static_pages_about_url
assert_response :success
end - ERROR: NameError: undefined local variable or method `static_pages_about_url’ for
- test “should get about” do
- Add route for about in config/routes.rb
- get ‘static_pages/about’
- ERROR: AbstractController::ActionNotFound: The action ‘about’ could not be found for
- Add action to the controller in static_pages_controller.rb
- def about
- end
- ERROR: ActionController::MissingExactTemplate: StaticPagesController#about is missing a template for request formats: text/html
- Create app/views/static_pages/about.html.erb file
- run ‘rails test’ again
- 3 runs, 3 assertions, 0 failures, 0 errors, 0 skips