rack 1.6.12 → 2.0.3

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 (142) hide show
  1. checksums.yaml +5 -5
  2. data/COPYING +1 -1
  3. data/HISTORY.md +138 -8
  4. data/README.rdoc +17 -25
  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 +4 -3
  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 +6 -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 -10
  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 +272 -158
  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 +383 -307
  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 +7 -5
  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 +69 -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} +22 -37
  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 +768 -607
  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_show_exceptions.rb +80 -0
  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 -68
  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 +102 -66
  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
  142. data/test/spec_showexceptions.rb +0 -98
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/lobster'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -13,46 +14,46 @@ module LobsterHelpers
13
14
  end
14
15
 
15
16
  describe Rack::Lobster::LambdaLobster do
16
- extend LobsterHelpers
17
-
18
- should "be a single lambda" do
19
- Rack::Lobster::LambdaLobster.should.be.kind_of Proc
17
+ include LobsterHelpers
18
+
19
+ it "be a single lambda" do
20
+ Rack::Lobster::LambdaLobster.must_be_kind_of Proc
20
21
  end
21
22
 
22
- should "look like a lobster" do
23
+ it "look like a lobster" do
23
24
  res = lambda_lobster.get("/")
24
- res.should.be.ok
25
- res.body.should.include "(,(,,(,,,("
26
- res.body.should.include "?flip"
25
+ res.must_be :ok?
26
+ res.body.must_include "(,(,,(,,,("
27
+ res.body.must_include "?flip"
27
28
  end
28
29
 
29
- should "be flippable" do
30
+ it "be flippable" do
30
31
  res = lambda_lobster.get("/?flip")
31
- res.should.be.ok
32
- res.body.should.include "(,,,(,,(,("
32
+ res.must_be :ok?
33
+ res.body.must_include "(,,,(,,(,("
33
34
  end
34
35
  end
35
36
 
36
37
  describe Rack::Lobster do
37
- extend LobsterHelpers
38
-
39
- should "look like a lobster" do
38
+ include LobsterHelpers
39
+
40
+ it "look like a lobster" do
40
41
  res = lobster.get("/")
41
- res.should.be.ok
42
- res.body.should.include "(,(,,(,,,("
43
- res.body.should.include "?flip"
44
- res.body.should.include "crash"
42
+ res.must_be :ok?
43
+ res.body.must_include "(,(,,(,,,("
44
+ res.body.must_include "?flip"
45
+ res.body.must_include "crash"
45
46
  end
46
47
 
47
- should "be flippable" do
48
+ it "be flippable" do
48
49
  res = lobster.get("/?flip=left")
49
- res.should.be.ok
50
- res.body.should.include "),,,),,),)"
50
+ res.must_be :ok?
51
+ res.body.must_include "),,,),,),)"
51
52
  end
52
53
 
53
- should "provide crashing for testing purposes" do
54
+ it "provide crashing for testing purposes" do
54
55
  lambda {
55
56
  lobster.get("/?flip=crash")
56
- }.should.raise
57
+ }.must_raise RuntimeError
57
58
  end
58
59
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/lint'
2
3
  require 'rack/lock'
3
4
  require 'rack/mock'
@@ -9,11 +10,6 @@ class Lock
9
10
  @synchronized = false
10
11
  end
11
12
 
12
- def synchronize
13
- @synchronized = true
14
- yield
15
- end
16
-
17
13
  def lock
18
14
  @synchronized = true
19
15
  end
@@ -35,12 +31,12 @@ module LockHelpers
35
31
  end
36
32
 
37
33
  describe Rack::Lock do
38
- extend LockHelpers
34
+ include LockHelpers
39
35
 
40
36
  describe 'Proxy' do
41
- extend LockHelpers
37
+ include LockHelpers
42
38
 
43
- should 'delegate each' do
39
+ it 'delegate each' do
44
40
  env = Rack::MockRequest.env_for("/")
