rack 1.6.12 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (141) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +1 -1
  3. data/HISTORY.md +138 -8
  4. data/README.rdoc +18 -28
  5. data/Rakefile +6 -14
  6. data/SPEC +10 -11
  7. data/contrib/rack_logo.svg +164 -111
  8. data/example/protectedlobster.rb +1 -1
  9. data/example/protectedlobster.ru +1 -1
  10. data/lib/rack.rb +70 -21
  11. data/lib/rack/auth/abstract/request.rb +5 -1
  12. data/lib/rack/auth/digest/params.rb +2 -3
  13. data/lib/rack/auth/digest/request.rb +1 -1
  14. data/lib/rack/body_proxy.rb +14 -9
  15. data/lib/rack/builder.rb +3 -3
  16. data/lib/rack/chunked.rb +5 -5
  17. data/lib/rack/{commonlogger.rb → common_logger.rb} +3 -3
  18. data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
  19. data/lib/rack/content_length.rb +2 -2
  20. data/lib/rack/deflater.rb +4 -39
  21. data/lib/rack/directory.rb +66 -54
  22. data/lib/rack/etag.rb +5 -4
  23. data/lib/rack/events.rb +154 -0
  24. data/lib/rack/file.rb +64 -40
  25. data/lib/rack/handler.rb +3 -25
  26. data/lib/rack/handler/cgi.rb +15 -16
  27. data/lib/rack/handler/fastcgi.rb +13 -14
  28. data/lib/rack/handler/lsws.rb +11 -11
  29. data/lib/rack/handler/scgi.rb +15 -15
  30. data/lib/rack/handler/thin.rb +3 -0
  31. data/lib/rack/handler/webrick.rb +24 -26
  32. data/lib/rack/head.rb +15 -17
  33. data/lib/rack/lint.rb +40 -40
  34. data/lib/rack/lobster.rb +1 -1
  35. data/lib/rack/lock.rb +15 -10
  36. data/lib/rack/logger.rb +2 -2
  37. data/lib/rack/media_type.rb +38 -0
  38. data/lib/rack/{methodoverride.rb → method_override.rb} +6 -6
  39. data/lib/rack/mime.rb +18 -5
  40. data/lib/rack/mock.rb +36 -54
  41. data/lib/rack/multipart.rb +35 -6
  42. data/lib/rack/multipart/generator.rb +5 -5
  43. data/lib/rack/multipart/parser.rb +270 -157
  44. data/lib/rack/multipart/uploaded_file.rb +1 -2
  45. data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
  46. data/lib/rack/query_parser.rb +192 -0
  47. data/lib/rack/recursive.rb +8 -8
  48. data/lib/rack/request.rb +394 -305
  49. data/lib/rack/response.rb +130 -57
  50. data/lib/rack/rewindable_input.rb +1 -12
  51. data/lib/rack/runtime.rb +10 -18
  52. data/lib/rack/sendfile.rb +5 -7
  53. data/lib/rack/server.rb +30 -23
  54. data/lib/rack/session/abstract/id.rb +108 -138
  55. data/lib/rack/session/cookie.rb +26 -28
  56. data/lib/rack/session/memcache.rb +8 -14
  57. data/lib/rack/session/pool.rb +14 -21
  58. data/lib/rack/show_exceptions.rb +386 -0
  59. data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
  60. data/lib/rack/static.rb +30 -5
  61. data/lib/rack/tempfile_reaper.rb +2 -2
  62. data/lib/rack/urlmap.rb +15 -14
  63. data/lib/rack/utils.rb +136 -211
  64. data/rack.gemspec +10 -9
  65. data/test/builder/an_underscore_app.rb +5 -0
  66. data/test/builder/options.ru +1 -1
  67. data/test/cgi/test.fcgi +1 -0
  68. data/test/cgi/test.gz +0 -0
  69. data/test/helper.rb +34 -0
  70. data/test/multipart/filename_with_encoded_words +7 -0
  71. data/test/multipart/filename_with_single_quote +7 -0
  72. data/test/multipart/quoted +15 -0
  73. data/test/multipart/rack-logo.png +0 -0
  74. data/test/multipart/unity3d_wwwform +11 -0
  75. data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
  76. data/test/spec_auth_basic.rb +27 -19
  77. data/test/spec_auth_digest.rb +47 -46
  78. data/test/spec_body_proxy.rb +27 -27
  79. data/test/spec_builder.rb +51 -41
  80. data/test/spec_cascade.rb +24 -22
  81. data/test/spec_cgi.rb +49 -67
  82. data/test/spec_chunked.rb +37 -35
  83. data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
  84. data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
  85. data/test/spec_config.rb +3 -2
  86. data/test/spec_content_length.rb +18 -17
  87. data/test/spec_content_type.rb +13 -12
  88. data/test/spec_deflater.rb +85 -49
  89. data/test/spec_directory.rb +87 -27
  90. data/test/spec_etag.rb +32 -31
  91. data/test/spec_events.rb +133 -0
  92. data/test/spec_fastcgi.rb +50 -72
  93. data/test/spec_file.rb +120 -77
  94. data/test/spec_handler.rb +19 -34
  95. data/test/spec_head.rb +15 -14
  96. data/test/spec_lint.rb +164 -199
  97. data/test/spec_lobster.rb +24 -23
  98. data/test/spec_lock.rb +79 -39
  99. data/test/spec_logger.rb +4 -3
  100. data/test/spec_media_type.rb +42 -0
  101. data/test/{spec_methodoverride.rb → spec_method_override.rb} +34 -35
  102. data/test/spec_mime.rb +19 -19
  103. data/test/spec_mock.rb +206 -144
  104. data/test/spec_multipart.rb +322 -200
  105. data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
  106. data/test/spec_recursive.rb +17 -14
  107. data/test/spec_request.rb +780 -605
  108. data/test/spec_response.rb +215 -112
  109. data/test/spec_rewindable_input.rb +50 -40
  110. data/test/spec_runtime.rb +11 -10
  111. data/test/spec_sendfile.rb +30 -35
  112. data/test/spec_server.rb +78 -52
  113. data/test/spec_session_abstract_id.rb +11 -33
  114. data/test/spec_session_abstract_session_hash.rb +45 -0
  115. data/test/spec_session_cookie.rb +99 -67
  116. data/test/spec_session_memcache.rb +63 -101
  117. data/test/spec_session_pool.rb +48 -84
  118. data/test/{spec_showexceptions.rb → spec_show_exceptions.rb} +23 -28
  119. data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
  120. data/test/spec_static.rb +71 -32
  121. data/test/spec_tempfile_reaper.rb +11 -10
  122. data/test/spec_thin.rb +55 -50
  123. data/test/spec_urlmap.rb +79 -78
  124. data/test/spec_utils.rb +441 -346
  125. data/test/spec_version.rb +2 -8
  126. data/test/spec_webrick.rb +93 -71
  127. data/test/static/foo.html +1 -0
  128. data/test/testrequest.rb +1 -1
  129. data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
  130. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
  131. metadata +92 -70
  132. data/KNOWN-ISSUES +0 -44
  133. data/lib/rack/backports/uri/common_18.rb +0 -56
  134. data/lib/rack/backports/uri/common_192.rb +0 -52
  135. data/lib/rack/backports/uri/common_193.rb +0 -29
  136. data/lib/rack/handler/evented_mongrel.rb +0 -8
  137. data/lib/rack/handler/mongrel.rb +0 -106
  138. data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  139. data/lib/rack/showexceptions.rb +0 -387
  140. data/lib/rack/utils/okjson.rb +0 -600
  141. data/test/spec_mongrel.rb +0 -182
