This project is archived and is in readonly mode.

#5474 ✓stale
James Conroy-Finn

ActionController::TestCase fails to recognise valid routes

Reported by James Conroy-Finn | August 27th, 2010 @ 03:47 PM

I'm unable to run controller and/or routing specs because ActionController::TestCase seems to fail to recognise valid routes, which work when requested via HTTP.

There is already a ticket on the rspec-rails issue tracker ( The following Rails template was used to demonstrate the issue stating it was to do with singular resources but it appears to also affect plural ones.

# Template for Rails 3.x apps.

gem 'rspec-rails', :version => ">= 2.0.0.beta.19"
run 'bundle install'

generate 'rspec:install'
rake 'db:migrate'

generate :controller, 'people'
route "resource :people, :singular => 'person'"

file 'spec/controllers/people_controller_spec.rb', <<-CODE
require 'spec_helper'

describe PeopleController do

  describe 'GET index' do
    before(:each) do
      get :index

    it 'should be a success' do
      response.should be_sucess

Mr. David Chelimsky responded with the following…

Controller specs mix in ActionController::TestCase::Behavior, which is where this problem lies. The same example fails in an ActionController::TestCase:

require 'test_helper'

class PeopleControllerTest < ActionController::TestCase
  test "GET index" do
    get :index
    assert_response :success

Comments and changes to this ticket

  • Andrew White

    Andrew White August 27th, 2010 @ 09:48 PM

    • State changed from “new” to “needs-more-info”
    • Importance changed from “” to “Low”

    I can't reproduce this and your code has a number of errors. Firstly :singular is no longer a valid option for resources - any custom inflections should be defined in the inflections initializer. Secondly, you're using a singleton resource call but trying to call get :index and singleton resources don't have an index action. Finally you have a typo on response.should be_sucess.

    Testing in RC2 using resources instead of resource, removing the :singular option and fixing the typo and then running rake spec shows no errors. Additionally, make sure that you've actually implemented the action - I forgot to when trying to reproduce this.

  • rails

    rails April 5th, 2011 @ 01:00 AM

    • State changed from “needs-more-info” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails April 5th, 2011 @ 01:00 AM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>