45
41
  response = Class.new {
46
42
  attr_accessor :close_called
@@ -52,10 +48,10 @@ describe Rack::Lock do
52
48
  response = app.call(env)[2]
53
49
  list = []
54
50
  response.each { |x| list << x }
55
- list.should.equal %w{ hi mom }
51
+ list.must_equal %w{ hi mom }
56
52
  end
57
53
 
58
- should 'delegate to_path' do
54
+ it 'delegate to_path' do
59
55
  lock = Lock.new
60
56
  env = Rack::MockRequest.env_for("/")
61
57
 
@@ -65,11 +61,11 @@ describe Rack::Lock do
65
61
  app = Rack::Lock.new(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, res] }, lock)
66
62
  body = app.call(env)[2]
67
63
 
68
- body.should.respond_to :to_path
69
- body.to_path.should.equal "/tmp/hello.txt"
64
+ body.must_respond_to :to_path
65
+ body.to_path.must_equal "/tmp/hello.txt"
70
66
  end
71
67
 
72
- should 'not delegate to_path if body does not implement it' do
68
+ it 'not delegate to_path if body does not implement it' do
73
69
  env = Rack::MockRequest.env_for("/")
74
70
 
75
71
  res = ['Hello World']
@@ -77,11 +73,11 @@ describe Rack::Lock do
77
73
  app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, res] })
78
74
  body = app.call(env)[2]
79
75
 
80
- body.should.not.respond_to :to_path
76
+ body.wont_respond_to :to_path
81
77
  end
82
78
  end
83
79
 
84
- should 'call super on close' do
80
+ it 'call super on close' do
85
81
  env = Rack::MockRequest.env_for("/")
86
82
  response = Class.new {
87
83
  attr_accessor :close_called
@@ -91,74 +87,108 @@ describe Rack::Lock do
91
87
 
92
88
  app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, response] })
93
89
  app.call(env)
94
- response.close_called.should.equal false
90
+ response.close_called.must_equal false
95
91
  response.close
96
- response.close_called.should.equal true
92
+ response.close_called.must_equal true
97
93
  end
98
94
 
99
- should "not unlock until body is closed" do
95
+ it "not unlock until body is closed" do
100
96
  lock = Lock.new
101
97
  env = Rack::MockRequest.env_for("/")
102
98
  response = Object.new
103
99
  app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, response] }, lock)
104
- lock.synchronized.should.equal false
100
+ lock.synchronized.must_equal false
105
101
  response = app.call(env)[2]
106
- lock.synchronized.should.equal true
102
+ lock.synchronized.must_equal true
107
103
  response.close
108
- lock.synchronized.should.equal false
104
+ lock.synchronized.must_equal false
109
105
  end
110
106
 
111
- should "return value from app" do
107
+ it "return value from app" do
112
108
  env = Rack::MockRequest.env_for("/")
113
109
  body = [200, {"Content-Type" => "text/plain"}, %w{ hi mom }]
114
110
  app = lock_app(lambda { |inner_env| body })
115
111
 
116
112
  res = app.call(env)
117
- res[0].should.equal body[0]
118
- res[1].should.equal body[1]
119
- res[2].to_enum.to_a.should.equal ["hi", "mom"]
113
+ res[0].must_equal body[0]
114
+ res[1].must_equal body[1]
115
+ res[2].to_enum.to_a.must_equal ["hi", "mom"]
120
116
  end
121
117
 
122
- should "call synchronize on lock" do
118
+ it "call synchronize on lock" do
123
119
  lock = Lock.new
124
120
  env = Rack::MockRequest.env_for("/")
125
121
  app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, %w{ a b c }] }, lock)
126
- lock.synchronized.should.equal false
122
+ lock.synchronized.must_equal false
127
123
  app.call(env)
128
- lock.synchronized.should.equal true
124
+ lock.synchronized.must_equal true
129
125
  end
130
126
 
