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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:42:30+00:00 2026-05-21T19:42:30+00:00

Trying out rspec-rails. I get a weird error – no routes are supposedly found,

  • 0

Trying out rspec-rails. I get a weird error – no routes are supposedly found, even though I can access them fine in the browser when running rails s.

I even tried it with just /

Failure/Error: get "/"
     ActionController::RoutingError:
       No route matches {:controller=>"action_view/test_case/test", :action=>"/"}

I can definitely access / and other resources in the browser, though. Is there something I could’ve missed when setting rspec up? I put it into the Gemfile and ran rspec:install.

Thank you,
MrB

edit: Here’s my test

  1 require 'spec_helper'
  2 
  3 describe "resource" do
  4   describe "GET" do
  5     it "contains /" do
  6       get "/"
  7       response.should have_selector("h1", :content => "Project")
  8     end
  9   end
 10 end

Here’s my route file:

myApp::Application.routes.draw do

  resources :groups do
    resources :projects
  end 

  resources :projects do
    resources :variants
    resources :steps

    member do
      get 'compare'
    end 
  end 

  resources :steps do
    resources :costs
  end 

  resources :variants do
    resources :costs
  end 

  resources :costs

  root :to => "home#index"

end

My spec_helper.rb:

ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'    

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|

  config.mock_with :rspec
  config.include RSpec::Rails::ControllerExampleGroup


  config.fixture_path = "#{::Rails.root}/spec/fixtures"


  config.use_transactional_fixtures = true
end

Didn’t really change anything here, I think.

  • 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-21T19:42:30+00:00Added an answer on May 21, 2026 at 7:42 pm

    As far as i know, you are trying to combine two tests into one. In rspec this should be solved in two steps. In one spec you test the routing, and in another you test the controller.

    So, add a file spec/routing/root_routing_spec.rb

    require "spec_helper"
    
    describe "routes for Widgets" do
      it "routes /widgets to the widgets controller" do
        { :get => "/" }.should route_to(:controller => "home", :action => "index")
      end
    end
    

    And then add a file spec/controllers/home_controller_spec.rb, and I am using the extended matchers defined by shoulda or remarkable.

    require 'spec_helper'
    
    describe HomeController do
    
      render_views
    
      context "GET index" do
        before(:each) do
          get :index
        end
        it {should respond_with :success }
        it {should render_template(:index) }
    
        it "has the right title" do
          response.should have_selector("h1", :content => "Project")
        end
    
      end
    end  
    

    Actually, I almost never use render_views but always test my components as isolated as possible. Whether the view contains the correct title I test in my view-spec.

    Using rspec i test each component (model, controller, views, routing) separately, and i use cucumber to write high level tests to slice through all layers.

    Hope this helps.

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

Sidebar

Related Questions

Trying out the examples found on pleac.sf.net , I'm not able to get an
Came across this error when trying out the ruby on rails tutorial section with
I am using Rspec 2.6.1 on Rails 3.1. I am trying out a simple
I'm trying out 'shoulda' on top of rspec (rails 3) with the following spec:
I'm trying out rspec, and immediately hit a wall when it doesn't seem to
I was reading up on RSpec and I was trying to figure out how
I'm trying to follow Michael Hartl's Ruby on Rails Tutorial in http://ruby.railstutorial.org/chapters/sign-in-sign-out , but
I'm using RSpec for my Rails 3 tests and trying to use Spork. I
Am trying out Ruby on Rails in Windows XP using the Hello World example.
I am trying to sort out my RSpec tests for a controller of mine,

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.