@@ -1,7 +1,8 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/builder'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
4
- require 'rack/showexceptions'
5
+ require 'rack/show_exceptions'
5
6
  require 'rack/urlmap'
6
7
 
7
8
  class NothingMiddleware
@@ -22,11 +23,11 @@ describe Rack::Builder do
22
23
  def builder(&block)
23
24
  Rack::Lint.new Rack::Builder.new(&block)
24
25
  end
25
-
26
+
26
27
  def builder_to_app(&block)
27
28
  Rack::Lint.new Rack::Builder.new(&block).to_app
28
29
  end
29
-
30
+
30
31
  it "supports mapping" do
31
32
  app = builder_to_app do
32
33
  map '/' do |outer_env|
@@ -36,8 +37,8 @@ describe Rack::Builder do
36
37
  run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['sub']] }
37
38
  end
38
39
  end
39
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
40
- Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub'
40
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'root'
41
+ Rack::MockRequest.new(app).get("/sub").body.to_s.must_equal 'sub'
41
42
  end
42
43
 
43
44
  it "doesn't dupe env even when mapping" do
@@ -50,8 +51,8 @@ describe Rack::Builder do
50
51
  }
51
52
  end
52
53
  end
53
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
54
- NothingMiddleware.env['new_key'].should.equal 'new_value'
54
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'root'
55
+ NothingMiddleware.env['new_key'].must_equal 'new_value'
55
56
  end