131
- should "unlock if the app raises" do
127
+ it "unlock if the app raises" do
132
128
  lock = Lock.new
133
129
  env = Rack::MockRequest.env_for("/")
134
130
  app = lock_app(lambda { raise Exception }, lock)
135
- lambda { app.call(env) }.should.raise(Exception)
136
- lock.synchronized.should.equal false
131
+ lambda { app.call(env) }.must_raise Exception
132
+ lock.synchronized.must_equal false
137
133
  end
138
134
 
139
- should "unlock if the app throws" do
135
+ it "unlock if the app throws" do
140
136
  lock = Lock.new
141
137
  env = Rack::MockRequest.env_for("/")
142
138
  app = lock_app(lambda {|_| throw :bacon }, lock)
143
- lambda { app.call(env) }.should.throw(:bacon)
144
- lock.synchronized.should.equal false
139
+ lambda { app.call(env) }.must_throw :bacon
140
+ lock.synchronized.must_equal false
145
141
  end
146
142
 
147
- should "set multithread flag to false" do
143
+ it "set multithread flag to false" do
148
144
  app = lock_app(lambda { |env|
149
- env['rack.multithread'].should.equal false
145
+ env['rack.multithread'].must_equal false
150
146
  [200, {"Content-Type" => "text/plain"}, %w{ a b c }]
151
147
  }, false)
152
- app.call(Rack::MockRequest.env_for("/"))
148
+ env = Rack::MockRequest.env_for("/")
149
+ env['rack.multithread'].must_equal true
150
+ app.call(env)
151
+ env['rack.multithread'].must_equal true
153
152
  end
154
153
 
155
- should "reset original multithread flag when exiting lock" do
154
+ it "reset original multithread flag when exiting lock" do
156
155
  app = Class.new(Rack::Lock) {
157
156
  def call(env)
158
- env['rack.multithread'].should.equal true
157
+ env['rack.multithread'].must_equal true
159
158
  super
160
159
  end
161
160
  }.new(lambda { |env| [200, {"Content-Type" => "text/plain"}, %w{ a b c }] })
162
161
  Rack::Lint.new(app).call(Rack::MockRequest.env_for("/"))
163
162
  end
163
+
164
+ it 'not unlock if an error is raised before the mutex is locked' do
165
+ lock = Class.new do
166
+ def initialize() @unlocked = false end
167
+ def unlocked?() @unlocked end
168
+ def lock() raise Exception end
169
+ def unlock() @unlocked = true end
170
+ end.new
171
+ env = Rack::MockRequest.env_for("/")
172
+ app = lock_app(proc { [200, {"Content-Type" => "text/plain"}, []] }, lock)
173
+ lambda { app.call(env) }.must_raise Exception
174
+ lock.unlocked?.must_equal false
175
+ end
176
+
177
+ it "not reset the environment while the body is proxied" do
178
+ proxy = Class.new do
179
+ attr_reader :env
180
+ def initialize(env) @env = env end
181
+ end
182
+ app = Rack::Lock.new lambda { |env| [200, {"Content-Type" => "text/plain"}, proxy.new(env)] }
183
+ response = app.call(Rack::MockRequest.env_for("/"))[2]
184
+ response.env['rack.multithread'].must_equal false
185
+ end
186
+
187
+ it "unlock if an exception occurs before returning" do
188
+ lock = Lock.new
189
+ env = Rack::MockRequest.env_for("/")
190
+ app = lock_app(proc { [].freeze }, lock)
191
+ lambda { app.call(env) }.must_raise Exception
192
+ lock.synchronized.must_equal false
193
+ end
164
194
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'stringio'
2
3
  require 'rack/lint'
3
4
  require 'rack/logger'
@@ -13,11 +14,11 @@ describe Rack::Logger do
13
14
  [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
14
15
  }
15
16
 
16
- should "conform to Rack::Lint" do
17
+ it "conform to Rack::Lint" do
17
18
  errors = StringIO.new
