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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:58:36+00:00 2026-05-30T00:58:36+00:00

I’m having a frustrating time with Rspec while working through the Ruby on Rails

  • 0

I’m having a frustrating time with Rspec while working through the Ruby on Rails Learn by Example tutorial on 5.2.

I’m currently trying to test my routing using rspec and the tests always comes back as a failure even though I followed the steps in the tutorial correctly to the best of my knowledge and have verified that the routing works by manually checking and testing the routing myself.

For example, the layout_links_spec.rb looks like this:

require 'spec_helper'

describe "LayoutLinks" do

    it "should have a Home page at '/'" do
        get '/'
        response.should have_selector('title', :content => "Home")
    end

    it "should have a Contact page at '/contact'" do
        get '/contact'
        response.should have_selector('title', :content => "Contact")
    end

    it "should have an About page at '/about'" do
        get '/about'
        response.should have_selector('title', :content => "About")
    end

    it "should have a Help Page at '/help'" do
        get '/help'
        reponse.should have_selector('title', :content => "Help")
    end

end

And my routes looks like:

SampleApp::Application.routes.draw do
  match '/contact', :to => 'pages#contact'
  match '/about', :to => 'pages#about'
  match '/help', :to => 'pages#help'
  get "pages/home"
  get "pages/contact"
  get "pages/about"
  get "pages/help"

  root :to => 'pages#home'
end

Rspec returns this failure:

  5) LayoutLinks should have a Home page at '/'
     Failure/Error: get '/'
     ActionController::RoutingError:
       No route matches [GET] "/"
     # ./spec/requests/layout_links_spec.rb:6:in `block (2 levels) in <top (required)>'

  6) LayoutLinks should have a Contact page at '/contact'
     Failure/Error: get '/contact'
     ActionController::RoutingError:
       No route matches [GET] "/contact"
     # ./spec/requests/layout_links_spec.rb:11:in `block (2 levels) in <top (required)>'

  7) LayoutLinks should have an About page at '/about'
     Failure/Error: get '/about'
     ActionController::RoutingError:
       No route matches [GET] "/about"
     # ./spec/requests/layout_links_spec.rb:16:in `block (2 levels) in <top (required)>'

  8) LayoutLinks should have a Help Page at '/help'
     Failure/Error: get '/help'
     ActionController::RoutingError:
       No route matches [GET] "/help"
     # ./spec/requests/layout_links_spec.rb:21:in `block (2 levels) in <top (required)>'

I get a similar error with my pages_controller_spec.rb tests as well

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

Gets this rspec error:

  1) PagesController GET 'home' should be successful
     Failure/Error: get 'home'
     ActionView::Template::Error:
       undefined local variable or method `root_path' for #<#<Class:0x00000103e8b210>:0x00000103e87de0>
     # ./app/views/layouts/_header.html.erb:3:in `_app_views_layouts__header_html_erb__1560745193027372362_2179584160'
     # ./app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__2627526215404316040_2176993080'
     # ./spec/controllers/pages_controller_spec.rb:15:in `block (3 levels) in <top (required)>'

I checked my code with the tutorial and it looks right. If I type in the url localhost:3000/home or /about etc, I get to the correct page which indicates that it must be routed correctly. I could just go forward with the tutorial, but I’d like to learn how to do TDD and use rspec in practice but I feel like I can’t rely on rspec to do this…

  • 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-05-30T00:58:39+00:00Added an answer on May 30, 2026 at 12:58 am

    I had exactly the same issue and was getting close to throwing something.

    Restarting Spork resolved the issue and all was well with the world again

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string

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.