rack 1.6.13 → 2.0.0.alpha

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 (138) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY.md +139 -18
  3. data/README.rdoc +17 -25
  4. data/Rakefile +6 -14
  5. data/SPEC +8 -9
  6. data/contrib/rack_logo.svg +164 -111
  7. data/lib/rack.rb +70 -21
  8. data/lib/rack/auth/digest/request.rb +1 -1
  9. data/lib/rack/body_proxy.rb +14 -9
  10. data/lib/rack/builder.rb +3 -3
  11. data/lib/rack/chunked.rb +5 -5
  12. data/lib/rack/{commonlogger.rb → common_logger.rb} +2 -2
  13. data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
  14. data/lib/rack/content_length.rb +2 -2
  15. data/lib/rack/deflater.rb +4 -4
  16. data/lib/rack/directory.rb +49 -55
  17. data/lib/rack/etag.rb +2 -1
  18. data/lib/rack/events.rb +154 -0
  19. data/lib/rack/file.rb +55 -40
  20. data/lib/rack/handler.rb +2 -24
  21. data/lib/rack/handler/cgi.rb +15 -16
  22. data/lib/rack/handler/fastcgi.rb +13 -14
  23. data/lib/rack/handler/lsws.rb +11 -11
  24. data/lib/rack/handler/scgi.rb +15 -15
  25. data/lib/rack/handler/thin.rb +3 -0
  26. data/lib/rack/handler/webrick.rb +22 -24
  27. data/lib/rack/head.rb +15 -17
  28. data/lib/rack/lint.rb +38 -38
  29. data/lib/rack/lobster.rb +1 -1
  30. data/lib/rack/lock.rb +6 -10
  31. data/lib/rack/logger.rb +2 -2
  32. data/lib/rack/media_type.rb +38 -0
  33. data/lib/rack/{methodoverride.rb → method_override.rb} +4 -11
  34. data/lib/rack/mime.rb +18 -5
  35. data/lib/rack/mock.rb +35 -52
  36. data/lib/rack/multipart.rb +35 -6
  37. data/lib/rack/multipart/generator.rb +4 -4
  38. data/lib/rack/multipart/parser.rb +273 -158
  39. data/lib/rack/multipart/uploaded_file.rb +1 -2
  40. data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
  41. data/lib/rack/query_parser.rb +174 -0
  42. data/lib/rack/recursive.rb +8 -8
  43. data/lib/rack/reloader.rb +1 -2
  44. data/lib/rack/request.rb +370 -304
  45. data/lib/rack/response.rb +129 -56
  46. data/lib/rack/rewindable_input.rb +1 -12
  47. data/lib/rack/runtime.rb +10 -18
  48. data/lib/rack/sendfile.rb +5 -7
  49. data/lib/rack/server.rb +31 -25
  50. data/lib/rack/session/abstract/id.rb +93 -135
  51. data/lib/rack/session/cookie.rb +26 -28
  52. data/lib/rack/session/memcache.rb +8 -14
  53. data/lib/rack/session/pool.rb +14 -21
  54. data/lib/rack/show_exceptions.rb +386 -0
  55. data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
  56. data/lib/rack/static.rb +30 -5
  57. data/lib/rack/tempfile_reaper.rb +2 -2
  58. data/lib/rack/urlmap.rb +13 -14
  59. data/lib/rack/utils.rb +128 -221
  60. data/rack.gemspec +9 -5
  61. data/test/builder/an_underscore_app.rb +5 -0
  62. data/test/builder/options.ru +1 -1
  63. data/test/cgi/test.fcgi +1 -0
  64. data/test/cgi/test.gz +0 -0
  65. data/test/helper.rb +31 -0
  66. data/test/multipart/filename_with_encoded_words +7 -0
  67. data/test/multipart/{filename_with_null_byte → filename_with_single_quote} +1 -1
  68. data/test/multipart/quoted +15 -0
  69. data/test/multipart/rack-logo.png +0 -0
  70. data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
  71. data/test/spec_auth_basic.rb +20 -19
  72. data/test/spec_auth_digest.rb +47 -46
  73. data/test/spec_body_proxy.rb +27 -27
  74. data/test/spec_builder.rb +51 -41
  75. data/test/spec_cascade.rb +24 -22
  76. data/test/spec_cgi.rb +49 -67
  77. data/test/spec_chunked.rb +36 -34
  78. data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
  79. data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
  80. data/test/spec_config.rb +3 -2
  81. data/test/spec_content_length.rb +18 -17
  82. data/test/spec_content_type.rb +13 -12
  83. data/test/spec_deflater.rb +66 -40
  84. data/test/spec_directory.rb +72 -27
  85. data/test/spec_etag.rb +32 -31
  86. data/test/spec_events.rb +133 -0
  87. data/test/spec_fastcgi.rb +50 -72
  88. data/test/spec_file.rb +96 -77
  89. data/test/spec_handler.rb +19 -34
  90. data/test/spec_head.rb +15 -14
  91. data/test/spec_lint.rb +162 -197
  92. data/test/spec_lobster.rb +24 -23
  93. data/test/spec_lock.rb +69 -39
  94. data/test/spec_logger.rb +4 -3
  95. data/test/spec_media_type.rb +42 -0
  96. data/test/spec_method_override.rb +83 -0
  97. data/test/spec_mime.rb +19 -19
  98. data/test/spec_mock.rb +196 -151
  99. data/test/spec_multipart.rb +310 -202
  100. data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
  101. data/test/spec_recursive.rb +17 -14
  102. data/test/spec_request.rb +763 -607
  103. data/test/spec_response.rb +209 -156
  104. data/test/spec_rewindable_input.rb +50 -40
  105. data/test/spec_runtime.rb +11 -10
  106. data/test/spec_sendfile.rb +30 -35
  107. data/test/spec_server.rb +78 -52
  108. data/test/spec_session_abstract_id.rb +11 -33
  109. data/test/spec_session_cookie.rb +97 -65
  110. data/test/spec_session_memcache.rb +63 -101
  111. data/test/spec_session_pool.rb +48 -84
  112. data/test/spec_show_exceptions.rb +80 -0
  113. data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
  114. data/test/spec_static.rb +71 -32
  115. data/test/spec_tempfile_reaper.rb +11 -10
  116. data/test/spec_thin.rb +55 -50
  117. data/test/spec_urlmap.rb +79 -78
  118. data/test/spec_utils.rb +417 -345
  119. data/test/spec_version.rb +2 -8
  120. data/test/spec_webrick.rb +77 -67
  121. data/test/static/foo.html +1 -0
  122. data/test/testrequest.rb +1 -1
  123. data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
  124. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
  125. metadata +116 -71
  126. data/KNOWN-ISSUES +0 -44
  127. data/lib/rack/backports/uri/common_18.rb +0 -56
  128. data/lib/rack/backports/uri/common_192.rb +0 -52
  129. data/lib/rack/backports/uri/common_193.rb +0 -29
  130. data/lib/rack/handler/evented_mongrel.rb +0 -8
  131. data/lib/rack/handler/mongrel.rb +0 -106
  132. data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  133. data/lib/rack/showexceptions.rb +0 -387
  134. data/lib/rack/utils/okjson.rb +0 -600
  135. data/test/spec_methodoverride.rb +0 -111
  136. data/test/spec_mongrel.rb +0 -182
  137. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  138. data/test/spec_showexceptions.rb +0 -98
