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,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_equal 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
@@ -0,0 +1,83 @@
1
+ require 'minitest/autorun'
2
+ require 'stringio'
3
+ require 'rack/method_override'
4
+ require 'rack/mock'
5
+
6
+ describe Rack::MethodOverride do
7
+ def app
8
+ Rack::Lint.new(Rack::MethodOverride.new(lambda {|e|
9
+ [200, {"Content-Type" => "text/plain"}, []]
10
+ }))
11
+ end
12
+
13
+ it "not affect GET requests" do
14
+ env = Rack::MockRequest.env_for("/?_method=delete", :method => "GET")
15
+ app.call env
16
+
17
+ env["REQUEST_METHOD"].must_equal "GET"
18
+ end
19
+
20
+ it "modify REQUEST_METHOD for POST requests when _method parameter is set" do
21
+ env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=put")
22
+ app.call env
23
+
24
+ env["REQUEST_METHOD"].must_equal "PUT"
25
+ end
26
+
27
+ it "modify REQUEST_METHOD for POST requests when X-HTTP-Method-Override is set" do
28
+ env = Rack::MockRequest.env_for("/",
29
+ :method => "POST",
30
+ "HTTP_X_HTTP_METHOD_OVERRIDE" => "PATCH"
31
+ )
32
+ app.call env
33
+
34
+ env["REQUEST_METHOD"].must_equal "PATCH"
35
+ end
36
+
37
+ it "not modify REQUEST_METHOD if the method is unknown" do
38
+ env = Rack::MockRequest.env_for("/", :method => "POST", :input => "_method=foo")
39
+ app.call env
40
+
41
+ env["REQUEST_METHOD"].must_equal "POST"
42
+ end
43
+
44
+ it "not modify REQUEST_METHOD when _method is nil" do
45
+ env = Rack::MockRequest.env_for("/", :method => "POST", :input => "foo=bar")
46
+ app.call env
47
+
48
+ env["REQUEST_METHOD"].must_equal "POST"
49
+ end
50
+
51
+ it "store the original REQUEST_METHOD prior to overriding" do
52
+ env = Rack::MockRequest.env_for("/",
53
+ :method => "POST",
54
+ :input => "_method=options")
55
+ app.call env
56
+
57
+ env["rack.methodoverride.original_method"].must_equal "POST"
58
+ end
59
+
60
+ it "not modify REQUEST_METHOD when given invalid multipart form data" do
61
+ input = <<EOF
62
+ --AaB03x\r
63
+ content-disposition: form-data; name="huge"; filename="huge"\r
64
+ EOF
65
+ env = Rack::MockRequest.env_for("/",
66
+ "CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x",
67
+ "CONTENT_LENGTH" => input.size.to_s,
68
+ :method => "POST", :input => input)
69
+ begin
70
+ app.call env
71
+ rescue EOFError
72
+ end
73
+
74
+ env["REQUEST_METHOD"].must_equal "POST"
75
+ end
76
+
77
+ it "not modify REQUEST_METHOD for POST requests when the params are unparseable" do
78
+ env = Rack::MockRequest.env_for("/", :method => "POST", :input => "(%bad-params%)")
79
+ app.call env
80
+
81
+ env["REQUEST_METHOD"].must_equal "POST"
82
+ end
83
+ end
@@ -1,51 +1,51 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/mime'
2
3
 
3
4
  describe Rack::Mime do
4
5
 
5
6
  it "should return the fallback mime-type for files with no extension" do
6
7
  fallback = 'image/jpg'
7
- Rack::Mime.mime_type(File.extname('no_ext'), fallback).should.equal fallback
8
+ Rack::Mime.mime_type(File.extname('no_ext'), fallback).must_equal fallback
8
9
  end
9
10
 
10
11
  it "should always return 'application/octet-stream' for unknown file extensions" do
11
12
  unknown_ext = File.extname('unknown_ext.abcdefg')
12
- Rack::Mime.mime_type(unknown_ext).should.equal 'application/octet-stream'
13
+ Rack::Mime.mime_type(unknown_ext).must_equal 'application/octet-stream'
13
14
  end
14
15
 
15
16
  it "should return the mime-type for a given extension" do
16
17
  # sanity check. it would be infeasible test every single mime-type.
17
- Rack::Mime.mime_type(File.extname('image.jpg')).should.equal 'image/jpeg'
18
+ Rack::Mime.mime_type(File.extname('image.jpg')).must_equal 'image/jpeg'
18
19
  end
19
20
 
20
21
  it "should support null fallbacks" do
21
- Rack::Mime.mime_type('.nothing', nil).should.equal nil
22
+ Rack::Mime.mime_type('.nothing', nil).must_equal nil
22
23
  end
23
24
 
24
25
  it "should match exact mimes" do
25
- Rack::Mime.match?('text/html', 'text/html').should.equal true
26
- Rack::Mime.match?('text/html', 'text/meme').should.equal false
27
- Rack::Mime.match?('text', 'text').should.equal true
28
- Rack::Mime.match?('text', 'binary').should.equal false
26
+ Rack::Mime.match?('text/html', 'text/html').must_equal true
27
+ Rack::Mime.match?('text/html', 'text/meme').must_equal false
28
+ Rack::Mime.match?('text', 'text').must_equal true
29
+ Rack::Mime.match?('text', 'binary').must_equal false
29
30
  end
30
31
 
31
32
  it "should match class wildcard mimes" do
32
- Rack::Mime.match?('text/html', 'text/*').should.equal true
33
- Rack::Mime.match?('text/plain', 'text/*').should.equal true
34
- Rack::Mime.match?('application/json', 'text/*').should.equal false
35
- Rack::Mime.match?('text/html', 'text').should.equal true
33
+ Rack::Mime.match?('text/html', 'text/*').must_equal true
34
+ Rack::Mime.match?('text/plain', 'text/*').must_equal true
35
+ Rack::Mime.match?('application/json', 'text/*').must_equal false
36
+ Rack::Mime.match?('text/html', 'text').must_equal true
36
37
  end
37
38
 
38
39
  it "should match full wildcards" do
39
- Rack::Mime.match?('text/html', '*').should.equal true
40
- Rack::Mime.match?('text/plain', '*').should.equal true
41
- Rack::Mime.match?('text/html', '*/*').should.equal true
42
- Rack::Mime.match?('text/plain', '*/*').should.equal true
40
+ Rack::Mime.match?('text/html', '*').must_equal true
41
+ Rack::Mime.match?('text/plain', '*').must_equal true
42
+ Rack::Mime.match?('text/html', '*/*').must_equal true
43
+ Rack::Mime.match?('text/plain', '*/*').must_equal true
43
44
  end
44
45
 
45
46
  it "should match type wildcard mimes" do
46
- Rack::Mime.match?('text/html', '*/html').should.equal true
47
- Rack::Mime.match?('text/plain', '*/plain').should.equal true
47
+ Rack::Mime.match?('text/html', '*/html').must_equal true
48
+ Rack::Mime.match?('text/plain', '*/plain').must_equal true
48
49
  end
49
50
 
50
51
  end
51
-