rack 1.6.13 → 2.0.9

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

Potentially problematic release.


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

Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +1 -1
  3. data/HISTORY.md +138 -8
  4. data/README.rdoc +18 -28
  5. data/Rakefile +6 -14
  6. data/SPEC +3 -3
  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/auth/abstract/request.rb +5 -1
  11. data/lib/rack/auth/digest/params.rb +2 -3
  12. data/lib/rack/auth/digest/request.rb +1 -1
  13. data/lib/rack/body_proxy.rb +14 -9
  14. data/lib/rack/builder.rb +3 -3
  15. data/lib/rack/chunked.rb +5 -5
  16. data/lib/rack/{commonlogger.rb → common_logger.rb} +3 -3
  17. data/lib/rack/content_length.rb +2 -2
  18. data/lib/rack/deflater.rb +4 -39
  19. data/lib/rack/directory.rb +66 -54
  20. data/lib/rack/etag.rb +5 -4
  21. data/lib/rack/events.rb +154 -0
  22. data/lib/rack/file.rb +64 -40
  23. data/lib/rack/handler/cgi.rb +15 -16
  24. data/lib/rack/handler/fastcgi.rb +13 -14
  25. data/lib/rack/handler/lsws.rb +11 -11
  26. data/lib/rack/handler/scgi.rb +15 -15
  27. data/lib/rack/handler/thin.rb +3 -0
  28. data/lib/rack/handler/webrick.rb +24 -26
  29. data/lib/rack/handler.rb +3 -25
  30. data/lib/rack/head.rb +15 -17
  31. data/lib/rack/lint.rb +40 -40
  32. data/lib/rack/lobster.rb +1 -1
  33. data/lib/rack/lock.rb +15 -10
  34. data/lib/rack/logger.rb +2 -2
  35. data/lib/rack/media_type.rb +38 -0
  36. data/lib/rack/{methodoverride.rb → method_override.rb} +6 -6
  37. data/lib/rack/mime.rb +18 -5
  38. data/lib/rack/mock.rb +36 -54
  39. data/lib/rack/multipart/generator.rb +5 -5
  40. data/lib/rack/multipart/parser.rb +270 -157
  41. data/lib/rack/multipart/uploaded_file.rb +1 -2
  42. data/lib/rack/multipart.rb +35 -6
  43. data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
  44. data/lib/rack/query_parser.rb +192 -0
  45. data/lib/rack/recursive.rb +8 -8
  46. data/lib/rack/request.rb +394 -305
  47. data/lib/rack/response.rb +130 -57
  48. data/lib/rack/rewindable_input.rb +1 -12
  49. data/lib/rack/runtime.rb +10 -18
  50. data/lib/rack/sendfile.rb +5 -7
  51. data/lib/rack/server.rb +30 -23
  52. data/lib/rack/session/abstract/id.rb +110 -75
  53. data/lib/rack/session/cookie.rb +24 -17
  54. data/lib/rack/session/memcache.rb +9 -9
  55. data/lib/rack/session/pool.rb +8 -8
  56. data/lib/rack/show_exceptions.rb +386 -0
  57. data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
  58. data/lib/rack/static.rb +30 -5
  59. data/lib/rack/tempfile_reaper.rb +2 -2
  60. data/lib/rack/urlmap.rb +15 -14
  61. data/lib/rack/utils.rb +138 -211
  62. data/lib/rack.rb +70 -21
  63. data/rack.gemspec +10 -9
  64. data/test/builder/an_underscore_app.rb +5 -0
  65. data/test/builder/options.ru +1 -1
  66. data/test/cgi/test.fcgi +1 -0
  67. data/test/cgi/test.gz +0 -0
  68. data/test/helper.rb +34 -0
  69. data/test/multipart/filename_with_encoded_words +7 -0
  70. data/test/multipart/filename_with_single_quote +7 -0
  71. data/test/multipart/quoted +15 -0
  72. data/test/multipart/rack-logo.png +0 -0
  73. data/test/multipart/unity3d_wwwform +11 -0
  74. data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
  75. data/test/spec_auth_basic.rb +27 -19
  76. data/test/spec_auth_digest.rb +47 -46
  77. data/test/spec_body_proxy.rb +27 -27
  78. data/test/spec_builder.rb +51 -41
  79. data/test/spec_cascade.rb +24 -22
  80. data/test/spec_cgi.rb +49 -67
  81. data/test/spec_chunked.rb +37 -35
  82. data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
  83. data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
  84. data/test/spec_config.rb +3 -2
  85. data/test/spec_content_length.rb +18 -17
  86. data/test/spec_content_type.rb +13 -12
  87. data/test/spec_deflater.rb +85 -49
  88. data/test/spec_directory.rb +87 -27
  89. data/test/spec_etag.rb +32 -31
  90. data/test/spec_events.rb +133 -0
  91. data/test/spec_fastcgi.rb +50 -72
  92. data/test/spec_file.rb +120 -77
  93. data/test/spec_handler.rb +19 -34
  94. data/test/spec_head.rb +15 -14
  95. data/test/spec_lint.rb +164 -199
  96. data/test/spec_lobster.rb +24 -23
  97. data/test/spec_lock.rb +79 -39
  98. data/test/spec_logger.rb +4 -3
  99. data/test/spec_media_type.rb +42 -0
  100. data/test/{spec_methodoverride.rb → spec_method_override.rb} +34 -35
  101. data/test/spec_mime.rb +19 -19
  102. data/test/spec_mock.rb +206 -144
  103. data/test/spec_multipart.rb +322 -200
  104. data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
  105. data/test/spec_recursive.rb +17 -14
  106. data/test/spec_request.rb +780 -605
  107. data/test/spec_response.rb +233 -112
  108. data/test/spec_rewindable_input.rb +50 -40
  109. data/test/spec_runtime.rb +11 -10
  110. data/test/spec_sendfile.rb +30 -35
  111. data/test/spec_server.rb +78 -52
  112. data/test/spec_session_abstract_id.rb +11 -33
  113. data/test/spec_session_abstract_session_hash.rb +45 -0
  114. data/test/spec_session_cookie.rb +99 -67
  115. data/test/spec_session_memcache.rb +67 -68
  116. data/test/spec_session_pool.rb +52 -51
  117. data/test/{spec_showexceptions.rb → spec_show_exceptions.rb} +23 -28
  118. data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
  119. data/test/spec_static.rb +71 -32
  120. data/test/spec_tempfile_reaper.rb +11 -10
  121. data/test/spec_thin.rb +55 -50
  122. data/test/spec_urlmap.rb +79 -78
  123. data/test/spec_utils.rb +441 -346
  124. data/test/spec_version.rb +2 -8
  125. data/test/spec_webrick.rb +93 -71
  126. data/test/static/foo.html +1 -0
  127. data/test/testrequest.rb +1 -1
  128. data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
  129. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
  130. metadata +57 -36
  131. data/KNOWN-ISSUES +0 -44
  132. data/lib/rack/backports/uri/common_18.rb +0 -56
  133. data/lib/rack/backports/uri/common_192.rb +0 -52
  134. data/lib/rack/backports/uri/common_193.rb +0 -29
  135. data/lib/rack/handler/evented_mongrel.rb +0 -8
  136. data/lib/rack/handler/mongrel.rb +0 -106
  137. data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
  138. data/lib/rack/showexceptions.rb +0 -387
  139. data/lib/rack/utils/okjson.rb +0 -600
  140. data/test/spec_mongrel.rb +0 -182
  141. /data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
