rack 1.1.6 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. data/README +9 -205
  2. data/SPEC +3 -3
  3. data/lib/rack.rb +1 -24
  4. data/lib/rack/auth/abstract/request.rb +1 -5
  5. data/lib/rack/auth/digest/md5.rb +1 -2
  6. data/lib/rack/auth/digest/params.rb +1 -1
  7. data/lib/rack/content_length.rb +1 -1
  8. data/lib/rack/etag.rb +15 -6
  9. data/lib/rack/file.rb +3 -1
  10. data/lib/rack/handler/cgi.rb +8 -7
  11. data/lib/rack/handler/fastcgi.rb +1 -1
  12. data/lib/rack/handler/lsws.rb +1 -1
  13. data/lib/rack/handler/mongrel.rb +1 -1
  14. data/lib/rack/handler/scgi.rb +1 -4
  15. data/lib/rack/handler/webrick.rb +10 -6
  16. data/lib/rack/lint.rb +29 -37
  17. data/lib/rack/mime.rb +2 -0
  18. data/lib/rack/mock.rb +2 -1
  19. data/lib/rack/recursive.rb +4 -0
  20. data/lib/rack/request.rb +8 -6
  21. data/lib/rack/response.rb +1 -0
  22. data/lib/rack/rewindable_input.rb +13 -10
  23. data/lib/rack/sendfile.rb +8 -6
  24. data/lib/rack/server.rb +68 -9
  25. data/lib/rack/session/cookie.rb +1 -10
  26. data/lib/rack/session/memcache.rb +1 -1
  27. data/lib/rack/urlmap.rb +6 -7
  28. data/lib/rack/utils.rb +40 -71
  29. data/rack.gemspec +7 -11
  30. data/spec/cgi/lighttpd.conf +25 -0
  31. data/spec/cgi/rackup_stub.rb +6 -0
  32. data/spec/cgi/sample_rackup.ru +5 -0
  33. data/spec/cgi/test +9 -0
  34. data/spec/cgi/test.fcgi +8 -0
  35. data/spec/cgi/test.ru +5 -0
  36. data/spec/multipart/bad_robots +259 -0
  37. data/spec/multipart/binary +0 -0
  38. data/spec/multipart/empty +10 -0
  39. data/spec/multipart/fail_16384_nofile +814 -0
  40. data/spec/multipart/file1.txt +1 -0
  41. data/spec/multipart/filename_and_modification_param +7 -0
  42. data/spec/multipart/filename_with_escaped_quotes +6 -0
  43. data/spec/multipart/filename_with_escaped_quotes_and_modification_param +7 -0
  44. data/spec/multipart/filename_with_percent_escaped_quotes +6 -0
  45. data/spec/multipart/filename_with_unescaped_quotes +6 -0
  46. data/spec/multipart/ie +6 -0
  47. data/spec/multipart/nested +10 -0
  48. data/spec/multipart/none +9 -0
  49. data/spec/multipart/semicolon +6 -0
  50. data/spec/multipart/text +10 -0
  51. data/spec/rackup/config.ru +31 -0
  52. data/{test/spec_rack_auth_basic.rb → spec/spec_auth_basic.rb} +11 -14
  53. data/{test/spec_rack_auth_digest.rb → spec/spec_auth_digest.rb} +18 -27
  54. data/{test/spec_rack_builder.rb → spec/spec_builder.rb} +49 -10
  55. data/{test/spec_rack_cascade.rb → spec/spec_cascade.rb} +7 -10
  56. data/{test/spec_rack_cgi.rb → spec/spec_cgi.rb} +34 -32
  57. data/{test/spec_rack_chunked.rb → spec/spec_chunked.rb} +8 -10
  58. data/{test/spec_rack_commonlogger.rb → spec/spec_commonlogger.rb} +10 -15
  59. data/{test/spec_rack_conditionalget.rb → spec/spec_conditionalget.rb} +5 -7
  60. data/{test/spec_rack_config.rb → spec/spec_config.rb} +6 -7
  61. data/{test/spec_rack_content_length.rb → spec/spec_content_length.rb} +7 -8
  62. data/{test/spec_rack_content_type.rb → spec/spec_content_type.rb} +5 -6
  63. data/{test/spec_rack_deflater.rb → spec/spec_deflater.rb} +11 -13
  64. data/{test/spec_rack_directory.rb → spec/spec_directory.rb} +6 -10
  65. data/{test/spec_rack_etag.rb → spec/spec_etag.rb} +3 -5
  66. data/{test/spec_rack_fastcgi.rb → spec/spec_fastcgi.rb} +36 -29
  67. data/{test/spec_rack_file.rb → spec/spec_file.rb} +9 -13
  68. data/{test/spec_rack_handler.rb → spec/spec_handler.rb} +10 -12
  69. data/{test/spec_rack_head.rb → spec/spec_head.rb} +3 -3
  70. data/{test/spec_rack_lint.rb → spec/spec_lint.rb} +19 -32
  71. data/{test/spec_rack_lobster.rb → spec/spec_lobster.rb} +9 -11
  72. data/{test/spec_rack_lock.rb → spec/spec_lock.rb} +15 -17
  73. data/{test/spec_rack_logger.rb → spec/spec_logger.rb} +6 -7
  74. data/{test/spec_rack_methodoverride.rb → spec/spec_methodoverride.rb} +15 -17
  75. data/{test/spec_rack_mock.rb → spec/spec_mock.rb} +30 -32
  76. data/{test/spec_rack_mongrel.rb → spec/spec_mongrel.rb} +40 -46
  77. data/{test/spec_rack_nulllogger.rb → spec/spec_nulllogger.rb} +4 -5
  78. data/{test/spec_rack_recursive.rb → spec/spec_recursive.rb} +28 -36
  79. data/{test/spec_rack_request.rb → spec/spec_request.rb} +84 -98
  80. data/{test/spec_rack_response.rb → spec/spec_response.rb} +46 -27
  81. data/spec/spec_rewindable_input.rb +118 -0
  82. data/{test/spec_rack_runtime.rb → spec/spec_runtime.rb} +15 -11
  83. data/{test/spec_rack_sendfile.rb → spec/spec_sendfile.rb} +11 -14
  84. data/{test/spec_rack_session_cookie.rb → spec/spec_session_cookie.rb} +14 -36
  85. data/{test/spec_rack_session_memcache.rb → spec/spec_session_memcache.rb} +32 -26
  86. data/{test/spec_rack_session_pool.rb → spec/spec_session_pool.rb} +36 -31
  87. data/spec/spec_showexceptions.rb +23 -0
  88. data/spec/spec_showstatus.rb +79 -0
  89. data/{test/spec_rack_static.rb → spec/spec_static.rb} +5 -9
  90. data/{test/spec_rack_thin.rb → spec/spec_thin.rb} +30 -35
  91. data/{test/spec_rack_urlmap.rb → spec/spec_urlmap.rb} +6 -8
  92. data/{test/spec_rack_utils.rb → spec/spec_utils.rb} +134 -74
  93. data/{test/spec_rack_webrick.rb → spec/spec_webrick.rb} +28 -36
  94. data/spec/testrequest.rb +77 -0
  95. data/spec/unregistered_handler/rack/handler/unregistered.rb +7 -0
  96. data/spec/unregistered_handler/rack/handler/unregistered_long_one.rb +7 -0
  97. metadata +176 -191
  98. data/RDOX +0 -0
  99. data/lib/rack/adapter/camping.rb +0 -22
  100. data/test/spec_auth.rb +0 -57
  101. data/test/spec_rack_camping.rb +0 -55
  102. data/test/spec_rack_rewindable_input.rb +0 -118
  103. data/test/spec_rack_showexceptions.rb +0 -21
  104. data/test/spec_rack_showstatus.rb +0 -72
  105. data/test/spec_rackup.rb +0 -164
