In config/routes.rb:
get 'books(/*anything)' => redirect( "/public/%{anything}" ), :format => false
In spec/requests/store_request_spec.rb:
get '/books/aoeu/snth'
expect(response).to redirect_to( '/public/aoeu/snth' )
This fails with:
Failure/Error: expect(response).to redirect_to( '/public/aoeu/snth' )
Expected response to be a redirect to <http://www.example.com/public/aoeu/snth> but was a redirect to <http://www.example.com/public/aoeu%2Fsnth>.
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 <top (required)>'
Why is the %2F being inserted into the redirect response and how do I prevent it?
Edit:
If I use:
get 'books(/*anything)' => redirect( CGI::unescape("/public/%{anything}") ), :format => false
to create an unescaped string I still get the same error.