56
57
 
57
58
  it "chains apps by default" do
@@ -60,9 +61,9 @@ describe Rack::Builder do
60
61
  run lambda { |env| raise "bzzzt" }
61
62
  end
62
63
 
63
- Rack::MockRequest.new(app).get("/").should.be.server_error
64
- Rack::MockRequest.new(app).get("/").should.be.server_error
65
- Rack::MockRequest.new(app).get("/").should.be.server_error
64
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
65
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
66
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
66
67
  end
67
68
 
68
69
  it "has implicit #to_app" do
@@ -71,9 +72,9 @@ describe Rack::Builder do
71
72
  run lambda { |env| raise "bzzzt" }
72
73
  end
73
74
 
74
- Rack::MockRequest.new(app).get("/").should.be.server_error
75
- Rack::MockRequest.new(app).get("/").should.be.server_error
76
- Rack::MockRequest.new(app).get("/").should.be.server_error
75
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
76
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
77
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
77
78
  end
78
79
 
79
80
  it "supports blocks on use" do
@@ -87,14 +88,14 @@ describe Rack::Builder do
87
88
  end
88
89
 
89
90
  response = Rack::MockRequest.new(app).get("/")
90
- response.should.be.client_error
91
- response.status.should.equal 401
91
+ response.must_be :client_error?
92
+ response.status.must_equal 401
92
93
 
93
94
  # with auth...
94
95
  response = Rack::MockRequest.new(app).get("/",
95
96
  'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*"))
96
- response.status.should.equal 200
97
- response.body.to_s.should.equal 'Hi Boss'
97
+ response.status.must_equal 200
98
+ response.body.to_s.must_equal 'Hi Boss'
98
99
  end
99
100
 
100
101
  it "has explicit #to_app" do
@@ -103,9 +104,9 @@ describe Rack::Builder do
103
104
  run lambda { |env| raise "bzzzt" }
104
105
  end
105
106
 
106
- Rack::MockRequest.new(app).get("/").should.be.server_error
107
- Rack::MockRequest.new(app).get("/").should.be.server_error
108
- Rack::MockRequest.new(app).get("/").should.be.server_error
107
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
108
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
109
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
109
110
  end
110
111
 
111
112
  it "can mix map and run for endpoints" do
@@ -116,8 +117,8 @@ describe Rack::Builder do
116
117
  run lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, ['root']] }
117
118
  end
118
119
 
119
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
120
- Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub'
120
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'root'
121
+ Rack::MockRequest.new(app).get("/sub").body.to_s.must_equal 'sub'
121
122
  end
122
123
 
123
124
  it "accepts middleware-only map blocks" do
@@ -126,8 +127,8 @@ describe Rack::Builder do
126
127
  run lambda { |env| raise "bzzzt" }
127
128
  end
128
129
 
