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 7857929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:11:49+00:00 2026-06-02T21:11:49+00:00

I am working through Michaels Hartls Ruby on Rails Tutorial. in Chapter 3 I

  • 0

I am working through Michaels Hartls Ruby on Rails Tutorial. in Chapter 3 I set up R Spec and autotest as instructed. So far I have done everything that was instructed in the tutorial but I keep getting this error message.

rspec ./spec/controllers/pages_controller_spec.rb:13 # PagesController GET 'home' should have the right title
rspec ./spec/controllers/pages_controller_spec.rb:31 # PagesController GET 'contact' should have the right title
rspec ./spec/controllers/pages_controller_spec.rb:43 # PagesController GET 'about' should have the right title
rspec ./spec/controllers/pages_controller_spec.rb:57 # PagesController GET 'help' should have the right title'

My Gemfile Shows

source 'https://rubygems.org'

gem 'rails', '3.2.3'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'heroku'

group :development do

 gem 'autotest', '4.4.6'
 gem 'rspec-rails', '2.9.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

group :production do
# gems specifically for Heroku go here  
   gem 'pg'
end
group :test do

gem 'rspec',  '2.9.0'
gem 'webrat', '0.7.3'
gem "spork",  '0.9.0'

end
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
   gem 'therubyracer', :platform => :ruby
   gem 'execjs'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

My application.html.erb shows

  <!DOCTYPE>
<html>
    <head>
        <title><%= title %></title>
        <%= csrf_meta_tag %>
        </head>
    <body>
        <%= yield %>
    </body>
</html>

My page_controller_spec.rb shows this

 require 'spec_helper'

describe PagesController do
render_views
#home

  describe "GET 'home'" do
    it "should be successful" do
      get 'home'
      response.should be_success
    end

    it "should have the right title" do
      get 'home'
      response.should have_selector("title", 
                      :content => @base_title + " | Home")
     end

     it "should have a non-blank body" do
  get 'home'
  response.body.should_not =~ /<body>\s*<\/body>/
end
 end 
  #contact

  describe "GET 'contact'" do
    it "should be successful" do
      get 'contact'
      response.should be_success
    end 
      it "should have the right title" do
      get 'contact'
      response.should have_selector("title",
                      :content => @base_title + " | Contact")
  end
  end
#about
  describe "GET 'about'" do
    it "should be successful" do
      get 'about'
            response.should be_success
      end      
             it "should have the right title" do
      get 'about'
      response.should have_selector("title", 
                      :content =>  @base_title  + "  | About")
    end 
    end

    #help

  describe "GET 'help'" do
    it "should be successful" do
      get 'help'
            response.should be_success
      end      
             it "should have the right title" do
      get 'help'
      response.should have_selector("title", 
                      :content => @base_title + "| Help")
    end 
    end  
  end

pages_helper.rb has

module PagesHelper


      # Return a title an a per-page basis
    def title
      base_title = "Ruby on Rails Tutorial Sample App"
      if @title.nil?
        base_title
      else
        "#{base_title} | #{@title}"
      end
    end
    end

pages_controller.rb has

class PagesController < ApplicationController

  def home
        @title = 'home'
     end

  def contact
    @title = 'contact'
  end

  def about
    @title = 'about'
  end

   def help
    @title = 'help'
  end


end

Everything shows good in the browsers. But I still get these errors when my test are run using rspec spec/..

Can someone help?

  • 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-02T21:11:51+00:00Added an answer on June 2, 2026 at 9:11 pm

    You need to set @base_title. You could set it anywhere in the spec prior to your use of it, but since it’s the same everywhere you could put it in a before block, ie

    before(:each) do
      @base_title = ...
    end
    

    You could also use let (but then the specs need to use base_title rather than @base_title

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working through the Ruby on Rails 3 Tutorial: Learn Rails by Example by
I'm working through Michael Hartl's Ruby on Rails tutorial on http://ruby.railstutorial.org . I'm having
I am working through the Ruby on Rails Tutorial by Michael Hartl and I
I am relatively new to rails and have been working my way through the
I'm reading through Hartl's book, Ruby on Rails by Example. In chapter 11, it
I'm working through Practical Web 2.0 Appications currently and have hit a bit of
Working through the five minute Xtext tutorial (http://www.eclipse.org/Xtext/documentation/2_1_0/010-xtext-in-5-minutes.php) I get to Generating The Language
Working through a sample in Chapter 3 of Programming in Scala, the following code
Working through a zend tutorial & get this message, & not sure where to
Currently working through a Teach Yourself WPF tutorial. Usually I can mentally convert from

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.