test/spec_rack_urlmap.rb in rack-1.0.1 vs test/spec_rack_urlmap.rb in rack-1.1.0

- old
+ new

@@ -42,10 +42,16 @@ res = Rack::MockRequest.new(map).get("/foo/bar/") res.should.be.ok res["X-ScriptName"].should.equal "/foo/bar" res["X-PathInfo"].should.equal "/" + res = Rack::MockRequest.new(map).get("/foo///bar//quux") + res.status.should.equal 200 + res.should.be.ok + res["X-ScriptName"].should.equal "/foo/bar" + res["X-PathInfo"].should.equal "//quux" + res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh") res.should.be.ok res["X-ScriptName"].should.equal "/bleh/foo" res["X-PathInfo"].should.equal "/quux" @@ -178,8 +184,32 @@ res = Rack::MockRequest.new(map).get("") res.should.be.ok res["X-Position"].should.equal "root" res["X-PathInfo"].should.equal "/" + res["X-ScriptName"].should.equal "" + end + + specify "should not squeeze slashes" do + map = Rack::URLMap.new("/" => lambda { |env| + [200, + { "Content-Type" => "text/plain", + "X-Position" => "root", + "X-PathInfo" => env["PATH_INFO"], + "X-ScriptName" => env["SCRIPT_NAME"] + }, [""]]}, + "/foo" => lambda { |env| + [200, + { "Content-Type" => "text/plain", + "X-Position" => "foo", + "X-PathInfo" => env["PATH_INFO"], + "X-ScriptName" => env["SCRIPT_NAME"] + }, [""]]} + ) + + res = Rack::MockRequest.new(map).get("/http://example.org/bar") + res.should.be.ok + res["X-Position"].should.equal "root" + res["X-PathInfo"].should.equal "/http://example.org/bar" res["X-ScriptName"].should.equal "" end end