129
- proc { Rack::MockRequest.new(app).get("/") }.should.raise(RuntimeError)
130
- Rack::MockRequest.new(app).get("/foo").should.be.server_error
130
+ proc { Rack::MockRequest.new(app).get("/") }.must_raise(RuntimeError)
131
+ Rack::MockRequest.new(app).get("/foo").must_be :server_error?
131
132
  end
132
133
 
133
134
  it "yields the generated app to a block for warmup" do
@@ -138,10 +139,10 @@ describe Rack::Builder do
138
139
  run lambda { |env| [200, {}, []] }
139
140
  end.to_app
140
141
 
141
- warmed_up_app.should.equal app
142
+ warmed_up_app.must_equal app
142
143
  end
143
144
 
144
- should "initialize apps once" do
145
+ it "initialize apps once" do
145
146
  app = builder do
146
147
  class AppClass
147
148
  def initialize
@@ -158,8 +159,8 @@ describe Rack::Builder do
158
159
  run AppClass.new
159
160
  end
160
161
 
161
- Rack::MockRequest.new(app).get("/").status.should.equal 200
162
- Rack::MockRequest.new(app).get("/").should.be.server_error
162
+ Rack::MockRequest.new(app).get("/").status.must_equal 200
163
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
163
164
  end
164
165
 
165
166
  it "allows use after run" do
@@ -168,15 +169,15 @@ describe Rack::Builder do
168
169
  use Rack::ShowExceptions
169
170
  end
170
171
 
171
- Rack::MockRequest.new(app).get("/").should.be.server_error
172
- Rack::MockRequest.new(app).get("/").should.be.server_error
173
- Rack::MockRequest.new(app).get("/").should.be.server_error
172
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
173
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
174
+ Rack::MockRequest.new(app).get("/").must_be :server_error?
174
175
  end
175
176
 
176
177
  it 'complains about a missing run' do
177
178
  proc do
178
179
  Rack::Lint.new Rack::Builder.app { use Rack::ShowExceptions }
179
- end.should.raise(RuntimeError)
180
+ end.must_raise(RuntimeError)
180
181
  end
181
182
 
182
183
  describe "parse_file" do
@@ -186,38 +187,47 @@ describe Rack::Builder do
186
187
 
187
188
  it "parses commented options" do
188
189
  app, options = Rack::Builder.parse_file config_file('options.ru')
189
- options[:debug].should.be.true
190
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
190
+ options[:debug].must_equal true
191
+ options[:environment].must_equal 'test'
192
+ options[:Port].must_equal '2929'
193
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'OK'
191
194
  end
192
195
 
193
196
  it "removes __END__ before evaluating app" do
194
197
  app, _ = Rack::Builder.parse_file config_file('end.ru')
195
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
198
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'OK'
196
199
  end
197
200
 
198
201
  it "supports multi-line comments" do
199
- lambda {
200
- Rack::Builder.parse_file config_file('comment.ru')
201
- }.should.not.raise(SyntaxError)
202
+ proc, env = Rack::Builder.parse_file(config_file('comment.ru'))
203
+ proc.must_be_kind_of Proc
204
+ env.must_equal({})
202
205
  end
203
206
 
204
207
  it "requires anything not ending in .ru" do
205
208
  $: << File.dirname(__FILE__)
206
209
  app, * = Rack::Builder.parse_file 'builder/anything'
207
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
210
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'OK'
211
+ $:.pop
212
+ end
213
+
214
+ it 'requires an_underscore_app not ending in .ru' do
215
+ $: << File.dirname(__FILE__)
216
+ app, * = Rack::Builder.parse_file 'builder/an_underscore_app'
217
+ Rack::MockRequest.new(app).get('/').body.to_s.must_equal 'OK'
208
218
  $:.pop
209
219
  end
210
220
 
211
221
  it "sets __LINE__ correctly" do
212
222
  app, _ = Rack::Builder.parse_file config_file('line.ru')
213
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal '1'
223
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal '1'
214
224
  end
215
225
  end
216
226
 
