sinatra 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- data/CHANGELOG +1 -0
- data/LICENSE +22 -0
- data/Manifest +78 -1
- data/lib/sinatra.rb +12 -1
- data/sinatra.gemspec +7 -14
- data/vendor/rack/AUTHORS +7 -0
- data/vendor/rack/COPYING +18 -0
- data/vendor/rack/KNOWN-ISSUES +18 -0
- data/vendor/rack/README +242 -0
- data/vendor/rack/Rakefile +174 -0
- data/vendor/rack/bin/rackup +153 -0
- data/vendor/rack/contrib/rack_logo.svg +111 -0
- data/vendor/rack/example/lobster.ru +4 -0
- data/vendor/rack/example/protectedlobster.rb +14 -0
- data/vendor/rack/example/protectedlobster.ru +8 -0
- data/vendor/rack/lib/rack.rb +92 -0
- data/vendor/rack/lib/rack/adapter/camping.rb +22 -0
- data/vendor/rack/lib/rack/auth/abstract/handler.rb +28 -0
- data/vendor/rack/lib/rack/auth/abstract/request.rb +37 -0
- data/vendor/rack/lib/rack/auth/basic.rb +58 -0
- data/vendor/rack/lib/rack/auth/digest/md5.rb +124 -0
- data/vendor/rack/lib/rack/auth/digest/nonce.rb +51 -0
- data/vendor/rack/lib/rack/auth/digest/params.rb +55 -0
- data/vendor/rack/lib/rack/auth/digest/request.rb +40 -0
- data/vendor/rack/lib/rack/auth/openid.rb +116 -0
- data/vendor/rack/lib/rack/builder.rb +56 -0
- data/vendor/rack/lib/rack/cascade.rb +36 -0
- data/vendor/rack/lib/rack/commonlogger.rb +56 -0
- data/vendor/rack/lib/rack/file.rb +112 -0
- data/vendor/rack/lib/rack/handler/cgi.rb +57 -0
- data/vendor/rack/lib/rack/handler/fastcgi.rb +83 -0
- data/vendor/rack/lib/rack/handler/lsws.rb +52 -0
- data/vendor/rack/lib/rack/handler/mongrel.rb +78 -0
- data/vendor/rack/lib/rack/handler/scgi.rb +57 -0
- data/vendor/rack/lib/rack/handler/webrick.rb +57 -0
- data/vendor/rack/lib/rack/lint.rb +394 -0
- data/vendor/rack/lib/rack/lobster.rb +65 -0
- data/vendor/rack/lib/rack/mock.rb +160 -0
- data/vendor/rack/lib/rack/recursive.rb +57 -0
- data/vendor/rack/lib/rack/reloader.rb +64 -0
- data/vendor/rack/lib/rack/request.rb +197 -0
- data/vendor/rack/lib/rack/response.rb +166 -0
- data/vendor/rack/lib/rack/session/abstract/id.rb +126 -0
- data/vendor/rack/lib/rack/session/cookie.rb +71 -0
- data/vendor/rack/lib/rack/session/memcache.rb +83 -0
- data/vendor/rack/lib/rack/session/pool.rb +67 -0
- data/vendor/rack/lib/rack/showexceptions.rb +344 -0
- data/vendor/rack/lib/rack/showstatus.rb +103 -0
- data/vendor/rack/lib/rack/static.rb +38 -0
- data/vendor/rack/lib/rack/urlmap.rb +48 -0
- data/vendor/rack/lib/rack/utils.rb +240 -0
- data/vendor/rack/test/cgi/lighttpd.conf +20 -0
- data/vendor/rack/test/cgi/test +9 -0
- data/vendor/rack/test/cgi/test.fcgi +7 -0
- data/vendor/rack/test/cgi/test.ru +7 -0
- data/vendor/rack/test/spec_rack_auth_basic.rb +69 -0
- data/vendor/rack/test/spec_rack_auth_digest.rb +169 -0
- data/vendor/rack/test/spec_rack_builder.rb +50 -0
- data/vendor/rack/test/spec_rack_camping.rb +47 -0
- data/vendor/rack/test/spec_rack_cascade.rb +50 -0
- data/vendor/rack/test/spec_rack_cgi.rb +91 -0
- data/vendor/rack/test/spec_rack_commonlogger.rb +32 -0
- data/vendor/rack/test/spec_rack_fastcgi.rb +91 -0
- data/vendor/rack/test/spec_rack_file.rb +40 -0
- data/vendor/rack/test/spec_rack_lint.rb +317 -0
- data/vendor/rack/test/spec_rack_lobster.rb +45 -0
- data/vendor/rack/test/spec_rack_mock.rb +152 -0
- data/vendor/rack/test/spec_rack_mongrel.rb +165 -0
- data/vendor/rack/test/spec_rack_recursive.rb +77 -0
- data/vendor/rack/test/spec_rack_request.rb +384 -0
- data/vendor/rack/test/spec_rack_response.rb +167 -0
- data/vendor/rack/test/spec_rack_session_cookie.rb +49 -0
- data/vendor/rack/test/spec_rack_session_memcache.rb +100 -0
- data/vendor/rack/test/spec_rack_session_pool.rb +84 -0
- data/vendor/rack/test/spec_rack_showexceptions.rb +21 -0
- data/vendor/rack/test/spec_rack_showstatus.rb +71 -0
- data/vendor/rack/test/spec_rack_static.rb +37 -0
- data/vendor/rack/test/spec_rack_urlmap.rb +175 -0
- data/vendor/rack/test/spec_rack_utils.rb +57 -0
- data/vendor/rack/test/spec_rack_webrick.rb +106 -0
- data/vendor/rack/test/testrequest.rb +43 -0
- metadata +81 -4
- data/Rakefile +0 -24
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
3
|
+
require 'rack/static'
|
4
|
+
require 'rack/mock'
|
5
|
+
|
6
|
+
class DummyApp
|
7
|
+
def call(env)
|
8
|
+
[200, {}, "Hello World"]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "Rack::Static" do
|
13
|
+
root = File.expand_path(File.dirname(__FILE__))
|
14
|
+
OPTIONS = {:urls => ["/cgi"], :root => root}
|
15
|
+
|
16
|
+
setup do
|
17
|
+
@request = Rack::MockRequest.new(Rack::Static.new(DummyApp.new, OPTIONS))
|
18
|
+
end
|
19
|
+
|
20
|
+
specify "serves files" do
|
21
|
+
res = @request.get("/cgi/test")
|
22
|
+
res.should.be.ok
|
23
|
+
res.body.should =~ /ruby/
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "404s if url root is known but it can't find the file" do
|
27
|
+
res = @request.get("/cgi/foo")
|
28
|
+
res.should.be.not_found
|
29
|
+
end
|
30
|
+
|
31
|
+
specify "calls down the chain if url root is not known" do
|
32
|
+
res = @request.get("/something/else")
|
33
|
+
res.should.be.ok
|
34
|
+
res.body.should == "Hello World"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
3
|
+
require 'rack/urlmap'
|
4
|
+
require 'rack/mock'
|
5
|
+
|
6
|
+
context "Rack::URLMap" do
|
7
|
+
specify "dispatches paths correctly" do
|
8
|
+
app = lambda { |env|
|
9
|
+
[200, {
|
10
|
+
'X-ScriptName' => env['SCRIPT_NAME'],
|
11
|
+
'X-PathInfo' => env['PATH_INFO'],
|
12
|
+
'Content-Type' => 'text/plain'
|
13
|
+
}, [""]]
|
14
|
+
}
|
15
|
+
map = Rack::URLMap.new({
|
16
|
+
'http://foo.org/bar' => app,
|
17
|
+
'/foo' => app,
|
18
|
+
'/foo/bar' => app
|
19
|
+
})
|
20
|
+
|
21
|
+
res = Rack::MockRequest.new(map).get("/")
|
22
|
+
res.should.be.not_found
|
23
|
+
|
24
|
+
res = Rack::MockRequest.new(map).get("/qux")
|
25
|
+
res.should.be.not_found
|
26
|
+
|
27
|
+
res = Rack::MockRequest.new(map).get("/foo")
|
28
|
+
res.should.be.ok
|
29
|
+
res["X-ScriptName"].should.equal "/foo"
|
30
|
+
res["X-PathInfo"].should.equal ""
|
31
|
+
|
32
|
+
res = Rack::MockRequest.new(map).get("/foo/")
|
33
|
+
res.should.be.ok
|
34
|
+
res["X-ScriptName"].should.equal "/foo"
|
35
|
+
res["X-PathInfo"].should.equal "/"
|
36
|
+
|
37
|
+
res = Rack::MockRequest.new(map).get("/foo/bar")
|
38
|
+
res.should.be.ok
|
39
|
+
res["X-ScriptName"].should.equal "/foo/bar"
|
40
|
+
res["X-PathInfo"].should.equal ""
|
41
|
+
|
42
|
+
res = Rack::MockRequest.new(map).get("/foo/bar/")
|
43
|
+
res.should.be.ok
|
44
|
+
res["X-ScriptName"].should.equal "/foo/bar"
|
45
|
+
res["X-PathInfo"].should.equal "/"
|
46
|
+
|
47
|
+
res = Rack::MockRequest.new(map).get("/foo/quux", "SCRIPT_NAME" => "/bleh")
|
48
|
+
res.should.be.ok
|
49
|
+
res["X-ScriptName"].should.equal "/bleh/foo"
|
50
|
+
res["X-PathInfo"].should.equal "/quux"
|
51
|
+
|
52
|
+
res = Rack::MockRequest.new(map).get("/bar", 'HTTP_HOST' => 'foo.org')
|
53
|
+
res.should.be.ok
|
54
|
+
res["X-ScriptName"].should.equal "/bar"
|
55
|
+
res["X-PathInfo"].should.be.empty
|
56
|
+
|
57
|
+
res = Rack::MockRequest.new(map).get("/bar/", 'HTTP_HOST' => 'foo.org')
|
58
|
+
res.should.be.ok
|
59
|
+
res["X-ScriptName"].should.equal "/bar"
|
60
|
+
res["X-PathInfo"].should.equal '/'
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
specify "dispatches hosts correctly" do
|
65
|
+
map = Rack::URLMap.new("http://foo.org/" => lambda { |env|
|
66
|
+
[200,
|
67
|
+
{ "Content-Type" => "text/plain",
|
68
|
+
"X-Position" => "foo.org",
|
69
|
+
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
70
|
+
}, [""]]},
|
71
|
+
"http://bar.org/" => lambda { |env|
|
72
|
+
[200,
|
73
|
+
{ "Content-Type" => "text/plain",
|
74
|
+
"X-Position" => "bar.org",
|
75
|
+
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
76
|
+
}, [""]]},
|
77
|
+
"/" => lambda { |env|
|
78
|
+
[200,
|
79
|
+
{ "Content-Type" => "text/plain",
|
80
|
+
"X-Position" => "default.org",
|
81
|
+
"X-Host" => env["HTTP_HOST"] || env["SERVER_NAME"],
|
82
|
+
}, [""]]}
|
83
|
+
)
|
84
|
+
|
85
|
+
res = Rack::MockRequest.new(map).get("/")
|
86
|
+
res.should.be.ok
|
87
|
+
res["X-Position"].should.equal "default.org"
|
88
|
+
|
89
|
+
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "bar.org")
|
90
|
+
res.should.be.ok
|
91
|
+
res["X-Position"].should.equal "bar.org"
|
92
|
+
|
93
|
+
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "foo.org")
|
94
|
+
res.should.be.ok
|
95
|
+
res["X-Position"].should.equal "foo.org"
|
96
|
+
|
97
|
+
res = Rack::MockRequest.new(map).get("http://foo.org/")
|
98
|
+
res.should.be.ok
|
99
|
+
res["X-Position"].should.equal "default.org"
|
100
|
+
|
101
|
+
res = Rack::MockRequest.new(map).get("/", "HTTP_HOST" => "example.org")
|
102
|
+
res.should.be.ok
|
103
|
+
res["X-Position"].should.equal "default.org"
|
104
|
+
|
105
|
+
res = Rack::MockRequest.new(map).get("/",
|
106
|
+
"HTTP_HOST" => "example.org:9292",
|
107
|
+
"SERVER_PORT" => "9292")
|
108
|
+
res.should.be.ok
|
109
|
+
res["X-Position"].should.equal "default.org"
|
110
|
+
end
|
111
|
+
|
112
|
+
specify "should be nestable" do
|
113
|
+
map = Rack::URLMap.new("/foo" =>
|
114
|
+
Rack::URLMap.new("/bar" =>
|
115
|
+
Rack::URLMap.new("/quux" => lambda { |env|
|
116
|
+
[200,
|
117
|
+
{ "Content-Type" => "text/plain",
|
118
|
+
"X-Position" => "/foo/bar/quux",
|
119
|
+
"X-PathInfo" => env["PATH_INFO"],
|
120
|
+
"X-ScriptName" => env["SCRIPT_NAME"],
|
121
|
+
}, [""]]}
|
122
|
+
)))
|
123
|
+
|
124
|
+
res = Rack::MockRequest.new(map).get("/foo/bar")
|
125
|
+
res.should.be.not_found
|
126
|
+
|
127
|
+
res = Rack::MockRequest.new(map).get("/foo/bar/quux")
|
128
|
+
res.should.be.ok
|
129
|
+
res["X-Position"].should.equal "/foo/bar/quux"
|
130
|
+
res["X-PathInfo"].should.equal ""
|
131
|
+
res["X-ScriptName"].should.equal "/foo/bar/quux"
|
132
|
+
end
|
133
|
+
|
134
|
+
specify "should route root apps correctly" do
|
135
|
+
map = Rack::URLMap.new("/" => lambda { |env|
|
136
|
+
[200,
|
137
|
+
{ "Content-Type" => "text/plain",
|
138
|
+
"X-Position" => "root",
|
139
|
+
"X-PathInfo" => env["PATH_INFO"],
|
140
|
+
"X-ScriptName" => env["SCRIPT_NAME"]
|
141
|
+
}, [""]]},
|
142
|
+
"/foo" => lambda { |env|
|
143
|
+
[200,
|
144
|
+
{ "Content-Type" => "text/plain",
|
145
|
+
"X-Position" => "foo",
|
146
|
+
"X-PathInfo" => env["PATH_INFO"],
|
147
|
+
"X-ScriptName" => env["SCRIPT_NAME"]
|
148
|
+
}, [""]]}
|
149
|
+
)
|
150
|
+
|
151
|
+
res = Rack::MockRequest.new(map).get("/foo/bar")
|
152
|
+
res.should.be.ok
|
153
|
+
res["X-Position"].should.equal "foo"
|
154
|
+
res["X-PathInfo"].should.equal "/bar"
|
155
|
+
res["X-ScriptName"].should.equal "/foo"
|
156
|
+
|
157
|
+
res = Rack::MockRequest.new(map).get("/foo")
|
158
|
+
res.should.be.ok
|
159
|
+
res["X-Position"].should.equal "foo"
|
160
|
+
res["X-PathInfo"].should.equal ""
|
161
|
+
res["X-ScriptName"].should.equal "/foo"
|
162
|
+
|
163
|
+
res = Rack::MockRequest.new(map).get("/bar")
|
164
|
+
res.should.be.ok
|
165
|
+
res["X-Position"].should.equal "root"
|
166
|
+
res["X-PathInfo"].should.equal "/bar"
|
167
|
+
res["X-ScriptName"].should.equal ""
|
168
|
+
|
169
|
+
res = Rack::MockRequest.new(map).get("")
|
170
|
+
res.should.be.ok
|
171
|
+
res["X-Position"].should.equal "root"
|
172
|
+
res["X-PathInfo"].should.equal "/"
|
173
|
+
res["X-ScriptName"].should.equal ""
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rack/utils'
|
2
|
+
|
3
|
+
context "Rack::Utils" do
|
4
|
+
specify "should escape correctly" do
|
5
|
+
Rack::Utils.escape("fo<o>bar").should.equal "fo%3Co%3Ebar"
|
6
|
+
Rack::Utils.escape("a space").should.equal "a+space"
|
7
|
+
Rack::Utils.escape("q1!2\"'w$5&7/z8)?\\").
|
8
|
+
should.equal "q1%212%22%27w%245%267%2Fz8%29%3F%5C"
|
9
|
+
end
|
10
|
+
|
11
|
+
specify "should unescape correctly" do
|
12
|
+
Rack::Utils.unescape("fo%3Co%3Ebar").should.equal "fo<o>bar"
|
13
|
+
Rack::Utils.unescape("a+space").should.equal "a space"
|
14
|
+
Rack::Utils.unescape("a%20space").should.equal "a space"
|
15
|
+
Rack::Utils.unescape("q1%212%22%27w%245%267%2Fz8%29%3F%5C").
|
16
|
+
should.equal "q1!2\"'w$5&7/z8)?\\"
|
17
|
+
end
|
18
|
+
|
19
|
+
specify "should parse queries correctly" do
|
20
|
+
Rack::Utils.parse_query("foo=bar").should.equal "foo" => "bar"
|
21
|
+
Rack::Utils.parse_query("foo=bar&foo=quux").
|
22
|
+
should.equal "foo" => ["bar", "quux"]
|
23
|
+
Rack::Utils.parse_query("my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F").
|
24
|
+
should.equal "my weird field" => "q1!2\"'w$5&7/z8)?"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "Rack::Utils::HeaderHash" do
|
29
|
+
specify "should capitalize on all accesses" do
|
30
|
+
h = Rack::Utils::HeaderHash.new("foo" => "bar")
|
31
|
+
h["foo"].should.equal "bar"
|
32
|
+
h["Foo"].should.equal "bar"
|
33
|
+
h["FOO"].should.equal "bar"
|
34
|
+
|
35
|
+
h.to_hash.should.equal "Foo" => "bar"
|
36
|
+
|
37
|
+
h["bar-zzle"] = "quux"
|
38
|
+
|
39
|
+
h.to_hash.should.equal "Foo" => "bar", "Bar-Zzle" => "quux"
|
40
|
+
end
|
41
|
+
|
42
|
+
specify "should capitalize correctly" do
|
43
|
+
h = Rack::Utils::HeaderHash.new
|
44
|
+
|
45
|
+
h.capitalize("foo").should.equal "Foo"
|
46
|
+
h.capitalize("foo-bar").should.equal "Foo-Bar"
|
47
|
+
h.capitalize("foo_bar").should.equal "Foo_Bar"
|
48
|
+
h.capitalize("foo bar").should.equal "Foo Bar"
|
49
|
+
h.capitalize("foo-bar-quux").should.equal "Foo-Bar-Quux"
|
50
|
+
h.capitalize("foo-bar-2quux").should.equal "Foo-Bar-2quux"
|
51
|
+
end
|
52
|
+
|
53
|
+
specify "should be converted to real Hash" do
|
54
|
+
h = Rack::Utils::HeaderHash.new("foo" => "bar")
|
55
|
+
h.to_hash.should.be.instance_of Hash
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'test/spec'
|
2
|
+
|
3
|
+
require 'rack/handler/webrick'
|
4
|
+
require 'rack/lint'
|
5
|
+
require 'testrequest'
|
6
|
+
|
7
|
+
Thread.abort_on_exception = true
|
8
|
+
|
9
|
+
context "Rack::Handler::WEBrick" do
|
10
|
+
include TestRequest::Helpers
|
11
|
+
|
12
|
+
setup do
|
13
|
+
@server = WEBrick::HTTPServer.new(:Host => @host='0.0.0.0',
|
14
|
+
:Port => @port=9202,
|
15
|
+
:Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN),
|
16
|
+
:AccessLog => [])
|
17
|
+
@server.mount "/test", Rack::Handler::WEBrick,
|
18
|
+
Rack::Lint.new(TestRequest.new)
|
19
|
+
Thread.new { @server.start }
|
20
|
+
trap(:INT) { @server.shutdown }
|
21
|
+
end
|
22
|
+
|
23
|
+
specify "should respond" do
|
24
|
+
lambda {
|
25
|
+
GET("/test")
|
26
|
+
}.should.not.raise
|
27
|
+
end
|
28
|
+
|
29
|
+
specify "should be a WEBrick" do
|
30
|
+
GET("/test")
|
31
|
+
status.should.be 200
|
32
|
+
response["SERVER_SOFTWARE"].should =~ /WEBrick/
|
33
|
+
response["HTTP_VERSION"].should.equal "HTTP/1.1"
|
34
|
+
response["SERVER_PROTOCOL"].should.equal "HTTP/1.1"
|
35
|
+
response["SERVER_PORT"].should.equal "9202"
|
36
|
+
response["SERVER_NAME"].should.equal "0.0.0.0"
|
37
|
+
end
|
38
|
+
|
39
|
+
specify "should have rack headers" do
|
40
|
+
GET("/test")
|
41
|
+
response["rack.version"].should.equal [0,1]
|
42
|
+
response["rack.multithread"].should.be true
|
43
|
+
response["rack.multiprocess"].should.be false
|
44
|
+
response["rack.run_once"].should.be false
|
45
|
+
end
|
46
|
+
|
47
|
+
specify "should have CGI headers on GET" do
|
48
|
+
GET("/test")
|
49
|
+
response["REQUEST_METHOD"].should.equal "GET"
|
50
|
+
response["SCRIPT_NAME"].should.equal "/test"
|
51
|
+
response["REQUEST_PATH"].should.equal "/"
|
52
|
+
response["PATH_INFO"].should.be.nil
|
53
|
+
response["QUERY_STRING"].should.equal ""
|
54
|
+
response["test.postdata"].should.equal ""
|
55
|
+
|
56
|
+
GET("/test/foo?quux=1")
|
57
|
+
response["REQUEST_METHOD"].should.equal "GET"
|
58
|
+
response["SCRIPT_NAME"].should.equal "/test"
|
59
|
+
response["REQUEST_PATH"].should.equal "/"
|
60
|
+
response["PATH_INFO"].should.equal "/foo"
|
61
|
+
response["QUERY_STRING"].should.equal "quux=1"
|
62
|
+
end
|
63
|
+
|
64
|
+
specify "should have CGI headers on POST" do
|
65
|
+
POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'})
|
66
|
+
status.should.equal 200
|
67
|
+
response["REQUEST_METHOD"].should.equal "POST"
|
68
|
+
response["SCRIPT_NAME"].should.equal "/test"
|
69
|
+
response["REQUEST_PATH"].should.equal "/"
|
70
|
+
response["QUERY_STRING"].should.equal ""
|
71
|
+
response["HTTP_X_TEST_HEADER"].should.equal "42"
|
72
|
+
response["test.postdata"].should.equal "rack-form-data=23"
|
73
|
+
end
|
74
|
+
|
75
|
+
specify "should support HTTP auth" do
|
76
|
+
GET("/test", {:user => "ruth", :passwd => "secret"})
|
77
|
+
response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ="
|
78
|
+
end
|
79
|
+
|
80
|
+
specify "should set status" do
|
81
|
+
GET("/test?secret")
|
82
|
+
status.should.equal 403
|
83
|
+
response["rack.url_scheme"].should.equal "http"
|
84
|
+
end
|
85
|
+
|
86
|
+
specify "should provide a .run" do
|
87
|
+
block_ran = false
|
88
|
+
catch(:done) {
|
89
|
+
Rack::Handler::WEBrick.run(lambda {},
|
90
|
+
{:Port => 9210,
|
91
|
+
:Logger => WEBrick::Log.new(nil, WEBrick::BasicLog::WARN),
|
92
|
+
:AccessLog => []}) { |server|
|
93
|
+
block_ran = true
|
94
|
+
server.should.be.kind_of WEBrick::HTTPServer
|
95
|
+
@s = server
|
96
|
+
throw :done
|
97
|
+
}
|
98
|
+
}
|
99
|
+
block_ran.should.be true
|
100
|
+
@s.shutdown
|
101
|
+
end
|
102
|
+
|
103
|
+
teardown do
|
104
|
+
@server.shutdown
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
class TestRequest
|
5
|
+
def call(env)
|
6
|
+
status = env["QUERY_STRING"] =~ /secret/ ? 403 : 200
|
7
|
+
env["test.postdata"] = env["rack.input"].read
|
8
|
+
[status, {"Content-Type" => "text/yaml"}, [env.to_yaml]]
|
9
|
+
end
|
10
|
+
|
11
|
+
module Helpers
|
12
|
+
attr_reader :status, :response
|
13
|
+
|
14
|
+
def GET(path, header={})
|
15
|
+
Net::HTTP.start(@host, @port) { |http|
|
16
|
+
user = header.delete(:user)
|
17
|
+
passwd = header.delete(:passwd)
|
18
|
+
|
19
|
+
get = Net::HTTP::Get.new(path, header)
|
20
|
+
get.basic_auth user, passwd if user && passwd
|
21
|
+
http.request(get) { |response|
|
22
|
+
@status = response.code.to_i
|
23
|
+
@response = YAML.load(response.body)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def POST(path, formdata={}, header={})
|
29
|
+
Net::HTTP.start(@host, @port) { |http|
|
30
|
+
user = header.delete(:user)
|
31
|
+
passwd = header.delete(:passwd)
|
32
|
+
|
33
|
+
post = Net::HTTP::Post.new(path, header)
|
34
|
+
post.form_data = formdata
|
35
|
+
post.basic_auth user, passwd if user && passwd
|
36
|
+
http.request(post) { |response|
|
37
|
+
@status = response.code.to_i
|
38
|
+
@response = YAML.load(response.body)
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -33,6 +33,7 @@ extra_rdoc_files:
|
|
33
33
|
- lib/sinatra/test/spec.rb
|
34
34
|
- lib/sinatra/test/unit.rb
|
35
35
|
- lib/sinatra.rb
|
36
|
+
- LICENSE
|
36
37
|
- README.rdoc
|
37
38
|
files:
|
38
39
|
- CHANGELOG
|
@@ -43,6 +44,8 @@ files:
|
|
43
44
|
- lib/sinatra/test/spec.rb
|
44
45
|
- lib/sinatra/test/unit.rb
|
45
46
|
- lib/sinatra.rb
|
47
|
+
- LICENSE
|
48
|
+
- Manifest
|
46
49
|
- README.rdoc
|
47
50
|
- test/app_test.rb
|
48
51
|
- test/application_test.rb
|
@@ -79,12 +82,86 @@ files:
|
|
79
82
|
- test/views/layout_test/layout.sass
|
80
83
|
- test/views/no_layout/no_layout.builder
|
81
84
|
- test/views/no_layout/no_layout.haml
|
82
|
-
-
|
85
|
+
- vendor/rack/AUTHORS
|
86
|
+
- vendor/rack/bin/rackup
|
87
|
+
- vendor/rack/contrib/rack_logo.svg
|
88
|
+
- vendor/rack/COPYING
|
89
|
+
- vendor/rack/example/lobster.ru
|
90
|
+
- vendor/rack/example/protectedlobster.rb
|
91
|
+
- vendor/rack/example/protectedlobster.ru
|
92
|
+
- vendor/rack/KNOWN-ISSUES
|
93
|
+
- vendor/rack/lib/rack/adapter/camping.rb
|
94
|
+
- vendor/rack/lib/rack/auth/abstract/handler.rb
|
95
|
+
- vendor/rack/lib/rack/auth/abstract/request.rb
|
96
|
+
- vendor/rack/lib/rack/auth/basic.rb
|
97
|
+
- vendor/rack/lib/rack/auth/digest/md5.rb
|
98
|
+
- vendor/rack/lib/rack/auth/digest/nonce.rb
|
99
|
+
- vendor/rack/lib/rack/auth/digest/params.rb
|
100
|
+
- vendor/rack/lib/rack/auth/digest/request.rb
|
101
|
+
- vendor/rack/lib/rack/auth/openid.rb
|
102
|
+
- vendor/rack/lib/rack/builder.rb
|
103
|
+
- vendor/rack/lib/rack/cascade.rb
|
104
|
+
- vendor/rack/lib/rack/commonlogger.rb
|
105
|
+
- vendor/rack/lib/rack/file.rb
|
106
|
+
- vendor/rack/lib/rack/handler/cgi.rb
|
107
|
+
- vendor/rack/lib/rack/handler/fastcgi.rb
|
108
|
+
- vendor/rack/lib/rack/handler/lsws.rb
|
109
|
+
- vendor/rack/lib/rack/handler/mongrel.rb
|
110
|
+
- vendor/rack/lib/rack/handler/scgi.rb
|
111
|
+
- vendor/rack/lib/rack/handler/webrick.rb
|
112
|
+
- vendor/rack/lib/rack/lint.rb
|
113
|
+
- vendor/rack/lib/rack/lobster.rb
|
114
|
+
- vendor/rack/lib/rack/mock.rb
|
115
|
+
- vendor/rack/lib/rack/recursive.rb
|
116
|
+
- vendor/rack/lib/rack/reloader.rb
|
117
|
+
- vendor/rack/lib/rack/request.rb
|
118
|
+
- vendor/rack/lib/rack/response.rb
|
119
|
+
- vendor/rack/lib/rack/session/abstract/id.rb
|
120
|
+
- vendor/rack/lib/rack/session/cookie.rb
|
121
|
+
- vendor/rack/lib/rack/session/memcache.rb
|
122
|
+
- vendor/rack/lib/rack/session/pool.rb
|
123
|
+
- vendor/rack/lib/rack/showexceptions.rb
|
124
|
+
- vendor/rack/lib/rack/showstatus.rb
|
125
|
+
- vendor/rack/lib/rack/static.rb
|
126
|
+
- vendor/rack/lib/rack/urlmap.rb
|
127
|
+
- vendor/rack/lib/rack/utils.rb
|
128
|
+
- vendor/rack/lib/rack.rb
|
129
|
+
- vendor/rack/Rakefile
|
130
|
+
- vendor/rack/README
|
131
|
+
- vendor/rack/test/cgi/lighttpd.conf
|
132
|
+
- vendor/rack/test/cgi/test
|
133
|
+
- vendor/rack/test/cgi/test.fcgi
|
134
|
+
- vendor/rack/test/cgi/test.ru
|
135
|
+
- vendor/rack/test/spec_rack_auth_basic.rb
|
136
|
+
- vendor/rack/test/spec_rack_auth_digest.rb
|
137
|
+
- vendor/rack/test/spec_rack_builder.rb
|
138
|
+
- vendor/rack/test/spec_rack_camping.rb
|
139
|
+
- vendor/rack/test/spec_rack_cascade.rb
|
140
|
+
- vendor/rack/test/spec_rack_cgi.rb
|
141
|
+
- vendor/rack/test/spec_rack_commonlogger.rb
|
142
|
+
- vendor/rack/test/spec_rack_fastcgi.rb
|
143
|
+
- vendor/rack/test/spec_rack_file.rb
|
144
|
+
- vendor/rack/test/spec_rack_lint.rb
|
145
|
+
- vendor/rack/test/spec_rack_lobster.rb
|
146
|
+
- vendor/rack/test/spec_rack_mock.rb
|
147
|
+
- vendor/rack/test/spec_rack_mongrel.rb
|
148
|
+
- vendor/rack/test/spec_rack_recursive.rb
|
149
|
+
- vendor/rack/test/spec_rack_request.rb
|
150
|
+
- vendor/rack/test/spec_rack_response.rb
|
151
|
+
- vendor/rack/test/spec_rack_session_cookie.rb
|
152
|
+
- vendor/rack/test/spec_rack_session_memcache.rb
|
153
|
+
- vendor/rack/test/spec_rack_session_pool.rb
|
154
|
+
- vendor/rack/test/spec_rack_showexceptions.rb
|
155
|
+
- vendor/rack/test/spec_rack_showstatus.rb
|
156
|
+
- vendor/rack/test/spec_rack_static.rb
|
157
|
+
- vendor/rack/test/spec_rack_urlmap.rb
|
158
|
+
- vendor/rack/test/spec_rack_utils.rb
|
159
|
+
- vendor/rack/test/spec_rack_webrick.rb
|
160
|
+
- vendor/rack/test/testrequest.rb
|
83
161
|
- sinatra.gemspec
|
84
|
-
- Rakefile
|
85
162
|
has_rdoc: true
|
86
163
|
homepage: http://www.sinatrarb.com
|
87
|
-
post_install_message: "*** Be sure to checkout
|
164
|
+
post_install_message: "*** Be sure to checkout http://sinatrarb.com for helpful tips!***"
|
88
165
|
rdoc_options:
|
89
166
|
- --line-numbers
|
90
167
|
- --inline-source
|