Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:09:26+00:00 2026-06-10T20:09:26+00:00

I am working through Michael Hartl’s Ruby on Rails Tutorial Chapter 5 exercises and

  • 0

I am working through Michael Hartl’s Ruby on Rails Tutorial Chapter 5 exercises and I keep getting a failing test that I cannot figure out.

I’m working with the click_link problem and All the caps match and the I believe all the other files are correct. I’m really not sure what’s wrong here. I’ve tried restarting Spork. And whenever I comment out the first click_link test, it pull up an error for the second one and so on… Feel free to take a look at the code at http://github.com/sambaek/sample_app.

Can someone help me out? Thanks a bunch!

spec/support/utilities.rb

include ApplicationHelper

spec/requests/static_pages_spec.rb

require 'spec_helper'

describe "Static pages" do

  subject { page }

  shared_examples_for "all static pages" do
    it { should have_selector('h1',    text: heading) }
    it { should have_selector('title', text: 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_selector 'title', text: '| Home' }
  end

  describe "Help page" do
    before { visit help_path }

    let(:heading)    { 'Help' }
    let(:page_title) { 'Help' }

    it_should_behave_like "all static pages"  
  end

  describe "About page" do
    before { visit about_path }

    let(:heading)    { 'About Us' }
    let(:page_title) { 'About Us' }

    it_should_behave_like "all static pages"
  end

  describe "Contact page" do
    before { visit contact_path }

    let(:heading)    { 'Contact' }
    let(:page_title) { 'Contact' }

    it_should_behave_like "all static pages"
  end

  it "should have the right links on the layout" do
    visit root_path
    click_link "About"
    page.should have_selector 'title', text: full_title('About Us')
    click_link "Help"
    page.should have_selector 'title', text: full_title('Help')
    click_link "Contact"
    page.should have_selector 'title', text: full_title('Contact')
    click_link "Home"
    click_link "Sign up now!"
    page.should have_selector 'title', text: full_title('Sign Up')
    click_link "sample app"
    page.should_not have_selector 'title', text: full_title(' | Home')
  end
end

spec/helpers/application_helper_spec.rb

require 'spec_helper'

describe ApplicationHelper do

  describe "full_title" do
    it "should include the page title" do
      full_title("foo").should =~ /foo/
    end

    it "should include the base title" do
      full_title("foo").should =~ /^Ruby on Rails Tutorial Sample App/
    end

    it "should not include a bar for the home page" do
      full_title("").should_not =~ /\|/
    end
  end
end

app/helpers/application_helper.rb

module ApplicationHelper
    def full_title(page_title)
        base_title = "Ruby on Rails Tutorial Sample App"
        if page_title.empty?
            base_title
        else
            "#{base_title} | #{page_title}"
        end
    end
end

Terminal Output

rspec spec/

..F............

Failures:

  1) Static pages should have the right links on the layout
     Failure/Error: page.should have_selector 'title', text: full_title('About Us')
       expected css "title" with text "Ruby on Rails Tutorial Sample App | About Us" to return something
     # ./spec/requests/static_pages_spec.rb:52:in `block (2 levels) in <top (required)>'

Finished in 4.37 seconds
15 examples, 1 failure

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:49 # Static pages should have the right links on the layout
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:09:28+00:00Added an answer on June 10, 2026 at 8:09 pm

    The problem is because your links in layouts/footer and layouts/header don’t go anywhere. They’re clickable by the spec, but they just go to # rather than their proper page. If you correct these links then the spec will work.

    In app/views/layouts/_footer.html.erb:

    <li><%= link_to "About",   '/about' %></li>
    <li><%= link_to "Contact", '/contact' %></li>
    

    In app/views/layouts/_header.html.erb:

     <li><%= link_to "Home",    '/' %></li>
     <li><%= link_to "Help",    '/help' %></li>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working through the Ruby on Rails Tutorial by Michael Hartl and I
I'm working through Michael Hartl's Ruby on Rails tutorial on http://ruby.railstutorial.org . I'm having
I'm working through Michael Hartl's Rails Tutorial. I've come to Chapter 9, Exercise 1
I am currently working through Michael Hartl's Rails Tutorial while experimenting with some other
I'm a newbie working through Michael Hartl's Tuby on Rails Tutorial and I have
Hi i'm working through the Hartl's Ruby on Rails Tutorial and i'm stuck with
I'm working through the Michael Hartl Tutorial and am having trouble getting sign-outs to
I am working through Michaels Hartls Ruby on Rails Tutorial. in Chapter 3 I
I'm working through the Ruby on Rails 3 Tutorial: Learn Rails by Example by
I am following the Ruby on Rails tutorial by Michael Hartl http://ruby.railstutorial.org/ I installed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.