Deleted old answer as not helpful. This works and is tested:
In routes.rb
:
get 'books/*anything', to: redirect { |params, request|
path = CGI.unescape(params[:anything])
"http://#{request.host_with_port}/public/#{path}"
}
In spec/requests/store_request_spec.rb
:
describe "books globbed route" do
before { get('/books/abcd/efgh') }
it "routes to public" do
expect(response).to redirect_to('/public/abcd/efgh')
end
end
Run bundle exec rspec spec/requests/store_request_spec.rb # =>
Store
books globbed route
routes to public
Finished in 0.15973 seconds
1 example, 0 failures
Randomized with seed 15579