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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:39:49+00:00 2026-06-17T02:39:49+00:00

I keep getting this error when trying to run a Rspec test as part

  • 0

I keep getting this error when trying to run a Rspec test as part of the Rubyonrails tutorial

Failures:

1) GET ‘about’ should be successful

 Failure/Error: get 'about'
 RuntimeError:
   @controller is nil: make sure you set it in your test's setup method.
 # ./spec/controllers/pages_controller_spec.rb:27:in `block (2 levels) in <top (required)>'

I have tried everything I can to try to correct it but all have proven futile. Any help will be appreciated.

Here is my spec_helper.rb file

require 'rubygems'
require 'spork'

Spork.prefork do
end
Spork.each_run do
end

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.include RSpec::Rails::ControllerExampleGroup
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end

pages_controller.rb file:

class PagesController < ApplicationController
 def home
 end

 def contact
 end

 def about
 end
 end

pages_controller_spec.rb file:

require 'spec_helper'

describe PagesController do
  render_views

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

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

end

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

routes.rb file:

SampleApp::Application.routes.draw do
  get "pages/home"

  get "pages/contact"

  get "pages/about"

end

btw I have no problem running Spork and autotest.

  • 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-17T02:39:50+00:00Added an answer on June 17, 2026 at 2:39 am

    The problem is the nesting in your tests: the describe PagesController block only wraps the first two tests and not the last one.

    It should look like this:

    describe PagesController do
      render_views
    
      describe "GET 'home'" do
        it "should be successful" do
          get 'home'
          response.should be_success
        end
      end
    
      describe "GET 'contact'" do
        it "should be successful" do
          get 'contact'
          response.should be_success
        end
      end
    
      describe "GET 'about'" do
        it "should be successful" do
          get 'about'
          response.should be_success
        end
      end
    end
    

    See: How do i get rid of @controller is nil error in my tests

    p.s. I’ve taken out all the render_views except the one in the top-level describe block — you should only need to call it once for the block (see the specs).

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

Sidebar

Related Questions

I'm trying to run a very simple integration test and keep getting this error:
Hi I keep getting this error, I'm trying to get tweets from twitter via
I keep getting this error trying to run the debugger: Program received signal EXC_BAD_ACCESS,
I'm trying to run the code below and I keep getting this error back:
Hi i'm trying to run Nant but keep getting this error when i tried
I keep getting this error when trying to run the code: (let ((exp lambda
This is really frustrating. I keep getting this error when trying to run a
I'm trying to get Factory Girl working, but I keep getting this error when
I'm trying to run a PHP script, but I keep getting this error whenever
I keep getting this error while trying to modify some tables. Here's my code:

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.