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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:01:05+00:00 2026-06-18T00:01:05+00:00

I have a Rails controller named PagesController that is nested as follows in app/controllers/sevenpages/public/pages_controller.rb

  • 0

I have a Rails controller named PagesController that is nested as follows in app/controllers/sevenpages/public/pages_controller.rb:

module Sevenpages
  module Public
    class PagesController < ApplicationController
      layout nil
      def show 
      end
    end
  end
end

I want to test this controller using RSpec

When I create the following test in spec/controllers/sevenpages/pubic/pages_controller_spec.rb:

require 'spec_helper'

describe Sevenpages:Public::PagesController do
  describe 'GET #show' do
    get :show, use_route: :sevenpages
    {{ tests go here }}
  end
end

I get the following error:

undefined method `get' for #<Class:0x007fe5c88e4300> (NoMethodError)

Now I understand what this error message means. The problem is that the RSpec::Rails::ControllerExampleGroup methods aren’t being automatically included in the controller test, so the standard Rails methods such as get, post, etc. aren’t available in the test.

I’ve tried all the recommended solutions that I can find without luck. Here’s what I’ve tried:

  • Ensure that spec/spec_helper.rb contains require 'rspec/rails'

  • Explicitly declare the test type using:

    describe Sevenpages::Public::PagesController, type: :controller do

  • Explicitly include the controller example group using:

    include RSpec::Rails::ControllerExampleGroup in the controller body

I’m at a loss as to what else I can try. I should note that I’m using:

  • Rails 3.2.11
  • RSpec 2.12.2

My app is a Rails engine, thus the use_route parameter to the get method.

The only thing I can think of is that RSpec doesn’t know how to handle a controller that’s nested this deeply. Is there some syntax that I should be aware of to enable RSpec to properly parse this as a controller test?

  • 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-18T00:01:06+00:00Added an answer on June 18, 2026 at 12:01 am

    The code you posted above has the test in a describe block. Typically with Rspec you put the test in a “it” block. Like:

    describe Sevenpages:Public::PagesController do
      describe 'GET #show' do
        it 'should work' do
          get :show, use_route: :sevenpages
          {{ tests go here }}
        end
      end
    end
    

    If you try this does the method become properly defined?

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

Sidebar

Related Questions

Hi there I have 3 files in rails as follows: 1)Located at app/controller/listings_controller.rb class
I have a controller in a Rails 3 app named my_store. I would like
I have a Rails controller action to test. In that action, a method User.can?
I have a Rails app with the usual application_controller, and a controller (and model)
I currently have the following controller method in a Rails app: def index @entries
I have a folder named public with an controller. There I but all the
Very often in a rails project, I have a 'content' controller that houses miscellaneous
I have a Rails application that uses a static_pages controller to render static pages
I have a controller named Reports::Accountant::ApprovedTimeOffRequestsController. It's in the proper directory, and the class
I have a controller named store_controller.rb and method index that renders index.html.erb , displaying

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.