Skip to content

Instantly share code, notes, and snippets.

@runa
Created January 29, 2013 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runa/4668565 to your computer and use it in GitHub Desktop.
Save runa/4668565 to your computer and use it in GitHub Desktop.
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