title: Rails/RSpec: 'get' to a different controller
body: <p>I have the following in my Rails 3 controllers/application.rb (which I'm trying to write a spec for):</p>
  
  <pre><code>  rescue_from CanCan::AccessDenied do |exception|
      flash[:alert] = t(:access_denied)
      if (current_user) then
        redirect_to root_url
      else
        session[:direct_redirect] = request.url
        redirect_to new_user_session_url
      end
    end
  </code></pre>
  
  <p>I'd like to write some specs to ensure the functionality works. I've placed the tests in spec/controller/application_controller_spec.rb, and figure I should write something such as:</p>
  
  <pre><code>  it "should redirect to the root url" do
      controller.stub(:authorize!) { raise CanCan::AccessDenied }
      get :index
      response.should redirect_to(root_url)
    end
  </code></pre>
  
  <p>The problem is that get :index line. The spec throws back a 'no route matches controller => application" error. "Fair enough", I figured, and tried to route to a different controller. Attempts were:</p>
  
  <pre><code>* get :controller =&gt; 'purchases', :action =&gt; :index
  * get purchases_url
  * get '/purchases/'
  </code></pre>
  
  <p>All of which where interpreted as an action under the 'application' controller.</p>
  
  <p>So, how can I route to a controller in rspec apart from the one in which the spec is written?</p>