Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Spec to display a weird behavior in Rack::URLMap
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.