3.5 Exercises

Make a Contact page for the sample app. Following the model in Listing
3.19, first write a test for the existence of a page at the URL
/static_pages/contact by testing for the title “Ruby on Rails Tutorial
Sample App | Contact”. Get your test to pass by filling the Contact page
with the content from Listing 3.30. (This exercise is solved as part of
Section 5.3.)

You may have noticed some repetition in the StaticPages controller spec
(Listing 3.19). In particular, the base title, “Ruby on Rails Tutorial
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 in Listing 3.31 still pass. Listing 3.31 introduces
string interpolation, which is covered further in Section 4.2.2.