217
227
  describe 'new_from_string' do
218
228
  it "builds a rack app from string" do
219
229
  app, = Rack::Builder.new_from_string "run lambda{|env| [200, {'Content-Type' => 'text/plane'}, ['OK']] }"
220
- Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
230
+ Rack::MockRequest.new(app).get("/").body.to_s.must_equal 'OK'
221
231
  end
222
232
  end
223
233
  end
@@ -1,3 +1,5 @@
1
+ require 'minitest/autorun'
2
+ require 'rack'
1
3
  require 'rack/cascade'
2
4
  require 'rack/file'
3
5
  require 'rack/lint'
@@ -8,7 +10,7 @@ describe Rack::Cascade do
8
10
  def cascade(*args)
9
11
  Rack::Lint.new Rack::Cascade.new(*args)
10
12
  end
11
-
13
+
12
14
  docroot = File.expand_path(File.dirname(__FILE__))
13
15
  app1 = Rack::File.new(docroot)
14
16
 
@@ -17,45 +19,45 @@ describe Rack::Cascade do
17
19
  app3 = Rack::URLMap.new("/foo" => lambda { |env|
18
20
  [200, { "Content-Type" => "text/plain"}, [""]]})
19
21
 
20
- should "dispatch onward on 404 and 405 by default" do
22
+ it "dispatch onward on 404 and 405 by default" do
21
23
  cascade = cascade([app1, app2, app3])
22
- Rack::MockRequest.new(cascade).get("/cgi/test").should.be.ok
23
- Rack::MockRequest.new(cascade).get("/foo").should.be.ok
24
- Rack::MockRequest.new(cascade).get("/toobad").should.be.not_found
25
- Rack::MockRequest.new(cascade).get("/cgi/../..").should.be.client_error
24
+ Rack::MockRequest.new(cascade).get("/cgi/test").must_be :ok?
25
+ Rack::MockRequest.new(cascade).get("/foo").must_be :ok?
26
+ Rack::MockRequest.new(cascade).get("/toobad").must_be :not_found?
27
+ Rack::MockRequest.new(cascade).get("/cgi/../..").must_be :client_error?
26
28
 
27
29
  # Put is not allowed by Rack::File so it'll 405.
28
- Rack::MockRequest.new(cascade).put("/foo").should.be.ok
30
+ Rack::MockRequest.new(cascade).put("/foo").must_be :ok?
29
31
  end
30
32
 
31
- should "dispatch onward on whatever is passed" do
33
+ it "dispatch onward on whatever is passed" do
32
34
  cascade = cascade([app1, app2, app3], [404, 403])
33
- Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.not_found
35
+ Rack::MockRequest.new(cascade).get("/cgi/../bla").must_be :not_found?
34
36
  end
35
37
 
36
- should "return 404 if empty" do
37
- Rack::MockRequest.new(cascade([])).get('/').should.be.not_found
38
+ it "return 404 if empty" do
39
+ Rack::MockRequest.new(cascade([])).get('/').must_be :not_found?
38
40
  end
39
41
 
40
- should "append new app" do
42
+ it "append new app" do
41
43
  cascade = Rack::Cascade.new([], [404, 403])
42
- Rack::MockRequest.new(cascade).get('/').should.be.not_found
44
+ Rack::MockRequest.new(cascade).get('/').must_be :not_found?
43
45
  cascade << app2
44
- Rack::MockRequest.new(cascade).get('/cgi/test').should.be.not_found
45
- Rack::MockRequest.new(cascade).get('/cgi/../bla').should.be.not_found
46
+ Rack::MockRequest.new(cascade).get('/cgi/test').must_be :not_found?
47
+ Rack::MockRequest.new(cascade).get('/cgi/../bla').must_be :not_found?
46
48
  cascade << app1