@@ -0,0 +1 @@
1
+ contents
@@ -0,0 +1,7 @@
1
+ --AaB03x
2
+ Content-Type: image/jpeg
3
+ Content-Disposition: attachment; name="files"; filename=genome.jpeg; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
4
+ Content-Description: a complete map of the human genome
5
+
6
+ contents
7
+ --AaB03x--
@@ -0,0 +1,6 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="files"; filename="escape \"quotes"
3
+ Content-Type: application/octet-stream
4
+
5
+ contents
6
+ --AaB03x--
@@ -0,0 +1,7 @@
1
+ --AaB03x
2
+ Content-Type: image/jpeg
3
+ Content-Disposition: attachment; name="files"; filename=""human" genome.jpeg"; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
4
+ Content-Description: a complete map of the human genome
5
+
6
+ contents
7
+ --AaB03x--
@@ -0,0 +1,6 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="files"; filename="escape %22quotes"
3
+ Content-Type: application/octet-stream
4
+
5
+ contents
6
+ --AaB03x--
@@ -0,0 +1,6 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="files"; filename="escape "quotes"
3
+ Content-Type: application/octet-stream
4
+
5
+ contents
6
+ --AaB03x--
@@ -0,0 +1,6 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="files"; filename="C:\Documents and Settings\Administrator\Desktop\file1.txt"
3
+ Content-Type: text/plain
4
+
5
+ contents
6
+ --AaB03x--
@@ -0,0 +1,10 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="foo[submit-name]"
3
+
4
+ Larry
5
+ --AaB03x
6
+ Content-Disposition: form-data; name="foo[files]"; filename="file1.txt"
7
+ Content-Type: text/plain
8
+
9
+ contents
10
+ --AaB03x--
@@ -0,0 +1,9 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="submit-name"
3
+
4
+ Larry
5
+ --AaB03x
6
+ Content-Disposition: form-data; name="files"; filename=""
7
+
8
+
9
+ --AaB03x--
@@ -0,0 +1,6 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="files"; filename="fi;le1.txt"
3
+ Content-Type: text/plain
4
+
5
+ contents
6
+ --AaB03x--
@@ -0,0 +1,10 @@
1
+ --AaB03x
2
+ Content-Disposition: form-data; name="submit-name"
3
+
4
+ Larry
5
+ --AaB03x
6
+ Content-Disposition: form-data; name="files"; filename="file1.txt"
7
+ Content-Type: text/plain
8
+
9
+ contents
10
+ --AaB03x--
@@ -0,0 +1,31 @@
1
+ require "#{File.dirname(__FILE__)}/../testrequest"
2
+
3
+ $stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")
4
+
5
+ class EnvMiddleware
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ # provides a way to test that lint is present
12
+ if env["PATH_INFO"] == "/broken_lint"
13
+ return [200, {}, ["Broken Lint"]]
14
+ # provides a way to kill the process without knowing the pid
15
+ elsif env["PATH_INFO"] == "/die"
16
+ exit!
17
+ end
18
+
19
+ env["test.$DEBUG"] = $DEBUG
20
+ env["test.$EVAL"] = BUKKIT if defined?(BUKKIT)
21
+ env["test.$VERBOSE"] = $VERBOSE
22
+ env["test.$LOAD_PATH"] = $LOAD_PATH
23
+ env["test.stderr"] = File.expand_path($stderr.path)
24
+ env["test.Ping"] = defined?(Ping)
25
+ env["test.pid"] = Process.pid
26
+ @app.call(env)
27
+ end
28
+ end
29
+
30
+ use EnvMiddleware
31
+ run TestRequest.new
@@ -1,25 +1,22 @@
1
- require 'test/spec'
2
-
3
1
  require 'rack/auth/basic'