@@ -1,53 +1,31 @@
1
+ require 'minitest/autorun'
1
2
  ### WARNING: there be hax in this file.
2
3
 
3
4
  require 'rack/session/abstract/id'
4
5
 
5
6
  describe Rack::Session::Abstract::ID do
6
- id = Rack::Session::Abstract::ID
7
+ attr_reader :id
7
8
 
8
- def silence_warning
9
- o, $VERBOSE = $VERBOSE, nil
10
- yield
11
- ensure
12
- $VERBOSE = o
9
+ def setup
10
+ super
11
+ @id = Rack::Session::Abstract::ID
13
12
  end
14
13
 
15
- def reload_id
16
- $".delete $".find { |part| part =~ %r{session/abstract/id.rb} }
17
- silence_warning { require 'rack/session/abstract/id' }
18
- end
19
-
20
- should "use securerandom when available" do
21
- begin
22
- fake = false
23
- silence_warning do
24
- ::SecureRandom = fake = true unless defined?(SecureRandom)
25
- end
26
- reload_id
27
- id::DEFAULT_OPTIONS[:secure_random].should.eql(fake || SecureRandom)
28
- ensure
29
- Object.send(:remove_const, :SecureRandom) if fake
30
- end
31
- end
14
+ it "use securerandom" do
15
+ assert_equal ::SecureRandom, id::DEFAULT_OPTIONS[:secure_random]
32
16
 