47
- Rack::MockRequest.new(cascade).get('/cgi/test').should.be.ok
48
- Rack::MockRequest.new(cascade).get('/cgi/../..').should.be.client_error
49
- Rack::MockRequest.new(cascade).get('/foo').should.be.not_found
49
+ Rack::MockRequest.new(cascade).get('/cgi/test').must_be :ok?
50
+ Rack::MockRequest.new(cascade).get('/cgi/../..').must_be :client_error?
51
+ Rack::MockRequest.new(cascade).get('/foo').must_be :not_found?
50
52
  cascade << app3
51
- Rack::MockRequest.new(cascade).get('/foo').should.be.ok
53
+ Rack::MockRequest.new(cascade).get('/foo').must_be :ok?
52
54
  end
53
55
 
54
- should "close the body on cascade" do
56
+ it "close the body on cascade" do
55
57
  body = StringIO.new
56
58
  closer = lambda { |env| [404, {}, body] }
57
59
  cascade = Rack::Cascade.new([closer, app3], [404])
58
- Rack::MockRequest.new(cascade).get("/foo").should.be.ok
59
- body.should.be.closed
60
+ Rack::MockRequest.new(cascade).get("/foo").must_be :ok?
61
+ body.must_be :closed?
60
62
  end
61
63
  end
@@ -1,102 +1,84 @@
1
- begin
1
+ require 'helper'
2
+
3
+ if defined? LIGHTTPD_PID
4
+
2
5
  require File.expand_path('../testrequest', __FILE__)
3
6
  require 'rack/handler/cgi'
4
7
 
5
8
  describe Rack::Handler::CGI do
6
- extend TestRequest::Helpers
9
+ include TestRequest::Helpers
7
10
 
8
- @host = '127.0.0.1'
9
- @port = 9203
11
+ before do
12
+ @host = '127.0.0.1'
13
+ @port = 9203
14
+ end
10
15
 
11
16
  if `which lighttpd` && !$?.success?
12
17
  raise "lighttpd not found"
13
18
  end
14
19
 
15
- # Keep this first.
16
- $pid = fork {
17
- ENV['RACK_ENV'] = 'deployment'
18
- ENV['RUBYLIB'] = [
19
- File.expand_path('../../lib', __FILE__),
20
- ENV['RUBYLIB'],
21
- ].compact.join(':')
22
-
23
- Dir.chdir(File.expand_path("../cgi", __FILE__)) do
24
- exec "lighttpd -D -f lighttpd.conf"
25
- end
26
- }
27
-
28
- should "respond" do
20
+ it "respond" do
29
21
  sleep 1
30
22
  GET("/test")
31
- response.should.not.be.nil
23
+ response.wont_be :nil?
32
24
  end
33
25
 
34
- should "be a lighttpd" do
26
+ it "be a lighttpd" do
35
27
  GET("/test")
36
- status.should.equal 200
37
- response["SERVER_SOFTWARE"].should =~ /lighttpd/
38
- response["HTTP_VERSION"].should.equal "HTTP/1.1"
39
- response["SERVER_PROTOCOL"].should.equal "HTTP/1.1"
40
- response["SERVER_PORT"].should.equal @port.to_s
41
- response["SERVER_NAME"].should.equal @host
28
+ status.must_equal 200
29
+ response["SERVER_SOFTWARE"].must_match(/lighttpd/)
30
+ response["HTTP_VERSION"].must_equal "HTTP/1.1"
31
+ response["SERVER_PROTOCOL"].must_equal "HTTP/1.1"
32
+ response["SERVER_PORT"].must_equal @port.to_s
33
+ response["SERVER_NAME"].must_equal @host
42
34
  end
43
35
 
44
- should "have rack headers" do
36
+ it "have rack headers" do
45
37
  GET("/test")
46
- response["rack.version"].should.equal([1,3])
47
- response["rack.multithread"].should.be.false
48
- response["rack.multiprocess"].should.be.true
49
- response["rack.run_once"].should.be.true
38
+ response["rack.version"].must_equal [1,3]
39
+ assert_equal false, response["rack.multithread"]
40
+ assert_equal true, response["rack.multiprocess"]
41
+ assert_equal true, response["rack.run_once"]
50
42
  end
