title: How do you test route constraints using RSpec
body: <p>Given a couple of cities in the DB:</p>
  
  <pre><code>City.first.attributes =&gt; {:id =&gt; 1, :name =&gt; 'nyc'}
  City.last.attributes =&gt;  {:id =&gt; 2, :name =&gt; 'boston'}
  </code></pre>
  
  <p>And a route like:</p>
  
  <pre><code>match '/:city/*dest' =&gt; 'cities#do_something', :constraints =&gt; {:city =&gt; /#{City.all.map{|c| c.name}.join('|'}/}
  </code></pre>
  
  <p>(so the constraints should evaluate to: /nyc|boston/)</p>
  
  <p>And a spec:</p>
  
  <pre><code>it "recognizes and generates a route for city specific paths" do
    { :put =&gt; '/bad-city/some/path' }.should route_to({:controller =&gt; "cities", :action =&gt; "do_something", :dest =&gt; 'some/path', :city =&gt; 'bad-city'})
  end
  </code></pre>
  
  <p>I would expect a failure. But it passes.</p>
  
  <p>Likewise:</p>
  
  <pre><code>it "doesn't route bad city names" do
    { :put =&gt; '/some-bad-city/some/path' }.should_not be_routable
  end
  </code></pre>
  
  <p>Here I expect it to pass, but it fails.</p>
  
  <p>It seems the constraint is being ignored in the specs, since the matching cities have the same behavior as the bad ones.</p>
  
  <p>Is this a known issue, or am I missing something that I need to do?</p>