33
- should "not use securerandom when unavailable" do
34
- begin
35
- sr = Object.send(:remove_const, :SecureRandom) if defined?(SecureRandom)
36
- reload_id
37
- id::DEFAULT_OPTIONS[:secure_random].should.eql false
38
- ensure
39
- ::SecureRandom = sr if defined?(sr)
40
- end
17
+ id = @id.new nil
18
+ assert_equal ::SecureRandom, id.sid_secure
41
19
  end
42
20
 
43
- should "allow to use another securerandom provider" do
21
+ it "allow to use another securerandom provider" do
44
22
  secure_random = Class.new do
45
23
  def hex(*args)
46
24
  'fake_hex'
47
25
  end
48
26
  end
49
27
  id = Rack::Session::Abstract::ID.new nil, :secure_random => secure_random.new
50
- id.send(:generate_sid).should.equal 'fake_hex'
28
+ id.send(:generate_sid).must_equal 'fake_hex'
51
29
  end
52
30
 
53
31
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/session/cookie'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -10,7 +11,7 @@ describe Rack::Session::Cookie do
10
11
  hash.delete("session_id")
11
12
  Rack::Response.new(hash.inspect).to_a
12
13
  end
13
-
14
+
14
15
  session_id = lambda do |env|
15
16
  Rack::Response.new(env["rack.session"].to_hash.inspect).to_a
16
17
  end
@@ -73,31 +74,31 @@ describe Rack::Session::Cookie do
73
74
  it 'uses base64 to encode' do
74
75
  coder = Rack::Session::Cookie::Base64.new
75
76
  str = 'fuuuuu'
76
- coder.encode(str).should.equal [str].pack('m')
77
+ coder.encode(str).must_equal [str].pack('m')
77
78
  end
78
79
 
79
80
  it 'uses base64 to decode' do
80
81
  coder = Rack::Session::Cookie::Base64.new
81
82
  str = ['fuuuuu'].pack('m')
82
- coder.decode(str).should.equal str.unpack('m').first
83
+ coder.decode(str).must_equal str.unpack('m').first
83
84
  end
84
85
 
85
86
  describe 'Marshal' do
86
87
  it 'marshals and base64 encodes' do
87
88
  coder = Rack::Session::Cookie::Base64::Marshal.new
88
89
  str = 'fuuuuu'
89
- coder.encode(str).should.equal [::Marshal.dump(str)].pack('m')
90
+ coder.encode(str).must_equal [::Marshal.dump(str)].pack('m')
90
91
  end
91
92
 
92
93
  it 'marshals and base64 decodes' do
93
94
  coder = Rack::Session::Cookie::Base64::Marshal.new
94
95
  str = [::Marshal.dump('fuuuuu')].pack('m')
95
- coder.decode(str).should.equal ::Marshal.load(str.unpack('m').first)
96
+ coder.decode(str).must_equal ::Marshal.load(str.unpack('m').first)
96
97
  end
97
98
 
98
99
  it 'rescues failures on decode' do
99
100
  coder = Rack::Session::Cookie::Base64::Marshal.new
100
- coder.decode('lulz').should.equal nil
101
+ coder.decode('lulz').must_equal nil
101
102
  end
102
103
  end
103
104
 
@@ -105,18 +106,18 @@ describe Rack::Session::Cookie do
105
106
  it 'marshals and base64 encodes' do
106
107
  coder = Rack::Session::Cookie::Base64::JSON.new
107
108
  obj = %w[fuuuuu]
108
- coder.encode(obj).should.equal [::Rack::Utils::OkJson.encode(obj)].pack('m')
109
+ coder.encode(obj).must_equal [::JSON.dump(obj)].pack('m')
109
110
  end
