Listing 3.4. Generating a StaticPages controller

Rails comes with a script for making controllers called generate; all it
needs to work its magic is the controller’s name. Since we’ll be making
a controller to handle static pages, we’ll call it the StaticPages
controller. We’ll also plan to make actions for a Home page, a Help
page, and an About page. The generate script takes an optional list of
actions, so we’ll include two of the initial actions directly on the
command line (Listing 3.4).
3.2.1 Test-driven development

In test-driven development, we first write a failing test, represented
in many testing tools by the color red. We then implement code to get
the test to pass, represented by the color green. Finally, if necessary,
we refactor the code, changing its form (by eliminating duplication, for
example) without changing its function. This cycle is known as “Red,
Green, Refactor
3.3.2 Passing title tests

Our plan is to edit the Home, Help, and About pages to make page titles
that change on each page. This will involve using the <title> tag in our
page views. Most browsers display the contents of the title tag at the
top of the browser window (Google Chrome is an odd exception), and it is
also important for search-engine optimization. We’ll start by writing
tests for the titles, then add the titles themselves, and finally use a
layout file to refactor the resulting pages and eliminate duplication.