TDD process in Rails

(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).

  1. 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
  2. Add route for about in config/routes.rb
    • get ‘static_pages/about’
    • ERROR: AbstractController::ActionNotFound: The action ‘about’ could not be found for
  3. 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
  4. Create app/views/static_pages/about.html.erb file
  5. run ‘rails test’ again
    • 3 runs, 3 assertions, 0 failures, 0 errors, 0 skips

Leave a comment

Your email address will not be published. Required fields are marked *