110
111
 
111
112
  it 'marshals and base64 decodes' do
112
113
  coder = Rack::Session::Cookie::Base64::JSON.new
113
- str = [::Rack::Utils::OkJson.encode(%w[fuuuuu])].pack('m')
114
- coder.decode(str).should.equal ::Rack::Utils::OkJson.decode(str.unpack('m').first)
114
+ str = [::JSON.dump(%w[fuuuuu])].pack('m')
115
+ coder.decode(str).must_equal ::JSON.parse(str.unpack('m').first)
115
116
  end
116
117
 
117
118
  it 'rescues failures on decode' do
118
119
  coder = Rack::Session::Cookie::Base64::JSON.new
119
- coder.decode('lulz').should.equal nil
120
+ coder.decode('lulz').must_equal nil
120
121
  end
121
122
  end
122
123
 
@@ -124,31 +125,46 @@ describe Rack::Session::Cookie do
124
125
  it 'jsons, deflates, and base64 encodes' do
125
126
  coder = Rack::Session::Cookie::Base64::ZipJSON.new
126
127
  obj = %w[fuuuuu]
127
- json = Rack::Utils::OkJson.encode(obj)
128
- coder.encode(obj).should.equal [Zlib::Deflate.deflate(json)].pack('m')
128
+ json = JSON.dump(obj)
129
+ coder.encode(obj).must_equal [Zlib::Deflate.deflate(json)].pack('m')
129
130
  end
130
131
 
131
132
  it 'base64 decodes, inflates, and decodes json' do
132
133
  coder = Rack::Session::Cookie::Base64::ZipJSON.new
133
134
  obj = %w[fuuuuu]
134
- json = Rack::Utils::OkJson.encode(obj)
135
+ json = JSON.dump(obj)
135
136
  b64 = [Zlib::Deflate.deflate(json)].pack('m')
136
- coder.decode(b64).should.equal obj
137
+ coder.decode(b64).must_equal obj
137
138
  end
138
139
 
139
140
  it 'rescues failures on decode' do
140
141
  coder = Rack::Session::Cookie::Base64::ZipJSON.new
141
- coder.decode('lulz').should.equal nil
142
+ coder.decode('lulz').must_equal nil
142
143
  end
143
144
  end
144
145
  end
145
146
 
146
147
  it "warns if no secret is given" do
147
148
  Rack::Session::Cookie.new(incrementor)
148
- @warnings.first.should =~ /no secret/i
149
+ @warnings.first.must_match(/no secret/i)
149
150
  @warnings.clear
150
151
  Rack::Session::Cookie.new(incrementor, :secret => 'abc')
151
- @warnings.should.be.empty?
152
+ @warnings.must_be :empty?
153
+ end
154
+
155
+ it "doesn't warn if coder is configured to handle encoding" do
156
+ Rack::Session::Cookie.new(
157
+ incrementor,
158
+ :coder => Object.new,
159
+ :let_coder_handle_secure_encoding => true)
160
+ @warnings.must_be :empty?
161
+ end
162
+
163
+ it "still warns if coder is not set" do
164
+ Rack::Session::Cookie.new(
165
+ incrementor,
166
+ :let_coder_handle_secure_encoding => true)
167
+ @warnings.first.must_match(/no secret/i)
152
168
  end
153
169
 
154
170
  it 'uses a coder' do
@@ -164,25 +180,25 @@ describe Rack::Session::Cookie do
164
180
  }.new
165
181
  response = response_for(:app => [incrementor, { :coder => identity }])
166
182
 
167
- response["Set-Cookie"].should.include("rack.session=")
168
- response.body.should.equal '{"counter"=>1}'
169
- identity.calls.should.equal [:decode, :encode]
183
+ response["Set-Cookie"].must_include "rack.session="
184
+ response.body.must_equal '{"counter"=>1}'
185
+ identity.calls.must_equal [:decode, :encode]
170
186
  end
171
187
 
172
188
  it "creates a new cookie" do
173
189
  response = response_for(:app => incrementor)
