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,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"
@@ -16,18 +16,22 @@ Also see http://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
26
  s.author = 'Christian Neukirchen'
27
27
  s.email = 'chneukirchen@gmail.com'
28
28
  s.homepage = 'http://rack.github.io/'
29
- s.rubyforge_project = 'rack'
29
+ s.required_ruby_version = '>= 2.2.2'
30
30
 
31
- s.add_development_dependency 'bacon'
31
+ s.add_dependency 'json'
32
+
33
+ s.add_development_dependency 'minitest', "~> 5.0"
34
+ s.add_development_dependency 'minitest-sprint'
35
+ s.add_development_dependency 'concurrent-ruby'
32
36
  s.add_development_dependency 'rake'
33
37
  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']] }
@@ -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'
Binary file
@@ -0,0 +1,31 @@
1
+ require 'minitest/autorun'
2
+
3
+ module Rack
4
+ class TestCase < Minitest::Test
5
+ if `which lighttpd` && !$?.success?
6
+ begin
7
+ # Keep this first.
8
+ LIGHTTPD_PID = fork {
9
+ ENV['RACK_ENV'] = 'deployment'
10
+ ENV['RUBYLIB'] = [
11
+ ::File.expand_path('../../lib', __FILE__),
12
+ ENV['RUBYLIB'],
13
+ ].compact.join(':')
14
+
15
+ Dir.chdir(::File.expand_path("../cgi", __FILE__)) do
16
+ exec "lighttpd -D -f lighttpd.conf"
17
+ end
18
+ }
19
+ rescue NotImplementedError
20
+ warn "Your Ruby doesn't support Kernel#fork. Skipping Rack::Handler::CGI and ::FastCGI tests."
21
+ else
22
+ Minitest.after_run do
23
+ Process.kill 15, LIGHTTPD_PID
24
+ Process.wait LIGHTTPD_PID
25
+ end
26
+ end
27
+ else
28
+ warn "Lighttpd isn't installed. Skipping Rack::Handler::CGI and FastCGI tests. Install lighttpd to run them."
29
+ end
30
+ end
31
+ 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--
@@ -1,6 +1,6 @@
1
1
  --AaB03x
2
2
  Content-Type: image/jpeg
3
- Content-Disposition: attachment; name="files"; filename="flowers.exe%00.jpg"
3
+ Content-Disposition: attachment; name="files"; filename="bob's flowers.jpg"
4
4
  Content-Description: a complete map of the human genome
5
5
 
6
6
  contents
@@ -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--
@@ -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,50 @@ 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'
74
75
  end
75
76
  end
76
77
 
77
78
  it 'takes realm as optional constructor arg' do
78
79
  app = Rack::Auth::Basic.new(unprotected_app, realm) { true }
79
- realm.should == app.realm
80
+ realm.must_equal app.realm
80
81
  end
81
82
  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