51
43
 
52
- should "have CGI headers on GET" do
44
+ it "have CGI headers on GET" do
53
45
  GET("/test")
54
- response["REQUEST_METHOD"].should.equal "GET"
55
- response["SCRIPT_NAME"].should.equal "/test"
56
- response["REQUEST_PATH"].should.equal "/"
57
- response["PATH_INFO"].should.be.nil
58
- response["QUERY_STRING"].should.equal ""
59
- response["test.postdata"].should.equal ""
46
+ response["REQUEST_METHOD"].must_equal "GET"
47
+ response["SCRIPT_NAME"].must_equal "/test"
48
+ response["REQUEST_PATH"].must_equal "/"
49
+ response["PATH_INFO"].must_be_nil
50
+ response["QUERY_STRING"].must_equal ""
51
+ response["test.postdata"].must_equal ""
60
52
 
61
53
  GET("/test/foo?quux=1")
62
- response["REQUEST_METHOD"].should.equal "GET"
63
- response["SCRIPT_NAME"].should.equal "/test"
64
- response["REQUEST_PATH"].should.equal "/"
65
- response["PATH_INFO"].should.equal "/foo"
66
- response["QUERY_STRING"].should.equal "quux=1"
54
+ response["REQUEST_METHOD"].must_equal "GET"
55
+ response["SCRIPT_NAME"].must_equal "/test"
56
+ response["REQUEST_PATH"].must_equal "/"
57
+ response["PATH_INFO"].must_equal "/foo"
58
+ response["QUERY_STRING"].must_equal "quux=1"
67
59
  end
68
60
 
69
- should "have CGI headers on POST" do
61
+ it "have CGI headers on POST" do
70
62
  POST("/test", {"rack-form-data" => "23"}, {'X-test-header' => '42'})
71
- status.should.equal 200
72
- response["REQUEST_METHOD"].should.equal "POST"
73
- response["SCRIPT_NAME"].should.equal "/test"
74
- response["REQUEST_PATH"].should.equal "/"
75
- response["QUERY_STRING"].should.equal ""
76
- response["HTTP_X_TEST_HEADER"].should.equal "42"
77
- response["test.postdata"].should.equal "rack-form-data=23"
63
+ status.must_equal 200
64
+ response["REQUEST_METHOD"].must_equal "POST"
65
+ response["SCRIPT_NAME"].must_equal "/test"
66
+ response["REQUEST_PATH"].must_equal "/"
67
+ response["QUERY_STRING"].must_equal ""
68
+ response["HTTP_X_TEST_HEADER"].must_equal "42"
69
+ response["test.postdata"].must_equal "rack-form-data=23"
78
70
  end
79
71
 
80
- should "support HTTP auth" do
72
+ it "support HTTP auth" do
81
73
  GET("/test", {:user => "ruth", :passwd => "secret"})
82
- response["HTTP_AUTHORIZATION"].should.equal "Basic cnV0aDpzZWNyZXQ="
74
+ response["HTTP_AUTHORIZATION"].must_equal "Basic cnV0aDpzZWNyZXQ="
83
75
  end
84
76
 
85
- should "set status" do
77
+ it "set status" do
86
78
  GET("/test?secret")
87
- status.should.equal 403
88
- response["rack.url_scheme"].should.equal "http"
89
- end
90
-
91
- # Keep this last.
92
- should "shutdown" do
93
- Process.kill 15, $pid
94
- Process.wait($pid).should == $pid
79
+ status.must_equal 403
80
+ response["rack.url_scheme"].must_equal "http"
95
81
  end
96
82
  end
97
83
 
98
- rescue RuntimeError
99
- $stderr.puts "Skipping Rack::Handler::CGI tests (lighttpd is required). Install lighttpd and try again."
100
- rescue NotImplementedError
101
- $stderr.puts "Your Ruby implemenation or platform does not support fork. Skipping Rack::Handler::CGI tests."
102
- end
84
+ end # if defined? LIGHTTPD_PID