I am working through Michael Hartl's Ruby on Rails tutorial, and I am doing the Chapter 5 exercises. Can someone please explain why this test is failing?
Here is spec/requests/static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
# let(:base_title) { "Ruby on Rails Tutorial Sample App" }
subject { page }
shared_examples_for "all static pages" do
it { should have_selector('h1', text: heading) }
it { should have_title(full_title(page_title)) }
end
describe "Home page" do
before { visit root_path }
let(:heading) { 'Sample App' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_title('| Home') }
end
describe "Help page" do
before { visit help_path }
let(:heading) { 'Help' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_title('| Help') }
end
describe "About page" do
before { visit about_path }
let(:heading) { 'About' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_title('| About Us') }
end
describe "Contact page" do
before { visit contact_path }
let(:heading) { 'Contact' }
let(:page_title) { '' }
it_should_behave_like "all static pages"
it { should_not have_title('| Contact') }
end
it "should have the right links on the layout" do
visit root_path
click_link "About"
expect(page).to have_title(full_title('About Us'))
click_link "Help"
expect(page).to have_title(full_title('Help'))
click_link "Contact"
expect(page).to have_title(full_title('Contact'))
click_link "Home"
click_link "Sign up now!"
expect(page).to have_title(full_title('Sign up'))
click_link "sample app"
expect(page).to have_title(full_title('Sample App'))
end
end
Here is app/views/static_pages/about.html.erb
<h1>About Us</h1>
<p>
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
is a project to make a book and screencasts to teach web development
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
is the sample application for the tutorial.
</p>
My test rspec spec/
Failures:
1) Static pages should have the right links on the layout
Failure/Error: expect(page).to have_title(full_title('About us'))
expected #has_title?("Ruby on Rails Tutorial Sample App | About us") to return true, got false
# ./spec/requests/static_pages_spec.rb:57:in `block (2 levels) in <top (required)>'
Finished in 1.11 seconds
13 examples, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:54 # Static pages should have the right links on the layout