Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Spec to display a weird behavior in Rack::URLMap

View spec_urlmap_with_domain_specific_routes.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
require 'rack/urlmap'
require 'rack/mock'
 
describe Rack::URLMap do
it "dispatches domain-specific routes correctly" do
map = Rack::URLMap.new("http://foo.org/" => lambda { |env|
[200,
{ "Content-Type" => "text/plain",
"X-Position" => "foo.org",
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
}, [""]]},
"/" => lambda { |env|
[200,
{ "Content-Type" => "text/plain",
"X-Position" => "default.org",
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
}, [""]]}
)
 
res = Rack::MockRequest.new(map).get("http://foo.org/")
res.should.be.ok
res["X-Position"].should.equal "foo.org"
 
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.