4
2
  require 'rack/mock'
5
3
 
6
- context 'Rack::Auth::Basic' do
7
-
4
+ describe Rack::Auth::Basic do
8
5
  def realm
9
6
  'WallysWorld'
10
7
  end
11
-
8
+
12
9
  def unprotected_app
13
10
  lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] }
14
11
  end
15
-
12
+
16
13
  def protected_app
17
14
  app = Rack::Auth::Basic.new(unprotected_app) { |username, password| 'Boss' == username }
18
15
  app.realm = realm
19
16
  app
20
17
  end
21
18
 
22
- setup do
19
+ before do
23
20
  @request = Rack::MockRequest.new(protected_app)
24
21
  end
25
22
 
@@ -39,26 +36,26 @@ context 'Rack::Auth::Basic' do
39
36
  response.body.should.be.empty
40
37
  end
41
38
 
42
- specify 'should challenge correctly when no credentials are specified' do
39
+ should 'challenge correctly when no credentials are specified' do
43
40
  request do |response|
44
41
  assert_basic_auth_challenge response
45
42
  end
46
43
  end
47
44
 
48
- specify 'should rechallenge if incorrect credentials are specified' do
45
+ should 'rechallenge if incorrect credentials are specified' do
49
46
  request_with_basic_auth 'joe', 'password' do |response|
50
47
  assert_basic_auth_challenge response
51
48
  end
52
49
  end
53
50
 
54
- specify 'should return application output if correct credentials are specified' do
51
+ should 'return application output if correct credentials are specified' do
55
52
  request_with_basic_auth 'Boss', 'password' do |response|