174
- response["Set-Cookie"].should.include("rack.session=")
175
- response.body.should.equal '{"counter"=>1}'
190
+ response["Set-Cookie"].must_include "rack.session="
191
+ response.body.must_equal '{"counter"=>1}'
176
192
  end
177
193
 
178
194
  it "loads from a cookie" do
179
195
  response = response_for(:app => incrementor)
180
196
 
181
197
  response = response_for(:app => incrementor, :cookie => response)
182
- response.body.should.equal '{"counter"=>2}'
198
+ response.body.must_equal '{"counter"=>2}'
183
199
 
184
200
  response = response_for(:app => incrementor, :cookie => response)
185
- response.body.should.equal '{"counter"=>3}'
201
+ response.body.must_equal '{"counter"=>3}'
186
202
  end
187
203
 
188
204
  it "renew session id" do
@@ -191,29 +207,29 @@ describe Rack::Session::Cookie do
191
207
  response = response_for(:app => only_session_id, :cookie => cookie)
192
208
  cookie = response['Set-Cookie'] if response['Set-Cookie']
193
209
 
194
- response.body.should.not.equal ""
210
+ response.body.wont_equal ""
195
211
  old_session_id = response.body
196
212
 
197
213
  response = response_for(:app => renewer, :cookie => cookie)
198
214
  cookie = response['Set-Cookie'] if response['Set-Cookie']
199
215
  response = response_for(:app => only_session_id, :cookie => cookie)
200
216
 
201
- response.body.should.not.equal ""
202
- response.body.should.not.equal old_session_id
217
+ response.body.wont_equal ""
218
+ response.body.wont_equal old_session_id
203
219
  end
204
220
 
205
221
  it "destroys session" do
206
222
  response = response_for(:app => incrementor)
207
223
  response = response_for(:app => only_session_id, :cookie => response)
208
224
 
209
- response.body.should.not.equal ""
225
+ response.body.wont_equal ""
210
226
  old_session_id = response.body
211
227
 
212
228
  response = response_for(:app => destroy_session, :cookie => response)
213
229
  response = response_for(:app => only_session_id, :cookie => response)
214
230
 
215
- response.body.should.not.equal ""
216
- response.body.should.not.equal old_session_id
231
+ response.body.wont_equal ""
232
+ response.body.wont_equal old_session_id
217
233
  end
218
234
 
219
235
  it "survives broken cookies" do
@@ -221,19 +237,19 @@ describe Rack::Session::Cookie do
221
237
  :app => incrementor,
222
238
  :cookie => "rack.session=blarghfasel"
223
239
  )
224
- response.body.should.equal '{"counter"=>1}'
240
+ response.body.must_equal '{"counter"=>1}'
225
241
 
226
242
  response = response_for(
227
243
  :app => [incrementor, { :secret => "test" }],
228
244
  :cookie => "rack.session="
229
245
  )
230
- response.body.should.equal '{"counter"=>1}'
246
+ response.body.must_equal '{"counter"=>1}'
231
247
  end
232
248
 
233
249
  it "barks on too big cookies" do
234
250
  lambda{
235
251
  response_for(:app => bigcookie, :request => { :fatal => true })
236
- }.should.raise(Rack::MockRequest::FatalWarning)
252
+ }.must_raise Rack::MockRequest::FatalWarning
237
253
  end
238
254
 
239
255
  it "loads from a cookie with integrity hash" do
@@ -241,58 +257,74 @@ describe Rack::Session::Cookie do
241
257
 
242
258
  response = response_for(:app => app)
243
259
  response = response_for(:app => app, :cookie => response)
244
- response.body.should.equal '{"counter"=>2}'
260
+ response.body.must_equal '{"counter"=>2}'
245
261
 
246
262
  response = response_for(:app => app, :cookie => response)
247
- response.body.should.equal '{"counter"=>3}'
263
+ response.body.must_equal '{"counter"=>3}'
248
264
 
249
265
  app = [incrementor, { :secret => "other" }]
250
266
 
251
267
  response = response_for(:app => app, :cookie => response)
252
- response.body.should.equal '{"counter"=>1}'
268
+ response.body.must_equal '{"counter"=>1}'
253
269
  end
254
270
 