18
19
  a = Rack::Lint.new(Rack::Logger.new(app))
19
20
  Rack::MockRequest.new(a).get('/', 'rack.errors' => errors)
20
- errors.string.should.match(/INFO -- : Program started/)
21
- errors.string.should.match(/WARN -- : Nothing to do/)
21
+ errors.string.must_match(/INFO -- : Program started/)
22
+ errors.string.must_match(/WARN -- : Nothing to do/)
22
23
  end
23
24
  end
@@ -0,0 +1,42 @@
1
+ require 'minitest/autorun'
2
+ require 'rack/media_type'
3
+
4
+ describe Rack::MediaType do
5
+ before { @empty_hash = {} }
6
+
7
+ describe 'when content_type nil' do
8
+ before { @content_type = nil }
9
+
10
+ it '#type is nil' do
11
+ Rack::MediaType.type(@content_type).must_be_nil
12
+ end
13
+
14
+ it '#params is empty' do
15
+ Rack::MediaType.params(@content_type).must_equal @empty_hash
16
+ end
17
+ end
18
+
19
+ describe 'when content_type contains only media_type' do
20
+ before { @content_type = 'application/text' }
21
+
22
+ it '#type is application/text' do
23
+ Rack::MediaType.type(@content_type).must_equal 'application/text'
24
+ end
25
+
26
+ it '#params is empty' do
27
+ Rack::MediaType.params(@content_type).must_equal @empty_hash
28
+ end
29
+ end
30
+
31
+ describe 'when content_type contains media_type and params' do
32
+ before { @content_type = 'application/text;CHARSET="utf-8"' }
33
+
34
+ it '#type is application/text' do
35
+ Rack::MediaType.type(@content_type).must_equal 'application/text'
36
+ end
37
+
38
+ it '#params has key "charset" with value "utf-8"' do
39
+ Rack::MediaType.params(@content_type)['charset'].must_equal 'utf-8'
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,6 @@
1
+ require 'minitest/autorun'
1
2
  require 'stringio'
2
- require 'rack/methodoverride'
3
+ require 'rack/method_override'
3
4
  require 'rack/mock'
4
5
 
5
6
  describe Rack::MethodOverride do
@@ -9,70 +10,54 @@ describe Rack::MethodOverride do
9
10
  }))
10
11
  end
11
12
 
12
- should "not affect GET requests" do
13
+ it "not affect GET requests" do
13
14
  env = Rack::MockRequest.env_for("/?_method=delete", :method => "GET")
14
15
  app.call env
15
16
 
16
- env["REQUEST_METHOD"].should.equal "GET"
17
+ env["REQUEST_METHOD"].must_equal "GET"
17
18
  end
18
19
 
19
- should "modify REQUEST_METHOD for POST requests when _method parameter is set" do
20
+ it "modify REQUEST_METHOD for POST requests when _method parameter is set" do
20
21
  env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put")
21
22
  app.call env
22
23
 
23
- env["REQUEST_METHOD"].should.equal "PUT"
24
+ env["REQUEST_METHOD"].must_equal "PUT"
24
25
  end
25
26
 
26
- if RUBY_VERSION >= "1.9"
27
- should "set rack.errors for invalid UTF8 _method values" do
28
- errors = StringIO.new
29
- env = Rack::MockRequest.env_for("/",
30
- :method => "POST",
31
- :input => "_method=\xBF".force_encoding("ASCII-8BIT"),
32
- "rack.errors" => errors)
33
-
34
- app.call env
35
-
36
- errors.rewind
37
- errors.read.should.equal "Invalid string for method\n"
38
- env["REQUEST_METHOD"].should.equal "POST"
39
- end
40
- end
41
-
42
- should "modify REQUEST_METHOD for POST requests when X-HTTP-Method-Override is set" do
27
+ it "modify REQUEST_METHOD for POST requests when X-HTTP-Method-Override is set" do
43
28
  env = Rack::MockRequest.env_for("/",
44
29
  :method => "POST",
45
30
  "HTTP_X_HTTP_METHOD_OVERRIDE" => "PATCH"
46
31
  )