56
53
  response.status.should.equal 200
57
54
  response.body.to_s.should.equal 'Hi Boss'
58
55
  end
59
56
  end
60
-
61
- specify 'should return 400 Bad Request if different auth scheme used' do
57
+
58
+ should 'return 400 Bad Request if different auth scheme used' do
62
59
  request 'HTTP_AUTHORIZATION' => 'Digest params' do |response|
63
60
  response.should.be.a.client_error
64
61
  response.status.should.equal 400
@@ -66,8 +63,8 @@ context 'Rack::Auth::Basic' do
66
63
  end
67
64
  end
68
65
 
69
- specify 'realm as optional constructor arg' do
66
+ it 'takes realm as optional constructor arg' do
70
67
  app = Rack::Auth::Basic.new(unprotected_app, realm) { true }
71
- assert_equal realm, app.realm
68
+ realm.should == app.realm
72
69
  end
73
70
  end
@@ -1,10 +1,7 @@
1
- require 'test/spec'
2
-
3
1
  require 'rack/auth/digest/md5'
4
2
  require 'rack/mock'
5
3
 
6
- context 'Rack::Auth::Digest::MD5' do
7
-
4
+ describe Rack::Auth::Digest::MD5 do
8
5
  def realm
9
6
  'WallysWorld'
10
7
  end
@@ -45,7 +42,7 @@ context 'Rack::Auth::Digest::MD5' do
45
42
  Rack::MethodOverride.new(protected_app)
46
43
  end
47
44
 
48
- setup do
45
+ before do
49
46
  @request = Rack::MockRequest.new(protected_app)
50
47
  end
51
48
 
@@ -117,20 +114,20 @@ context 'Rack::Auth::Digest::MD5' do
117
114
  response.should.not.include 'WWW-Authenticate'
118
115
  end
119
116
 
120
- specify 'should challenge when no credentials are specified' do
117
+ should 'challenge when no credentials are specified' do
121
118
  request 'GET', '/' do |response|
122
119
  assert_digest_auth_challenge response
123
120
  end
124
121
  end
125
122
 
126
- specify 'should return application output if correct credentials given' do
123
+ should 'return application output if correct credentials given' do
127
124
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
128
125
  response.status.should.equal 200
129
126
  response.body.to_s.should.equal 'Hi Alice'
130
127
  end
131
128
  end
132
129
 
133
- specify 'should return application output if correct credentials given (hashed passwords)' do
130
+ should 'return application output if correct credentials given (hashed passwords)' do
134
131
  @request = Rack::MockRequest.new(protected_app_with_hashed_passwords)
135
132
 
136
133
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
@@ -139,25 +136,19 @@ context 'Rack::Auth::Digest::MD5' do
139
136
  end
140
137
  end
141
138
 
142
- specify 'should rechallenge if incorrect username given' do
139
+ should 'rechallenge if incorrect username given' do
143
140
  request_with_digest_auth 'GET', '/', 'Bob', 'correct-password' do |response|
144
141
  assert_digest_auth_challenge response
145
142
  end
146
143
  end
147
144
 
148
- specify 'should rechallenge if incorrect password given' do
145
+ should 'rechallenge if incorrect password given' do
149
146
  request_with_digest_auth 'GET', '/', 'Alice', 'wrong-password' do |response|
150
147
  assert_digest_auth_challenge response
151
148
  end
152
149
  end
153
150
 
154
- specify 'rechallenge if incorrect user and blank password given' do
155
- request_with_digest_auth 'GET', '/', 'Bob', '' do |response|
156
- assert_digest_auth_challenge response
157
- end
158
- end
159
-
160
- specify 'should rechallenge with stale parameter if nonce is stale' do
151
+ should 'rechallenge with stale parameter if nonce is stale' do
161
152
  begin
162
153
  Rack::Auth::Digest::Nonce.time_limit = 1
163
154
 
@@ -170,39 +161,39 @@ context 'Rack::Auth::Digest::MD5' do
170
161
  end
171
162
  end
172
163
 
173
- specify 'should return 400 Bad Request if incorrect qop given' do
164
+ should 'return 400 Bad Request if incorrect qop given' do
174
165
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'qop' => 'auth-int' do |response|
175
166
  assert_bad_request response
176
167
  end
177
168
  end
178
169
 