255
- it "loads from a cookie wih accept-only integrity hash for graceful key rotation" do
271
+ it "loads from a cookie with accept-only integrity hash for graceful key rotation" do
256
272
  response = response_for(:app => [incrementor, { :secret => "test" }])
257
273
 
258
274
  app = [incrementor, { :secret => "test2", :old_secret => "test" }]
259
275
  response = response_for(:app => app, :cookie => response)
260
- response.body.should.equal '{"counter"=>2}'
276
+ response.body.must_equal '{"counter"=>2}'
261
277
 
262
278
  app = [incrementor, { :secret => "test3", :old_secret => "test2" }]
263
279
  response = response_for(:app => app, :cookie => response)
264
- response.body.should.equal '{"counter"=>3}'
280
+ response.body.must_equal '{"counter"=>3}'
265
281
  end
266
282
 
267
283
  it "ignores tampered with session cookies" do
268
284
  app = [incrementor, { :secret => "test" }]
269
285
  response = response_for(:app => app)
270
- response.body.should.equal '{"counter"=>1}'
286
+ response.body.must_equal '{"counter"=>1}'
271
287
 
272
288
  response = response_for(:app => app, :cookie => response)
273
- response.body.should.equal '{"counter"=>2}'
289
+ response.body.must_equal '{"counter"=>2}'
274
290
 
275
291
  _, digest = response["Set-Cookie"].split("--")
276
292
  tampered_with_cookie = "hackerman-was-here" + "--" + digest
277
293
 
278
294
  response = response_for(:app => app, :cookie => tampered_with_cookie)
279
- response.body.should.equal '{"counter"=>1}'
295
+ response.body.must_equal '{"counter"=>1}'
280
296
  end
281
297
 
282
298
  it "supports either of secret or old_secret" do
283
299
  app = [incrementor, { :secret => "test" }]
284
300
  response = response_for(:app => app)
285
- response.body.should.equal '{"counter"=>1}'
301
+ response.body.must_equal '{"counter"=>1}'
286
302
 
287
303
  response = response_for(:app => app, :cookie => response)
288
- response.body.should.equal '{"counter"=>2}'
304
+ response.body.must_equal '{"counter"=>2}'
289
305
 
290
306
  app = [incrementor, { :old_secret => "test" }]
291
307
  response = response_for(:app => app)
292
- response.body.should.equal '{"counter"=>1}'
308
+ response.body.must_equal '{"counter"=>1}'
309
+
310
+ response = response_for(:app => app, :cookie => response)
311
+ response.body.must_equal '{"counter"=>2}'
312
+ end
313
+
314
+ it "supports custom digest class" do
315
+ app = [incrementor, { :secret => "test", hmac: OpenSSL::Digest::SHA256 }]
316
+
317
+ response = response_for(:app => app)
318
+ response = response_for(:app => app, :cookie => response)
319
+ response.body.must_equal '{"counter"=>2}'
320
+
321
+ response = response_for(:app => app, :cookie => response)
322
+ response.body.must_equal '{"counter"=>3}'
323
+
324
+ app = [incrementor, { :secret => "other" }]
293
325
 
294
326
  response = response_for(:app => app, :cookie => response)
295
- response.body.should.equal '{"counter"=>2}'
327
+ response.body.must_equal '{"counter"=>1}'
296
328
  end
297
329
 
298
330
  it "can handle Rack::Lint middleware" do
@@ -300,7 +332,7 @@ describe Rack::Session::Cookie do
300
332
 
301
333
  lint = Rack::Lint.new(session_id)
302
334
  response = response_for(:app => lint, :cookie => response)
303
- response.body.should.not.be.nil
335
+ response.body.wont_be :nil?
304
336
  end
305
337
 
306
338
  it "can handle middleware that inspects the env" do
@@ -318,73 +350,73 @@ describe Rack::Session::Cookie do
318
350
 
319
351
  inspector = TestEnvInspector.new(session_id)
320
352
  response = response_for(:app => inspector, :cookie => response)
321
- response.body.should.not.be.nil
353
+ response.body.wont_be :nil?
322
354
  end
323
355
 
324
356
  it "returns the session id in the session hash" do
325
357
  response = response_for(:app => incrementor)
326
- response.body.should.equal '{"counter"=>1}'
358
+ response.body.must_equal '{"counter"=>1}'
327
359
 
