[3.1.2] Generate StaticPages controller

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.

Note that we’ve used the option --no-test-framework to suppress the
generation of the default RSpec tests, which we won’t be using.
Instead, we’ll create the tests by hand starting in Section 3.2. We’ve
also intentionally left off the about action from the command line
arguments in Listing 3.4 so that we can see how to add it using
test-driven development, or TDD (Section 3.2).

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:static_pages_with_rails
[3.2.1] Add content to home and help pages

We’ll begin by adding some content to the Home page using test-driven
development, including a top-level heading (<h1>) with the content
Sample App.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:TDD
[3.2.2] Add an About page

Having seen test-driven development in action in a simple example,
we’ll use the same technique to accomplish the slightly more
complicated task of adding a new page, namely, the About page that we
intentionally left off in Section 3.1.2. By writing a test and running
RSpec at each step, we’ll see how TDD can guide us through the
development of our application code.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:adding_a_page
[3.3.1] Temporarily remove layout file

You may have noticed that the rails new command already created a layout
file. We'll learn its purpose shortly, but for now you should remove it
before proceeding.  You wouldn't normally do this in a real application,
but it's easier to understand the purpose of the layout file if we start
by disabling it.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:testing_a_title_change
[3.3.1] Modify the <title> tags of each page

Now that we’ve created the actions and views for some static pages,
we’ll make them very slightly dynamic by adding some content that
changes on a per-page basis: we’ll have the title of each page change
to reflect its content.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:testing_a_title_change
[3.3.3] Print title with embedded Ruby

Paradoxically, we’ll take the first step toward eliminating duplication
by first adding some more: we’ll make the titles of the pages, which
are currently quite similar, match exactly. This will make it much
simpler to remove all the repetition at a stroke.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:embedded_ruby
[3.3.4] Restore layout file

In order to factor out this common structure, Rails comes with a special
layout file called application.html.erb, which we removed in Section
3.3.1 and which we'll now restore.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:layouts
[3.3.4] Replace layout title with embedded Ruby version

To get the layout to work, we have to replace the default title with the
Embedded Ruby from the examples above.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:layouts
[3.3.4] Change views back to use layouts

Of course, the views are still filled with all the HTML structure
included in the layout, so we have to remove it, leaving only the
interior contents.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:layouts
[3.5] Add Contact page

Make a Contact page for the sample app. First write a test for the
existence of a page at the URI /static_pages/contact. (Hint: Test for
the right title.) Then write a second test for the title “Ruby on Rails
Tutorial Sample App | Contact”. Get your tests to pass, and then fill
in the Contact page with content.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:static_pages_exercises
[3.5] Reduce repetition in RSpec tests

You may have noticed some repetition in the StaticPages controller spec.
In particular, the base title, “Ruby on Rails Tutoria Sample App”, is
the same for every title test. Using the RSpec let function, which
creates a variable corresponding to its argument, verify that the tests
still pass.

[Source] http://ruby.railstutorial.org/chapters/static-pages#sec:static_pages_exercises
Merge branch 'static-pages'