title: How to test controllers with nested routes using rspec
body: <p>I create controller with InherritedResource</p>
  
  <pre><code>class AppsController &lt; InheritedResources::Base
    belongs_to :company
  
    # Devise
    before_filter :login_or_oauth_required
    # CanCan
    load_and_authorize_resource
  end
  </code></pre>
  
  <p>and try to test it with Rspec by this method</p>
  
  <pre><code>require "spec_helper"
  
  include Devise::TestHelpers
  
  describe AppsController do
    before(:each) do
      @company_1 = Factory.build(:company)
      application_1 = Factory.create(:application, :company =&gt; @company_1)
      application_2 = Factory.create(:application, :company =&gt; @company_1)
      application_3  = Factory.create(:application, :company =&gt; @company_1)    
      @company_2 = Factory.build(:company)
  
      @user_1   = Factory.create(:user)
      role_1    = Factory.create(:publisher_role, :company =&gt; @company_1) 
      profile_1 = Factory.create(:profile, :company =&gt; @company_1, :user =&gt; @user_1, :roles =&gt; [role_1])
    end
  
    describe "index action" do
      it "user_1 should have 3 applications from company_1" do
        sign_in @user_1
        params = {"company_id"=&gt;"1"}
        get :index
        assigns[:apps].should have(3).items
      end
    end
  end
  </code></pre>
  
  <p>The result is</p>
  
  <pre><code>Failure/Error: get :index
       ActionController::RoutingError:
         No route matches {:controller=&gt;"apps"}
  </code></pre>
  
  <p>How to tell Rspec to "Get" in to my nested route</p>
  
  <p>My routes</p>
  
  <pre><code>  resources :companies do
      resources :apps do
        resources :shelves do
          resources :publications
        end
      end
    end
  </code></pre>
  
  <p>I try to follow this Question <a href="https://stackoverflow.com/questions/6714732/how-to-test-controllers-with-nested-routes-using-rspec">How to test controllers with nested routes using Rspec?</a> but it's not work on my case</p>
  
  <p>I use Rails 3.1.1 and rspac 2.7</p>