328
360
  response = response_for(:app => session_id, :cookie => response)
329
- response.body.should.match(/"session_id"=>/)
330
- response.body.should.match(/"counter"=>1/)
361
+ response.body.must_match(/"session_id"=>/)
362
+ response.body.must_match(/"counter"=>1/)
331
363
  end
332
364
 
333
365
  it "does not return a cookie if set to secure but not using ssl" do
334
366
  app = [incrementor, { :secure => true }]
335
367
 
336
368
  response = response_for(:app => app)
337
- response["Set-Cookie"].should.be.nil
369
+ response["Set-Cookie"].must_be_nil
338
370
 
339
371
  response = response_for(:app => app, :request => { "HTTPS" => "on" })
340
- response["Set-Cookie"].should.not.be.nil
341
- response["Set-Cookie"].should.match(/secure/)
372
+ response["Set-Cookie"].wont_be :nil?
373
+ response["Set-Cookie"].must_match(/secure/)
342
374
  end
343
375
 
344
376
  it "does not return a cookie if cookie was not read/written" do
345
377
  response = response_for(:app => nothing)
346
- response["Set-Cookie"].should.be.nil
378
+ response["Set-Cookie"].must_be_nil
347
379
  end
348
380
 
349
381
  it "does not return a cookie if cookie was not written (only read)" do
350
382
  response = response_for(:app => session_id)
351
- response["Set-Cookie"].should.be.nil
383
+ response["Set-Cookie"].must_be_nil
352
384
  end
353
385
 
354
386
  it "returns even if not read/written if :expire_after is set" do
355
387
  app = [nothing, { :expire_after => 3600 }]
356
388
  request = { "rack.session" => { "not" => "empty" }}
357
389
  response = response_for(:app => app, :request => request)
358
- response["Set-Cookie"].should.not.be.nil
390
+ response["Set-Cookie"].wont_be :nil?
359
391
  end
360
392
 
361
393
  it "returns no cookie if no data was written and no session was created previously, even if :expire_after is set" do
362
394
  app = [nothing, { :expire_after => 3600 }]
363
395
  response = response_for(:app => app)
364
- response["Set-Cookie"].should.be.nil
396
+ response["Set-Cookie"].must_be_nil
365
397
  end
366
398
 
367
399
  it "exposes :secret in env['rack.session.option']" do
368
400
  response = response_for(:app => [session_option[:secret], { :secret => "foo" }])
369
- response.body.should == '"foo"'
401
+ response.body.must_equal '"foo"'
370
402
  end
371
403
 
372
404
  it "exposes :coder in env['rack.session.option']" do
373
405
  response = response_for(:app => session_option[:coder])
374
- response.body.should.match(/Base64::Marshal/)
406
+ response.body.must_match(/Base64::Marshal/)
375
407
  end
376
408
 
377
409
  it "allows passing in a hash with session data from middleware in front" do
378
410
  request = { 'rack.session' => { :foo => 'bar' }}
379
411
  response = response_for(:app => session_id, :request => request)
380
- response.body.should.match(/foo/)
412
+ response.body.must_match(/foo/)
381
413
  end
382
414
 
383
415
  it "allows modifying session data with session data from middleware in front" do
384
416
  request = { 'rack.session' => { :foo => 'bar' }}
385
417
  response = response_for(:app => incrementor, :request => request)
386
- response.body.should.match(/counter/)
387
- response.body.should.match(/foo/)
418
+ response.body.must_match(/counter/)
419
+ response.body.must_match(/foo/)
388
420
  end
389
421
 
390
422
  it "allows more than one '--' in the cookie when calculating digests" do
@@ -403,8 +435,8 @@ describe Rack::Session::Cookie do
403
435
  }.new
404
436
  _app = [ app, { :secret => "test", :coder => unsafe_coder } ]
405
437
  response = response_for(:app => _app)
406
- response.body.should.equal "1--"
438
+ response.body.must_equal "1--"
407
439
  response = response_for(:app => _app, :cookie => response)
408
- response.body.should.equal "1--2--"
440
+ response.body.must_equal "1--2--"
409
441
  end
410
442
  end