PATH:
opt
/
alt
/
ruby19
/
lib64
/
ruby
/
gems
/
1.9.1
/
gems
/
rack-1.6.4
/
test
require 'rack/urlmap' require 'rack/mock' describe Rack::URLMap do it "dispatches paths correctly" do app = lambda { |env| [200, { 'X-ScriptName' => env['SCRIPT_NAME'], 'X-PathInfo' => env['PATH_INFO'], 'Content-Type' => 'text/plain' }, [""]] } map = Rack::Lint.new(Rack::URLMap.new({ 'http://foo.org/bar' => app, '/foo' => app, '/foo/bar' => app })) res = Rack::MockRequest.new(map).get("/") res.should.be.not_found res = Rack::MockRequest.new(map).get("/qux") res.should.be.not_found res = Rack::MockRequest.new(map).get("/foo") res.should.be.ok res["X-ScriptName"].should.equal "/foo" res["X-PathInfo"].should.equal "" res = Rack::MockRequest.new(map).get("/foo/") res.should.be.ok res["X-ScriptName"].should.equal "/foo" res["X-PathInfo"].should.equal "/" 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/") 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" res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org') res.should.be.ok res["X-ScriptName"].should.equal "/bar" res["X-PathInfo"].should.be.empty res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org') res.should.be.ok res["X-ScriptName"].should.equal "/bar" res["X-PathInfo"].should.equal '/' end it "dispatches hosts correctly" do map = Rack::Lint.new(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"], }, [""]]}, "http://subdomain.foo.org/" => lambda { |env| [200, { "Content-Type" => "text/plain", "X-Position" => "subdomain.foo.org", "X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"], }, [""]]}, "http://bar.org/" => lambda { |env| [200, { "Content-Type" => "text/plain", "X-Position" => "bar.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("/") res.should.be.ok res["X-Position"].should.equal "default.org" res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org") res.should.be.ok res["X-Position"].should.equal "bar.org" res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org") res.should.be.ok res["X-Position"].should.equal "foo.org" res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "subdomain.foo.org", "SERVER_NAME" => "foo.org") res.should.be.ok res["X-Position"].should.equal "subdomain.foo.org" res = Rack::MockRequest.new(map).get("http://foo.org/") res.should.be.ok res["X-Position"].should.equal "foo.org" res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org") res.should.be.ok res["X-Position"].should.equal "default.org" res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org:9292", "SERVER_PORT" => "9292") res.should.be.ok res["X-Position"].should.equal "default.org" end should "be nestable" do map = Rack::Lint.new(Rack::URLMap.new("/foo" => Rack::URLMap.new("/bar" => Rack::URLMap.new("/quux" => lambda { |env| [200, { "Content-Type" => "text/plain", "X-Position" => "/foo/bar/quux", "X-PathInfo" => env["PATH_INFO"], "X-ScriptName" => env["SCRIPT_NAME"], }, [""]]} )))) res = Rack::MockRequest.new(map).get("/foo/bar") res.should.be.not_found res = Rack::MockRequest.new(map).get("/foo/bar/quux") res.should.be.ok res["X-Position"].should.equal "/foo/bar/quux" res["X-PathInfo"].should.equal "" res["X-ScriptName"].should.equal "/foo/bar/quux" end should "route root apps correctly" do map = Rack::Lint.new(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("/foo/bar") res.should.be.ok res["X-Position"].should.equal "foo" res["X-PathInfo"].should.equal "/bar" res["X-ScriptName"].should.equal "/foo" res = Rack::MockRequest.new(map).get("/foo") res.should.be.ok res["X-Position"].should.equal "foo" res["X-PathInfo"].should.equal "" res["X-ScriptName"].should.equal "/foo" res = Rack::MockRequest.new(map).get("/bar") res.should.be.ok res["X-Position"].should.equal "root" res["X-PathInfo"].should.equal "/bar" res["X-ScriptName"].should.equal "" 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 should "not squeeze slashes" do map = Rack::Lint.new(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 should "not be case sensitive with hosts" do map = Rack::Lint.new(Rack::URLMap.new("http://example.org/" => lambda { |env| [200, { "Content-Type" => "text/plain", "X-Position" => "root", "X-PathInfo" => env["PATH_INFO"], "X-ScriptName" => env["SCRIPT_NAME"] }, [""]]} )) res = Rack::MockRequest.new(map).get("http://example.org/") res.should.be.ok res["X-Position"].should.equal "root" res["X-PathInfo"].should.equal "/" res["X-ScriptName"].should.equal "" res = Rack::MockRequest.new(map).get("http://EXAMPLE.ORG/") res.should.be.ok res["X-Position"].should.equal "root" res["X-PathInfo"].should.equal "/" res["X-ScriptName"].should.equal "" end end
[-] spec_fastcgi.rb
[edit]
[-] spec_session_pool.rb
[edit]
[-] spec_auth_basic.rb
[edit]
[-] spec_head.rb
[edit]
[-] spec_multipart.rb
[edit]
[-] spec_builder.rb
[edit]
[-] spec_config.rb
[edit]
[-] spec_recursive.rb
[edit]
[-] spec_runtime.rb
[edit]
[-] spec_server.rb
[edit]
[+]
multipart
[-] spec_commonlogger.rb
[edit]
[-] spec_nulllogger.rb
[edit]
[-] spec_file.rb
[edit]
[-] spec_rewindable_input.rb
[edit]
[+]
registering_handler
[-] spec_sendfile.rb
[edit]
[+]
unregistered_handler
[-] spec_mock.rb
[edit]
[+]
static
[-] spec_tempfile_reaper.rb
[edit]
[-] spec_content_type.rb
[edit]
[-] spec_urlmap.rb
[edit]
[-] spec_lint.rb
[edit]
[-] spec_methodoverride.rb
[edit]
[-] spec_session_memcache.rb
[edit]
[-] spec_utils.rb
[edit]
[-] spec_content_length.rb
[edit]
[-] spec_cgi.rb
[edit]
[-] spec_auth_digest.rb
[edit]
[-] spec_thin.rb
[edit]
[-] spec_showstatus.rb
[edit]
[-] spec_lock.rb
[edit]
[-] spec_mongrel.rb
[edit]
[-] spec_etag.rb
[edit]
[-] spec_chunked.rb
[edit]
[+]
..
[-] spec_request.rb
[edit]
[-] spec_body_proxy.rb
[edit]
[-] spec_static.rb
[edit]
[-] spec_cascade.rb
[edit]
[-] spec_showexceptions.rb
[edit]
[-] spec_session_abstract_id.rb
[edit]
[-] spec_directory.rb
[edit]
[+]
rackup
[-] spec_handler.rb
[edit]
[-] spec_version.rb
[edit]
[-] testrequest.rb
[edit]
[-] spec_conditionalget.rb
[edit]
[-] spec_logger.rb
[edit]
[-] spec_mime.rb
[edit]
[-] spec_response.rb
[edit]
[-] spec_webrick.rb
[edit]
[+]
cgi
[-] gemloader.rb
[edit]
[-] spec_deflater.rb
[edit]
[-] spec_session_cookie.rb
[edit]
[-] spec_lobster.rb
[edit]
[+]
builder