data/rack.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack"
3
- s.version = "1.6.13"
3
+ s.version = File.read('lib/rack.rb')[/RELEASE += +([\"\'])([\d][\w\.]+)\1/, 2]
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "a modular Ruby webserver interface"
6
6
  s.license = "MIT"
@@ -12,22 +12,23 @@ the simplest way possible, it unifies and distills the API for web
12
12
  servers, web frameworks, and software in between (the so-called
13
13
  middleware) into a single method call.
14
14
 
15
- Also see http://rack.github.io/.
15
+ Also see https://rack.github.io/.
16
16
  EOF
17
17
 
18
18
  s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*,test/**/*}'] +
19
- %w(COPYING KNOWN-ISSUES rack.gemspec Rakefile README.rdoc SPEC)
19
+ %w(COPYING rack.gemspec Rakefile README.rdoc SPEC)
20
20
  s.bindir = 'bin'
21
21
  s.executables << 'rackup'
22
22
  s.require_path = 'lib'
23
- s.extra_rdoc_files = ['README.rdoc', 'KNOWN-ISSUES', 'HISTORY.md']
23
+ s.extra_rdoc_files = ['README.rdoc', 'HISTORY.md']
24
24
  s.test_files = Dir['test/spec_*.rb']
25
25
 
26
- s.author = 'Christian Neukirchen'
27
- s.email = 'chneukirchen@gmail.com'
28
- s.homepage = 'http://rack.github.io/'
29
- s.rubyforge_project = 'rack'
26
+ s.author = 'Leah Neukirchen'
27
+ s.email = 'leah@vuxu.org'
28
+ s.homepage = 'https://rack.github.io/'
29
+ s.required_ruby_version = '>= 2.2.2'
30
30
 
31
- s.add_development_dependency 'bacon'
31
+ s.add_development_dependency 'minitest', "~> 5.0"
32
+ s.add_development_dependency 'minitest-sprint'
32
33
  s.add_development_dependency 'rake'
33
34
  end
@@ -0,0 +1,5 @@
1
+ class AnUnderscoreApp
2
+ def self.call(env)
3
+ [200, {'Content-Type' => 'text/plain'}, ['OK']]
4
+ end
5
+ end
@@ -1,2 +1,2 @@
1
- #\ -d
1
+ #\ -d -p 2929 --env test
2
2
  run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
data/test/cgi/test.fcgi CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- ruby -*-
3
3
 
4
+ require 'uri'
4
5
  $:.unshift '../../lib'
5
6
  require 'rack'
6
7
  require '../testrequest'
data/test/cgi/test.gz ADDED
Binary file
data/test/helper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'minitest/autorun'
2
+
3
+ module Rack
4
+ class TestCase < Minitest::Test
5
+ # Check for Lighttpd and launch it for tests if available.
6
+ `which lighttpd`
7
+
8
+ if $?.success?
9
+ begin
10
+ # Keep this first.
11
+ LIGHTTPD_PID = fork {
12
+ ENV['RACK_ENV'] = 'deployment'
13
+ ENV['RUBYLIB'] = [
14
+ ::File.expand_path('../../lib', __FILE__),
15
+ ENV['RUBYLIB'],
16
+ ].compact.join(':')
17
+
18
+ Dir.chdir(::File.expand_path("../cgi", __FILE__)) do
19
+ exec "lighttpd -D -f lighttpd.conf"
20
+ end
21
+ }
22
+ rescue NotImplementedError
23
+ warn "Your Ruby doesn't support Kernel#fork. Skipping Rack::Handler::CGI and ::FastCGI tests."
24
+ else
25
+ Minitest.after_run do
26
+ Process.kill 15, LIGHTTPD_PID
27
+ Process.wait LIGHTTPD_PID
28
+ end
29
+ end
30
+ else
31
+ warn "Lighttpd isn't installed. Skipping Rack::Handler::CGI and FastCGI tests. Install lighttpd to run them."
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ --AaB03x
2
+ Content-Type: image/jpeg
3
+ Content-Disposition: attachment; name="files"; filename*=utf-8''%D1%84%D0%B0%D0%B9%D0%BB
4
+ Content-Description: a complete map of the human genome
5
+
6
+ contents
7
+ --AaB03x--
@@ -0,0 +1,7 @@
1
+ --AaB03x
2
+ Content-Type: image/jpeg
3
+ Content-Disposition: attachment; name="files"; filename="bob's flowers.jpg"
4
+ Content-Description: a complete map of the human genome
5
+
6
+ contents
7
+ --AaB03x--
@@ -0,0 +1,15 @@
1
+ --AaB:03x
2
+ Content-Disposition: form-data; name="submit-name"
3
+
4
+ Larry
5
+ --AaB:03x
6
+ Content-Disposition: form-data; name="submit-name-with-content"
7
+ Content-Type: text/plain
8
+
9
+ Berry
10
+ --AaB:03x
11
+ Content-Disposition: form-data; name="files"; filename="file1.txt"
12
+ Content-Type: text/plain
13
+
14
+ contents
15
+ --AaB:03x--
Binary file
@@ -0,0 +1,11 @@
1
+ --AaB03x
2
+ Content-Type: text/plain; charset="utf-8"
3
+ Content-disposition: form-data; name="user_sid"
4
+
5
+ bbf14f82-d2aa-4c07-9fb8-ca6714a7ea97
6
+ --AaB03x
7
+ Content-Type: image/png; charset=UTF-8
8
+ Content-disposition: form-data; name="file";
9
+ filename="b67879ed-bfed-4491-a8cc-f99cca769f94.png"
10
+
11
+ --AaB03x
@@ -5,4 +5,4 @@ module Rack
5
5
 
6
6
  register :registering_myself, RegisteringMyself
7
7
  end
8
- end
8
+ end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/auth/basic'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -32,50 +33,57 @@ describe Rack::Auth::Basic do
32
33
  end
33
34
 
34
35
  def assert_basic_auth_challenge(response)
35
- response.should.be.a.client_error
36
- response.status.should.equal 401
37
- response.should.include 'WWW-Authenticate'
38
- response.headers['WWW-Authenticate'].should =~ /Basic realm="#{Regexp.escape(realm)}"/
39
- response.body.should.be.empty
36
+ response.must_be :client_error?
37
+ response.status.must_equal 401
38
+ response.must_include 'WWW-Authenticate'
39
+ response.headers['WWW-Authenticate'].must_match(/Basic realm="#{Regexp.escape(realm)}"/)
40
+ response.body.must_be :empty?
40
41
  end
41
42
 
42
- should 'challenge correctly when no credentials are specified' do
43
+ it 'challenge correctly when no credentials are specified' do
43
44
  request do |response|
44
45
  assert_basic_auth_challenge response
45
46
  end
46
47
  end
47
48
 
48
- should 'rechallenge if incorrect credentials are specified' do
49
+ it 'rechallenge if incorrect credentials are specified' do
49
50
  request_with_basic_auth 'joe', 'password' do |response|
50
51
  assert_basic_auth_challenge response
51
52
  end
52
53
  end
53
54
 
54
- should 'return application output if correct credentials are specified' do
55
+ it 'return application output if correct credentials are specified' do
55
56
  request_with_basic_auth 'Boss', 'password' do |response|
56
- response.status.should.equal 200
57
- response.body.to_s.should.equal 'Hi Boss'
57
+ response.status.must_equal 200
58
+ response.body.to_s.must_equal 'Hi Boss'
58
59
  end
59
60
  end
60
61
 
61
- should 'return 400 Bad Request if different auth scheme used' do
62
+ it 'return 400 Bad Request if different auth scheme used' do
62
63
  request 'HTTP_AUTHORIZATION' => 'Digest params' do |response|
63
- response.should.be.a.client_error
64
- response.status.should.equal 400
65
- response.should.not.include 'WWW-Authenticate'
64
+ response.must_be :client_error?
65
+ response.status.must_equal 400
66
+ response.wont_include 'WWW-Authenticate'
66
67
  end
67
68
  end
68
69
 
69
- should 'return 400 Bad Request for a malformed authorization header' do
70
+ it 'return 400 Bad Request for a malformed authorization header' do
70
71
  request 'HTTP_AUTHORIZATION' => '' do |response|
71
- response.should.be.a.client_error
72
- response.status.should.equal 400
73
- response.should.not.include 'WWW-Authenticate'
72
+ response.must_be :client_error?
73
+ response.status.must_equal 400
74
+ response.wont_include 'WWW-Authenticate'
75
+ end
76
+ end
77
+
78
+ it 'return 401 Bad Request for a nil authorization header' do
79
+ request 'HTTP_AUTHORIZATION' => nil do |response|
80
+ response.must_be :client_error?
81
+ response.status.must_equal 401
74
82
  end
75
83
  end
76
84
 
77
85
  it 'takes realm as optional constructor arg' do
78
86
  app = Rack::Auth::Basic.new(unprotected_app, realm) { true }
79
- realm.should == app.realm
87
+ realm.must_equal app.realm
80
88
  end
81
89
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/auth/digest/md5'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -100,160 +101,160 @@ describe Rack::Auth::Digest::MD5 do
100
101
  end
101
102
 
102
103
  def assert_digest_auth_challenge(response)
103
- response.should.be.a.client_error
104
- response.status.should.equal 401
105
- response.should.include 'WWW-Authenticate'
106
- response.headers['WWW-Authenticate'].should =~ /^Digest /
107
- response.body.should.be.empty
104
+ response.must_be :client_error?
105
+ response.status.must_equal 401
106
+ response.must_include 'WWW-Authenticate'
107
+ response.headers['WWW-Authenticate'].must_match(/^Digest /)
108
+ response.body.must_be :empty?
108
109
  end
109
110
 
110
111
  def assert_bad_request(response)
111
- response.should.be.a.client_error
112
- response.status.should.equal 400
113
- response.should.not.include 'WWW-Authenticate'
112
+ response.must_be :client_error?
113
+ response.status.must_equal 400
114
+ response.wont_include 'WWW-Authenticate'
114
115
  end
115
116
 
116
- should 'challenge when no credentials are specified' do
117
+ it 'challenge when no credentials are specified' do
117
118
  request 'GET', '/' do |response|
118
119
  assert_digest_auth_challenge response
119
120
  end
120
121
  end
121
122
 
122
- should 'return application output if correct credentials given' do
123
+ it 'return application output if correct credentials given' do
123
124
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
124
- response.status.should.equal 200
125
- response.body.to_s.should.equal 'Hi Alice'
125
+ response.status.must_equal 200
126
+ response.body.to_s.must_equal 'Hi Alice'
126
127
  end
127
128
  end
128
129
 
129
- should 'return application output if correct credentials given (hashed passwords)' do
130
+ it 'return application output if correct credentials given (hashed passwords)' do
130
131
  @request = Rack::MockRequest.new(protected_app_with_hashed_passwords)
131
132
 
132
133
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password' do |response|
133
- response.status.should.equal 200
134
- response.body.to_s.should.equal 'Hi Alice'
134
+ response.status.must_equal 200
135
+ response.body.to_s.must_equal 'Hi Alice'
135
136
  end
136
137
  end
137
138
 
138
- should 'rechallenge if incorrect username given' do
139
+ it 'rechallenge if incorrect username given' do
139
140
  request_with_digest_auth 'GET', '/', 'Bob', 'correct-password' do |response|
140
141
  assert_digest_auth_challenge response
141
142
  end
142
143
  end
143
144
 
144
- should 'rechallenge if incorrect password given' do
145
+ it 'rechallenge if incorrect password given' do
145
146
  request_with_digest_auth 'GET', '/', 'Alice', 'wrong-password' do |response|
146
147
  assert_digest_auth_challenge response
147
148
  end
148
149
  end
149
150
 
150
- should 'rechallenge if incorrect user and blank password given' do
151
+ it 'rechallenge if incorrect user and blank password given' do
151
152
  request_with_digest_auth 'GET', '/', 'Bob', '' do |response|
152
153
  assert_digest_auth_challenge response
153
154
  end
154
155
  end
155
156
 
156
- should 'not rechallenge if nonce is not stale' do
157
+ it 'not rechallenge if nonce is not stale' do
157
158
  begin
158
159
  Rack::Auth::Digest::Nonce.time_limit = 10
159
160
 
160
161
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', :wait => 1 do |response|
161
- response.status.should.equal 200
162
- response.body.to_s.should.equal 'Hi Alice'
163
- response.headers['WWW-Authenticate'].should.not =~ /\bstale=true\b/
162
+ response.status.must_equal 200
163
+ response.body.to_s.must_equal 'Hi Alice'
164
+ response.headers['WWW-Authenticate'].wont_match(/\bstale=true\b/)
164
165
  end
165
166
  ensure
166
167
  Rack::Auth::Digest::Nonce.time_limit = nil
167
168
  end
168
169
  end
169
170
 
170
- should 'rechallenge with stale parameter if nonce is stale' do
171
+ it 'rechallenge with stale parameter if nonce is stale' do
171
172
  begin
172
173
  Rack::Auth::Digest::Nonce.time_limit = 1
173
174
 
174
175
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', :wait => 2 do |response|
175
176
  assert_digest_auth_challenge response
176
- response.headers['WWW-Authenticate'].should =~ /\bstale=true\b/
177
+ response.headers['WWW-Authenticate'].must_match(/\bstale=true\b/)
177
178
  end
178
179
  ensure
179
180
  Rack::Auth::Digest::Nonce.time_limit = nil
180
181
  end
181
182
  end
182
183
 
183
- should 'return 400 Bad Request if incorrect qop given' do
184
+ it 'return 400 Bad Request if incorrect qop given' do
184
185
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'qop' => 'auth-int' do |response|
185
186
  assert_bad_request response
186
187
  end
187
188
  end
188
189
 
189
- should 'return 400 Bad Request if incorrect uri given' do
190
+ it 'return 400 Bad Request if incorrect uri given' do
190
191
  request_with_digest_auth 'GET', '/', 'Alice', 'correct-password', 'uri' => '/foo' do |response|
191
192
  assert_bad_request response
192
193
  end
193
194
  end
194
195
 
195
- should 'return 400 Bad Request if different auth scheme used' do
196
+ it 'return 400 Bad Request if different auth scheme used' do
196
197
  request 'GET', '/', 'HTTP_AUTHORIZATION' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' do |response|
197
198
  assert_bad_request response
198
199
  end
199
200
  end
200
201
 
201
- should 'not require credentials for unprotected path' do
202
+ it 'not require credentials for unprotected path' do
202
203
  @request = Rack::MockRequest.new(partially_protected_app)
203
204
  request 'GET', '/' do |response|
204
- response.should.be.ok
205
+ response.must_be :ok?
205
206
  end
206
207
  end
207
208
 
208
- should 'challenge when no credentials are specified for protected path' do
209
+ it 'challenge when no credentials are specified for protected path' do
209
210
  @request = Rack::MockRequest.new(partially_protected_app)
210
211
  request 'GET', '/protected' do |response|
211
212
  assert_digest_auth_challenge response
212
213
  end
213
214
  end
214
215
 
215
- should 'return application output if correct credentials given for protected path' do
216
+ it 'return application output if correct credentials given for protected path' do
216
217
  @request = Rack::MockRequest.new(partially_protected_app)
217
218
  request_with_digest_auth 'GET', '/protected', 'Alice', 'correct-password' do |response|
218
- response.status.should.equal 200
219
- response.body.to_s.should.equal 'Hi Alice'
219
+ response.status.must_equal 200
220
+ response.body.to_s.must_equal 'Hi Alice'
220
221
  end
221
222
  end
222
223
 
223
- should 'return application output when used with a query string and path as uri' do
224
+ it 'return application output when used with a query string and path as uri' do
224
225
  @request = Rack::MockRequest.new(partially_protected_app)
225
226
  request_with_digest_auth 'GET', '/protected?friend=Mike', 'Alice', 'correct-password' do |response|
226
- response.status.should.equal 200
227
- response.body.to_s.should.equal 'Hi Alice and Mike'
227
+ response.status.must_equal 200
228
+ response.body.to_s.must_equal 'Hi Alice and Mike'
228
229
  end
229
230
  end
230
231
 
231
- should 'return application output when used with a query string and fullpath as uri' do
232
+ it 'return application output when used with a query string and fullpath as uri' do
232
233
  @request = Rack::MockRequest.new(partially_protected_app)
233
234
  qs_uri = '/protected?friend=Mike'
234
235
  request_with_digest_auth 'GET', qs_uri, 'Alice', 'correct-password', 'uri' => qs_uri do |response|
235
- response.status.should.equal 200
236
- response.body.to_s.should.equal 'Hi Alice and Mike'
236
+ response.status.must_equal 200
237
+ response.body.to_s.must_equal 'Hi Alice and Mike'
237
238
  end
238
239
  end
239
240
 
240
- should 'return application output if correct credentials given for POST' do
241
+ it 'return application output if correct credentials given for POST' do
241
242
  request_with_digest_auth 'POST', '/', 'Alice', 'correct-password' do |response|
242
- response.status.should.equal 200
243
- response.body.to_s.should.equal 'Hi Alice'
243
+ response.status.must_equal 200
244
+ response.body.to_s.must_equal 'Hi Alice'
244
245
  end
245
246
  end
246
247
 
247
- should 'return application output if correct credentials given for PUT (using method override of POST)' do
248
+ it 'return application output if correct credentials given for PUT (using method override of POST)' do
248
249
  @request = Rack::MockRequest.new(protected_app_with_method_override)
249
250
  request_with_digest_auth 'POST', '/', 'Alice', 'correct-password', :input => "_method=put" do |response|
250
- response.status.should.equal 200
251
- response.body.to_s.should.equal 'Hi Alice'
251
+ response.status.must_equal 200
252
+ response.body.to_s.must_equal 'Hi Alice'
252
253
  end
253
254
  end
254
255
 
255
256
  it 'takes realm as optional constructor arg' do
256
257
  app = Rack::Auth::Digest::MD5.new(unprotected_app, realm) { true }
257
- realm.should == app.realm
258
+ realm.must_equal app.realm
258
259
  end
259
260
  end
@@ -1,85 +1,85 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/body_proxy'
2
3
  require 'stringio'
3
- require 'ostruct'
4
4
 
5
5
  describe Rack::BodyProxy do
6
- should 'call each on the wrapped body' do
6
+ it 'call each on the wrapped body' do
7
7
  called = false
8
8
  proxy = Rack::BodyProxy.new(['foo']) { }
9
9
  proxy.each do |str|
10
10
  called = true
11
- str.should.equal 'foo'
11
+ str.must_equal 'foo'
12
12
  end
13
- called.should.equal true
13
+ called.must_equal true
14
14
  end
15
15
 
16
- should 'call close on the wrapped body' do
16
+ it 'call close on the wrapped body' do
17
17
  body = StringIO.new
18
18
  proxy = Rack::BodyProxy.new(body) { }
19
19
  proxy.close
20
- body.should.be.closed
20
+ body.must_be :closed?
21
21
  end
22
22
 
23
- should 'only call close on the wrapped body if it responds to close' do
23
+ it 'only call close on the wrapped body if it responds to close' do
24
24
  body = []
25
25
  proxy = Rack::BodyProxy.new(body) { }
26
- proc { proxy.close }.should.not.raise
26
+ proxy.close.must_be_nil
27
27
  end
28
28
 
29
- should 'call the passed block on close' do
29
+ it 'call the passed block on close' do
30
30
  called = false
31
31
  proxy = Rack::BodyProxy.new([]) { called = true }
32
- called.should.equal false
32
+ called.must_equal false
33
33
  proxy.close
34
- called.should.equal true
34
+ called.must_equal true
35
35
  end
36
36
 
37
- should 'call the passed block on close even if there is an exception' do
37
+ it 'call the passed block on close even if there is an exception' do
38
38
  object = Object.new
39
39
  def object.close() raise "No!" end
40
40
  called = false
41
41
 
42
42
  begin
43
43
  proxy = Rack::BodyProxy.new(object) { called = true }
44
- called.should.equal false
44
+ called.must_equal false
45
45
  proxy.close
46
46
  rescue RuntimeError => e
47
47
  end
48
48
 
49
49
  raise "Expected exception to have been raised" unless e
50
- called.should.equal true
50
+ called.must_equal true
51
51
  end
52
52
 
53
- should 'allow multiple arguments in respond_to?' do
53
+ it 'allow multiple arguments in respond_to?' do
54
54
  body = []
55
55
  proxy = Rack::BodyProxy.new(body) { }
56
- proc { proxy.respond_to?(:foo, false) }.should.not.raise
56
+ proxy.respond_to?(:foo, false).must_equal false
57
57
  end
58
58
 
59
- should 'not respond to :to_ary' do
60
- body = OpenStruct.new(:to_ary => true)
61
- body.respond_to?(:to_ary).should.equal true
59
+ it 'not respond to :to_ary' do
60
+ body = Object.new.tap { |o| def o.to_ary() end }
61
+ body.respond_to?(:to_ary).must_equal true
62
62
 
63
63
  proxy = Rack::BodyProxy.new(body) { }
64
- proxy.respond_to?(:to_ary).should.equal false
65
- proxy.respond_to?("to_ary").should.equal false
64
+ proxy.respond_to?(:to_ary).must_equal false
65
+ proxy.respond_to?("to_ary").must_equal false
66
66
  end
67
67
 
68
- should 'not close more than one time' do
68
+ it 'not close more than one time' do
69
69
  count = 0
70
70
  proxy = Rack::BodyProxy.new([]) { count += 1; raise "Block invoked more than 1 time!" if count > 1 }
71
71
  2.times { proxy.close }
72
- count.should.equal 1
72
+ count.must_equal 1
73
73
  end
74
74
 
75
- should 'be closed when the callback is triggered' do
75
+ it 'be closed when the callback is triggered' do
76
76
  closed = false
77
77
  proxy = Rack::BodyProxy.new([]) { closed = proxy.closed? }
78
78
  proxy.close
79
- closed.should.equal true
79
+ closed.must_equal true
80
80
  end
81
81
 
82
- should 'provide an #each method' do
83
- Rack::BodyProxy.method_defined?(:each).should.equal true
82
+ it 'provide an #each method' do
83
+ Rack::BodyProxy.method_defined?(:each).must_equal true
84
84
  end
85
85
  end