179
- specify 'should return 400 Bad Request if incorrect uri given' do
170
+ should 'return 400 Bad Request if incorrect uri given' do
180
171
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'uri' => '/foo' do |response|
181
172
  assert_bad_request response
182
173
  end
183
174
  end
184
175
 
185
- specify 'should return 400 Bad Request if different auth scheme used' do
176
+ should 'return 400 Bad Request if different auth scheme used' do
186
177
  request 'GET', '/', 'HTTP_AUTHORIZATION' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' do |response|
187
178
  assert_bad_request response
188
179
  end
189
180
  end
190
181
 
191
- specify 'should not require credentials for unprotected path' do
182
+ should 'not require credentials for unprotected path' do
192
183
  @request = Rack::MockRequest.new(partially_protected_app)
193
184
  request 'GET', '/' do |response|
194
185
  response.should.be.ok
195
186
  end
196
187
  end
197
188
 
198
- specify 'should challenge when no credentials are specified for protected path' do
189
+ should 'challenge when no credentials are specified for protected path' do
199
190
  @request = Rack::MockRequest.new(partially_protected_app)
200
191
  request 'GET', '/protected' do |response|
201
192
  assert_digest_auth_challenge response
202
193
  end
203
194
  end
204
195
 
205
- specify 'should return application output if correct credentials given for protected path' do
196
+ should 'return application output if correct credentials given for protected path' do
206
197
  @request = Rack::MockRequest.new(partially_protected_app)
207
198
  request_with_digest_auth 'GET', '/protected', 'Alice', 'correct-password' do |response|
208
199
  response.status.should.equal 200
@@ -210,14 +201,14 @@ context 'Rack::Auth::Digest::MD5' do
210
201
  end
211
202
  end
212
203
 
213
- specify 'should return application output if correct credentials given for POST' do
204
+ should 'return application output if correct credentials given for POST' do
214
205
  request_with_digest_auth 'POST', '/', 'Alice', 'correct-password' do |response|
215
206
  response.status.should.equal 200
216
207
  response.body.to_s.should.equal 'Hi Alice'
217
208
  end
218
209
  end
219
210
 
220
- specify 'should return application output if correct credentials given for PUT (using method override of POST)' do
211
+ should 'return application output if correct credentials given for PUT (using method override of POST)' do
221
212
  @request = Rack::MockRequest.new(protected_app_with_method_override)
222
213
  request_with_digest_auth 'POST', '/', 'Alice', 'correct-password', :input => "_method=put" do |response|
223
214
  response.status.should.equal 200
@@ -225,8 +216,8 @@ context 'Rack::Auth::Digest::MD5' do
225
216
  end
226
217
  end
227
218
 
228
- specify 'realm as optional constructor arg' do
219
+ it 'takes realm as optional constructor arg' do
229
220
  app = Rack::Auth::Digest::MD5.new(unprotected_app, realm) { true }
230
- assert_equal realm, app.realm
221
+ realm.should == app.realm
231
222
  end
232
223
  end
@@ -1,12 +1,51 @@
1
- require 'test/spec'
2
-
3
1
  require 'rack/builder'
4
2
  require 'rack/mock'
5
3
  require 'rack/showexceptions'
6
- require 'rack/auth/basic'
4
+ require 'rack/urlmap'
5
+
6
+ class NothingMiddleware
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+ def call(env)
11
+ @@env = env
12
+ response = @app.call(env)
13
+ response
14
+ end
15
+ def self.env
16
+ @@env
17
+ end
18
+ end
19
+
20
+ describe Rack::Builder do
21
+ it "supports mapping" do
22
+ app = Rack::Builder.new do
23
+ map '/' do |outer_env|
24
+ run lambda { |inner_env| [200, {}, ['root']] }
25
+ end
26
+ map '/sub' do
27
+ run lambda { |inner_env| [200, {}, ['sub']] }
28
+ end
29
+ end.to_app
30
+ Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
31
+ Rack::MockRequest.new(app).get("/sub").body.to_s.should.equal 'sub'
32
+ end
33
+
34
+ it "doesn't dupe env even when mapping" do
35
+ app = Rack::Builder.new do
36
+ use NothingMiddleware
37
+ map '/' do |outer_env|
38
+ run lambda { |inner_env|
39
+ inner_env['new_key'] = 'new_value'
40
+ [200, {}, ['root']]
41
+ }
42
+ end
43
+ end.to_app
44
+ Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'root'
45
+ NothingMiddleware.env['new_key'].should.equal 'new_value'
46
+ end
7
47
 