47
32
  app.call env
48
33
 
49
- env["REQUEST_METHOD"].should.equal "PATCH"
34
+ env["REQUEST_METHOD"].must_equal "PATCH"
50
35
  end
51
36
 
52
- should "not modify REQUEST_METHOD if the method is unknown" do
37
+ it "not modify REQUEST_METHOD if the method is unknown" do
53
38
  env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=foo")
54
39
  app.call env
55
40
 
56
- env["REQUEST_METHOD"].should.equal "POST"
41
+ env["REQUEST_METHOD"].must_equal "POST"
57
42
  end
58
43
 
59
- should "not modify REQUEST_METHOD when _method is nil" do
44
+ it "not modify REQUEST_METHOD when _method is nil" do
60
45
  env = Rack::MockRequest.env_for("/", :method => "POST", :input => "foo=bar")
61
46
  app.call env
62
47
 
63
- env["REQUEST_METHOD"].should.equal "POST"
48
+ env["REQUEST_METHOD"].must_equal "POST"
64
49
  end
65
50
 
66
- should "store the original REQUEST_METHOD prior to overriding" do
51
+ it "store the original REQUEST_METHOD prior to overriding" do
67
52
  env = Rack::MockRequest.env_for("/",
68
53
  :method => "POST",
69
54
  :input => "_method=options")
70
55
  app.call env
71
56
 
72
- env["rack.methodoverride.original_method"].should.equal "POST"
57
+ env["rack.methodoverride.original_method"].must_equal "POST"
73
58
  end
74
59
 
75
- should "not modify REQUEST_METHOD when given invalid multipart form data" do
60
+ it "not modify REQUEST_METHOD when given invalid multipart form data" do
76
61
  input = <<EOF
77
62
  --AaB03x\r
78
63
  content-disposition: form-data; name="huge"; filename="huge"\r
@@ -83,10 +68,10 @@ EOF
83
68
  :method => "POST", :input => input)
84
69
  app.call env
85
70
 
86
- env["REQUEST_METHOD"].should.equal "POST"
71
+ env["REQUEST_METHOD"].must_equal "POST"
87
72
  end
88
73
 
89
- should "write error to RACK_ERRORS when given invalid multipart form data" do
74
+ it "writes error to RACK_ERRORS when given invalid multipart form data" do
90
75
  input = <<EOF
91
76
  --AaB03x\r
92
77
  content-disposition: form-data; name="huge"; filename="huge"\r
@@ -94,18 +79,18 @@ EOF
94
79
  env = Rack::MockRequest.env_for("/",
95
80
  "CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x",
96
81
  "CONTENT_LENGTH" => input.size.to_s,
97
- "rack.errors" => StringIO.new,
82
+ Rack::RACK_ERRORS => StringIO.new,
98
83
  :method => "POST", :input => input)
99
84
  Rack::MethodOverride.new(proc { [200, {"Content-Type" => "text/plain"}, []] }).call env
100
85
 
101
- env["rack.errors"].rewind
102
- env["rack.errors"].read.should =~ /Bad request content body/
86
+ env[Rack::RACK_ERRORS].rewind
87
+ env[Rack::RACK_ERRORS].read.must_match /Bad request content body/
103
88
  end
104
89
 
105
- should "not modify REQUEST_METHOD for POST requests when the params are unparseable" do
90
+ it "not modify REQUEST_METHOD for POST requests when the params are unparseable" do
106
91
  env = Rack::MockRequest.env_for("/", :method => "POST", :input => "(%bad-params%)")
107
92
  app.call env
108
93
 
109
- env["REQUEST_METHOD"].should.equal "POST"
94
+ env["REQUEST_METHOD"].must_equal "POST"
110
95
  end
111
96
  end