title: Rails RSpec request spec fails because unexpected %2F added to redirect response
body: <p>In config/routes.rb:</p>
  
  <pre><code>get 'books(/*anything)' =&gt; redirect( "/public/%{anything}" ), :format =&gt; false
  </code></pre>
  
  <p>In spec/requests/store_request_spec.rb:</p>
  
  <pre><code>get '/books/aoeu/snth'
  expect(response).to redirect_to( '/public/aoeu/snth' )
  </code></pre>
  
  <p>This fails with:</p>
  
  <pre><code>Failure/Error: expect(response).to redirect_to( '/public/aoeu/snth' )
     Expected response to be a redirect to &lt;http://www.example.com/public/aoeu/snth&gt; but was a redirect to &lt;http://www.example.com/public/aoeu%2Fsnth&gt;.
  Expected "http://www.example.com/public/aoeu/snth" to be === "http://www.example.com/public/aoeu%2Fsnth".
   # ./spec/requests/store_request_spec.rb:14:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Why is the %2F being inserted into the redirect response and how do I prevent it?</p>
  
  <p>Edit:</p>
  
  <p>If I use:</p>
  
  <pre><code>get 'books(/*anything)' =&gt; redirect( CGI::unescape("/public/%{anything}") ), :format =&gt; false
  </code></pre>
  
  <p>to create an unescaped string I still get the same error.</p>