8
- context "Rack::Builder" do
9
- specify "chains apps by default" do
48
+ it "chains apps by default" do
10
49
  app = Rack::Builder.new do
11
50
  use Rack::ShowExceptions
12
51
  run lambda { |env| raise "bzzzt" }
@@ -17,7 +56,7 @@ context "Rack::Builder" do
17
56
  Rack::MockRequest.new(app).get("/").should.be.server_error
18
57
  end
19
58
 
20
- specify "has implicit #to_app" do
59
+ it "has implicit #to_app" do
21
60
  app = Rack::Builder.new do
22
61
  use Rack::ShowExceptions
23
62
  run lambda { |env| raise "bzzzt" }
@@ -28,7 +67,7 @@ context "Rack::Builder" do
28
67
  Rack::MockRequest.new(app).get("/").should.be.server_error
29
68
  end
30
69
 
31
- specify "supports blocks on use" do
70
+ it "supports blocks on use" do
32
71
  app = Rack::Builder.new do
33
72
  use Rack::ShowExceptions
34
73
  use Rack::Auth::Basic do |username, password|
@@ -43,13 +82,13 @@ context "Rack::Builder" do
43
82
  response.status.should.equal 401
44
83
 
45
84
  # with auth...
46
- response = Rack::MockRequest.new(app).get("/",
85
+ response = Rack::MockRequest.new(app).get("/",
47
86
  'HTTP_AUTHORIZATION' => 'Basic ' + ["joe:secret"].pack("m*"))
48
87
  response.status.should.equal 200
49
88
  response.body.to_s.should.equal 'Hi Boss'
50
89
  end
51
90
 
52
- specify "has explicit #to_app" do
91
+ it "has explicit #to_app" do
53
92
  app = Rack::Builder.app do
54
93
  use Rack::ShowExceptions
55
94
  run lambda { |env| raise "bzzzt" }
@@ -60,7 +99,7 @@ context "Rack::Builder" do
60
99
  Rack::MockRequest.new(app).get("/").should.be.server_error
61
100
  end
62
101
 
63
- specify "apps are initialized once" do
102
+ should "initialize apps once" do
64
103
  app = Rack::Builder.new do
65
104
  class AppClass
66
105
  def initialize
@@ -1,12 +1,9 @@
1
- require 'test/spec'
2
-
3
1
  require 'rack/cascade'
4
- require 'rack/mock'
5
-
6
- require 'rack/urlmap'
7
2
  require 'rack/file'
3
+ require 'rack/urlmap'
4
+ require 'rack/mock'
8
5
 
9
- context "Rack::Cascade" do
6
+ describe Rack::Cascade do
10
7
  docroot = File.expand_path(File.dirname(__FILE__))
11
8
  app1 = Rack::File.new(docroot)
12
9
 
@@ -15,7 +12,7 @@ context "Rack::Cascade" do
15
12
  app3 = Rack::URLMap.new("/foo" => lambda { |env|
16
13
  [200, { "Content-Type" => "text/plain"}, [""]]})
17
14
 
18
- specify "should dispatch onward on 404 by default" do
15
+ should "dispatch onward on 404 by default" do
19
16
  cascade = Rack::Cascade.new([app1, app2, app3])
20
17
  Rack::MockRequest.new(cascade).get("/cgi/test").should.be.ok
21
18
  Rack::MockRequest.new(cascade).get("/foo").should.be.ok
@@ -23,16 +20,16 @@ context "Rack::Cascade" do
23
20
  Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.forbidden
24
21
  end
25
22
 
26
- specify "should dispatch onward on whatever is passed" do
23
+ should "dispatch onward on whatever is passed" do
27
24
  cascade = Rack::Cascade.new([app1, app2, app3], [404, 403])
28
25
  Rack::MockRequest.new(cascade).get("/cgi/../bla").should.be.not_found
29
26
  end
30
27
 
31
- specify "should return 404 if empty" do
28
+ should "return 404 if empty" do
32
29
  Rack::MockRequest.new(Rack::Cascade.new([])).get('/').should.be.not_found
33
30
  end
34
31
 
35
- specify "should append new app" do
32
+ should "append new app" do
36
33
  cascade = Rack::Cascade.new([], [404, 403])
37
34
  Rack::MockRequest.new(cascade).get('/').should.be.not_found
38
35
  cascade << app2