title: RSpec test routes with mounted engine
body: <p>I have a Rails app which mounts another engine to its routes, and also overrides some routes from the engine. Here is the routes.rb:</p>
  
  <pre><code>Spree::Core::Engine.routes.draw do
    # some other routes
    root :to =&gt; "home#index"
  end
  
  MyNamespace::Application.routes.draw do
    class CityConstraint
      def matches?(request)
        Spree::CityZone.where(:url =&gt; request.params[:city_name]).exists?
      end
    end
    mount Spree::Core::Engine, :at =&gt; ':city_name/', :constraints =&gt; CityConstraint.new, :as =&gt; :city
    mount Spree::Core::Engine, :at =&gt; '/'
  end
  </code></pre>
  
  <p>When I try to test the routes with RSpec (2.14), I always get the following error:</p>
  
  <pre><code>#encoding: utf-8
  require 'spec_helper'
  
  RSpec.describe "routes.rb" do
    it "test routing" do
      expect(get: "/").to route_to(controller: "spree/home", action: "index")
    end
  end
  </code></pre>
  
  <blockquote>
  <pre><code> Failure/Error: expect(get: "/").to route_to(controller: "home", action: "index")
     No route matches "/"
   # ./spec/routing/routes_spec.rb:6:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  </blockquote>
  
  <p>I've found out, that when I add the following line, it works:</p>
  
  <pre><code>RSpec.describe "routes.rb" do
    routes { Spree::Core::Engine.routes } # this sets the routes
    it "test routing" do
      expect(get: "/").to route_to(controller: "spree/home", action: "index")
    end
  end
  </code></pre>
  
  <p>The problem is, that I want to test the whole app, because we mount the app twice, under a city name scope (e.g. <code>/your_city</code>) and under root <code>/</code>.</p>
  
  <p>When I try to set <code>routes { MyNamespace::Application.routes }</code> in my tests, I get the <code>No route matches "/"</code> error.</p>
  
  <p><strong>Any ideas how to test the whole stack of the mounted routes, including the routes from the engine?</strong></p>