rack 1.6.13 → 2.0.1

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 (144) 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 +8 -9
  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/{conditionalget.rb → conditional_get.rb} +0 -0
  18. data/lib/rack/content_length.rb +2 -2
  19. data/lib/rack/deflater.rb +4 -4
  20. data/lib/rack/directory.rb +66 -54
  21. data/lib/rack/etag.rb +4 -3
  22. data/lib/rack/events.rb +154 -0
  23. data/lib/rack/file.rb +63 -39
  24. data/lib/rack/handler/cgi.rb +15 -16
  25. data/lib/rack/handler/fastcgi.rb +13 -14
  26. data/lib/rack/handler/lsws.rb +11 -11
  27. data/lib/rack/handler/scgi.rb +15 -15
  28. data/lib/rack/handler/thin.rb +3 -0
  29. data/lib/rack/handler/webrick.rb +22 -24
  30. data/lib/rack/handler.rb +3 -25
  31. data/lib/rack/head.rb +15 -17
  32. data/lib/rack/lint.rb +38 -38
  33. data/lib/rack/lobster.rb +1 -1
  34. data/lib/rack/lock.rb +6 -10
  35. data/lib/rack/logger.rb +2 -2
  36. data/lib/rack/media_type.rb +38 -0
  37. data/lib/rack/{methodoverride.rb → method_override.rb} +4 -11
  38. data/lib/rack/mime.rb +18 -5
  39. data/lib/rack/mock.rb +35 -53
  40. data/lib/rack/multipart/generator.rb +5 -5
  41. data/lib/rack/multipart/parser.rb +272 -158
  42. data/lib/rack/multipart/uploaded_file.rb +1 -2
  43. data/lib/rack/multipart.rb +35 -6
  44. data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
  45. data/lib/rack/query_parser.rb +192 -0
  46. data/lib/rack/recursive.rb +8 -8
  47. data/lib/rack/request.rb +383 -307
  48. data/lib/rack/response.rb +129 -56
  49. data/lib/rack/rewindable_input.rb +1 -12
  50. data/lib/rack/runtime.rb +10 -18
  51. data/lib/rack/sendfile.rb +5 -7
  52. data/lib/rack/server.rb +31 -25
  53. data/lib/rack/session/abstract/id.rb +95 -135
  54. data/lib/rack/session/cookie.rb +26 -28
  55. data/lib/rack/session/memcache.rb +8 -14
  56. data/lib/rack/session/pool.rb +14 -21
  57. data/lib/rack/show_exceptions.rb +386 -0
  58. data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
  59. data/lib/rack/static.rb +30 -5
  60. data/lib/rack/tempfile_reaper.rb +2 -2
  61. data/lib/rack/urlmap.rb +15 -14
  62. data/lib/rack/utils.rb +135 -210
  63. data/lib/rack.rb +70 -21
  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_null_byte → filename_with_single_quote} +1 -1
  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 +36 -34
  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 +66 -40
  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 +107 -77
  94. data/test/spec_handler.rb +19 -34
  95. data/test/spec_head.rb +15 -14
  96. data/test/spec_lint.rb +162 -197
  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_method_override.rb +83 -0
  102. data/test/spec_mime.rb +19 -19
  103. data/test/spec_mock.rb +196 -151
  104. data/test/spec_multipart.rb +317 -201
  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 +214 -111
  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 +28 -0
  115. data/test/spec_session_cookie.rb +97 -65
  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 +91 -67
  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 +103 -69
  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_methodoverride.rb +0 -111
  142. data/test/spec_mongrel.rb +0 -182
  143. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  144. data/test/spec_showexceptions.rb +0 -98
@@ -1,4 +1,5 @@
1
- require 'rack/commonlogger'
1
+ require 'minitest/autorun'
2
+ require 'rack/common_logger'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
4
5
 
@@ -21,66 +22,67 @@ describe Rack::CommonLogger do
21
22
  {"Content-Type" => "text/html", "Content-Length" => "0"},
22
23
  []]}
23
24
 
24
- should "log to rack.errors by default" do
25
+ it "log to rack.errors by default" do
25
26
  res = Rack::MockRequest.new(Rack::CommonLogger.new(app)).get("/")
26
27
 
27
- res.errors.should.not.be.empty
28
- res.errors.should =~ /"GET \/ " 200 #{length} /
28
+ res.errors.wont_be :empty?
29
+ res.errors.must_match(/"GET \/ " 200 #{length} /)
29
30
  end
30
31
 
31
- should "log to anything with +write+" do
32
+ it "log to anything with +write+" do
32
33
  log = StringIO.new
33
34
  Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/")
34
35
 
35
- log.string.should =~ /"GET \/ " 200 #{length} /
36
+ log.string.must_match(/"GET \/ " 200 #{length} /)
36
37
  end
37
38
 
38
- should "work with standartd library logger" do
39
+ it "work with standartd library logger" do
39
40
  logdev = StringIO.new
40
41
  log = Logger.new(logdev)
41
42
  Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/")
42
43
 
43
- logdev.string.should =~ /"GET \/ " 200 #{length} /
44
+ logdev.string.must_match(/"GET \/ " 200 #{length} /)
44
45
  end
45
46
 
46
- should "log - content length if header is missing" do
47
+ it "log - content length if header is missing" do
47
48
  res = Rack::MockRequest.new(Rack::CommonLogger.new(app_without_length)).get("/")
48
49
 
49
- res.errors.should.not.be.empty
50
- res.errors.should =~ /"GET \/ " 200 - /
50
+ res.errors.wont_be :empty?
51
+ res.errors.must_match(/"GET \/ " 200 - /)
51
52
  end
52
53
 
53
- should "log - content length if header is zero" do
54
+ it "log - content length if header is zero" do
54
55
  res = Rack::MockRequest.new(Rack::CommonLogger.new(app_with_zero_length)).get("/")
55
56
 
56
- res.errors.should.not.be.empty
57
- res.errors.should =~ /"GET \/ " 200 - /
57
+ res.errors.wont_be :empty?
58
+ res.errors.must_match(/"GET \/ " 200 - /)
58
59
  end
59
60
 
60
61
  def with_mock_time(t = 0)
61
- mc = class <<Time; self; end
62
+ mc = class << Time; self; end
62
63
  mc.send :alias_method, :old_now, :now
63
64
  mc.send :define_method, :now do
64
65
  at(t)
65
66
  end
66
67
  yield
67
68
  ensure
69
+ mc.send :undef_method, :now
68
70
  mc.send :alias_method, :now, :old_now
69
71
  end
70
72
 
71
- should "log in common log format" do
73
+ it "log in common log format" do
72
74
  log = StringIO.new
73
75
  with_mock_time do
74
76
  Rack::MockRequest.new(Rack::CommonLogger.new(app, log)).get("/")
75
77
  end
76
78
 
77
79
  md = /- - - \[([^\]]+)\] "(\w+) \/ " (\d{3}) \d+ ([\d\.]+)/.match(log.string)
78
- md.should.not.equal nil
80
+ md.wont_equal nil
79
81
  time, method, status, duration = *md.captures
80
- time.should.equal Time.at(0).strftime("%d/%b/%Y:%H:%M:%S %z")
81
- method.should.equal "GET"
82
- status.should.equal "200"
83
- (0..1).should.include?(duration.to_f)
82
+ time.must_equal Time.at(0).strftime("%d/%b/%Y:%H:%M:%S %z")
83
+ method.must_equal "GET"
84
+ status.must_equal "200"
85
+ (0..1).must_include duration.to_f
84
86
  end
85
87
 
86
88
  def length
@@ -1,13 +1,14 @@
1
+ require 'minitest/autorun'
1
2
  require 'time'
2
- require 'rack/conditionalget'
3
+ require 'rack/conditional_get'
3
4
  require 'rack/mock'
4
5
 
5
6
  describe Rack::ConditionalGet do
6
7
  def conditional_get(app)
7
8
  Rack::Lint.new Rack::ConditionalGet.new(app)
8
9
  end
9
-
10
- should "set a 304 status and truncate body when If-Modified-Since hits" do
10
+
11
+ it "set a 304 status and truncate body when If-Modified-Since hits" do
11
12
  timestamp = Time.now.httpdate
12
13
  app = conditional_get(lambda { |env|
13
14
  [200, {'Last-Modified'=>timestamp}, ['TEST']] })
@@ -15,33 +16,33 @@ describe Rack::ConditionalGet do
15
16
  response = Rack::MockRequest.new(app).
16
17
  get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp)
17
18
 
18
- response.status.should.equal 304
19
- response.body.should.be.empty
19
+ response.status.must_equal 304
20
+ response.body.must_be :empty?
20
21
  end
21
22
 
22
- should "set a 304 status and truncate body when If-Modified-Since hits and is higher than current time" do
23
+ it "set a 304 status and truncate body when If-Modified-Since hits and is higher than current time" do
23
24
  app = conditional_get(lambda { |env|
24
25
  [200, {'Last-Modified'=>(Time.now - 3600).httpdate}, ['TEST']] })
25
26
 
26
27
  response = Rack::MockRequest.new(app).
27
28
  get("/", 'HTTP_IF_MODIFIED_SINCE' => Time.now.httpdate)
28
29
 
29
- response.status.should.equal 304
30
- response.body.should.be.empty
30
+ response.status.must_equal 304
31
+ response.body.must_be :empty?
31
32
  end
32
33
 
33
- should "set a 304 status and truncate body when If-None-Match hits" do
34
+ it "set a 304 status and truncate body when If-None-Match hits" do
34
35
  app = conditional_get(lambda { |env|
35
- [200, {'Etag'=>'1234'}, ['TEST']] })
36
+ [200, {'ETag'=>'1234'}, ['TEST']] })
36
37
 
37
38
  response = Rack::MockRequest.new(app).
38
39
  get("/", 'HTTP_IF_NONE_MATCH' => '1234')
39
40
 
40
- response.status.should.equal 304
41
- response.body.should.be.empty
41
+ response.status.must_equal 304
42
+ response.body.must_be :empty?
42
43
  end
43
44
 
44
- should "not set a 304 status if If-Modified-Since hits but Etag does not" do
45
+ it "not set a 304 status if If-Modified-Since hits but Etag does not" do
45
46
  timestamp = Time.now.httpdate
46
47
  app = conditional_get(lambda { |env|
47
48
  [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
@@ -49,45 +50,45 @@ describe Rack::ConditionalGet do
49
50
  response = Rack::MockRequest.new(app).
50
51
  get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp, 'HTTP_IF_NONE_MATCH' => '4321')
51
52
 
52
- response.status.should.equal 200
53
- response.body.should.equal 'TEST'
53
+ response.status.must_equal 200
54
+ response.body.must_equal 'TEST'
54
55
  end
55
56
 
56
- should "set a 304 status and truncate body when both If-None-Match and If-Modified-Since hits" do
57
+ it "set a 304 status and truncate body when both If-None-Match and If-Modified-Since hits" do
57
58
  timestamp = Time.now.httpdate
58
59
  app = conditional_get(lambda { |env|
59
- [200, {'Last-Modified'=>timestamp, 'Etag'=>'1234'}, ['TEST']] })
60
+ [200, {'Last-Modified'=>timestamp, 'ETag'=>'1234'}, ['TEST']] })
60
61
 
61
62
  response = Rack::MockRequest.new(app).
62
63
  get("/", 'HTTP_IF_MODIFIED_SINCE' => timestamp, 'HTTP_IF_NONE_MATCH' => '1234')
63
64
 
64
- response.status.should.equal 304
65
- response.body.should.be.empty
65
+ response.status.must_equal 304
66
+ response.body.must_be :empty?
66
67
  end
67
68
 
68
- should "not affect non-GET/HEAD requests" do
69
+ it "not affect non-GET/HEAD requests" do
69
70
  app = conditional_get(lambda { |env|
70
71
  [200, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
71
72
 
72
73
  response = Rack::MockRequest.new(app).
73
74
  post("/", 'HTTP_IF_NONE_MATCH' => '1234')
74
75
 
75
- response.status.should.equal 200
76
- response.body.should.equal 'TEST'
76
+ response.status.must_equal 200
77
+ response.body.must_equal 'TEST'
77
78
  end
78
79
 
79
- should "not affect non-200 requests" do
80
+ it "not affect non-200 requests" do
80
81
  app = conditional_get(lambda { |env|
81
82
  [302, {'Etag'=>'1234', 'Content-Type' => 'text/plain'}, ['TEST']] })
82
83
 
83
84
  response = Rack::MockRequest.new(app).
84
85
  get("/", 'HTTP_IF_NONE_MATCH' => '1234')
85
86
 
86
- response.status.should.equal 302
87
- response.body.should.equal 'TEST'
87
+ response.status.must_equal 302
88
+ response.body.must_equal 'TEST'
88
89
  end
89
90
 
90
- should "not affect requests with malformed HTTP_IF_NONE_MATCH" do
91
+ it "not affect requests with malformed HTTP_IF_NONE_MATCH" do
91
92
  bad_timestamp = Time.now.strftime('%Y-%m-%d %H:%M:%S %z')
92
93
  app = conditional_get(lambda { |env|
93
94
  [200,{'Last-Modified'=>(Time.now - 3600).httpdate, 'Content-Type' => 'text/plain'}, ['TEST']] })
@@ -95,8 +96,8 @@ describe Rack::ConditionalGet do
95
96
  response = Rack::MockRequest.new(app).
96
97
  get("/", 'HTTP_IF_MODIFIED_SINCE' => bad_timestamp)
97
98
 
98
- response.status.should.equal 200
99
- response.body.should.equal 'TEST'
99
+ response.status.must_equal 200
100
+ response.body.must_equal 'TEST'
100
101
  end
101
102
 
102
103
  end
data/test/spec_config.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/builder'
2
3
  require 'rack/config'
3
4
  require 'rack/content_length'
@@ -5,7 +6,7 @@ require 'rack/lint'
5
6
  require 'rack/mock'
6
7
 
7
8
  describe Rack::Config do
8
- should "accept a block that modifies the environment" do
9
+ it "accept a block that modifies the environment" do
9
10
  app = Rack::Builder.new do
10
11
  use Rack::Lint
11
12
  use Rack::Config do |env|
@@ -17,6 +18,6 @@ describe Rack::Config do
17
18
  end
18
19
 
19
20
  response = Rack::MockRequest.new(app).get('/')
20
- response.body.should.equal('hello')
21
+ response.body.must_equal 'hello'
21
22
  end
22
23
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/content_length'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -11,37 +12,37 @@ describe Rack::ContentLength do
11
12
  Rack::MockRequest.env_for
12
13
  end
13
14
 
14
- should "set Content-Length on Array bodies if none is set" do
15
+ it "set Content-Length on Array bodies if none is set" do
15
16
  app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
16
17
  response = content_length(app).call(request)
17
- response[1]['Content-Length'].should.equal '13'
18
+ response[1]['Content-Length'].must_equal '13'
18
19
  end
19
20
 
20
- should "not set Content-Length on variable length bodies" do
21
+ it "not set Content-Length on variable length bodies" do
21
22
  body = lambda { "Hello World!" }
22
23
  def body.each ; yield call ; end
23
24
 
24
25
  app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
25
26
  response = content_length(app).call(request)
26
- response[1]['Content-Length'].should.be.nil
27
+ response[1]['Content-Length'].must_be_nil
27
28
  end
28
29
 
29
- should "not change Content-Length if it is already set" do
30
+ it "not change Content-Length if it is already set" do
30
31
  app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'Content-Length' => '1'}, "Hello, World!"] }
31
32
  response = content_length(app).call(request)
32
- response[1]['Content-Length'].should.equal '1'
33
+ response[1]['Content-Length'].must_equal '1'
33
34
  end
34
35
 
35
- should "not set Content-Length on 304 responses" do
36
+ it "not set Content-Length on 304 responses" do
36
37
  app = lambda { |env| [304, {}, []] }
37
38
  response = content_length(app).call(request)
38
- response[1]['Content-Length'].should.equal nil
39
+ response[1]['Content-Length'].must_equal nil
39
40
  end
40
41
 
41
- should "not set Content-Length when Transfer-Encoding is chunked" do
42
+ it "not set Content-Length when Transfer-Encoding is chunked" do
42
43
  app = lambda { |env| [200, {'Content-Type' => 'text/plain', 'Transfer-Encoding' => 'chunked'}, []] }
43
44
  response = content_length(app).call(request)
44
- response[1]['Content-Length'].should.equal nil
45
+ response[1]['Content-Length'].must_equal nil
45
46
  end
46
47
 
47
48
  # Using "Connection: close" for this is fairly contended. It might be useful
@@ -50,10 +51,10 @@ describe Rack::ContentLength do
50
51
  # should "not force a Content-Length when Connection:close" do
51
52
  # app = lambda { |env| [200, {'Connection' => 'close'}, []] }
52
53
  # response = content_length(app).call({})
53
- # response[1]['Content-Length'].should.equal nil
54
+ # response[1]['Content-Length'].must_equal nil
54
55
  # end
55
56
 
56
- should "close bodies that need to be closed" do
57
+ it "close bodies that need to be closed" do
57
58
  body = Struct.new(:body) do
58
59
  attr_reader :closed
59
60
  def each; body.join; end
@@ -63,12 +64,12 @@ describe Rack::ContentLength do
63
64
 
64
65
  app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
65
66
  response = content_length(app).call(request)
66
- body.closed.should.equal nil
67
+ body.closed.must_equal nil
67
68
  response[2].close
68
- body.closed.should.equal true
69
+ body.closed.must_equal true
69
70
  end
70
71
 
71
- should "support single-execute bodies" do
72
+ it "support single-execute bodies" do
72
73
  body = Struct.new(:body) do
73
74
  def each
74
75
  yield body.shift until body.empty?
@@ -79,7 +80,7 @@ describe Rack::ContentLength do
79
80
  app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, body] }
80
81
  response = content_length(app).call(request)
81
82
  expected = %w[one two three]
82
- response[1]['Content-Length'].should.equal expected.join.size.to_s
83
- response[2].to_enum.to_a.should.equal expected
83
+ response[1]['Content-Length'].must_equal expected.join.size.to_s
84
+ response[2].to_enum.to_a.must_equal expected
84
85
  end
85
86
  end
@@ -1,3 +1,4 @@
1
+ require 'minitest/autorun'
1
2
  require 'rack/content_type'
2
3
  require 'rack/lint'
3
4
  require 'rack/mock'
@@ -6,40 +7,40 @@ describe Rack::ContentType do
6
7
  def content_type(app, *args)
7
8
  Rack::Lint.new Rack::ContentType.new(app, *args)
8
9
  end
9
-
10
+
10
11
  def request
11
12
  Rack::MockRequest.env_for
12
13
  end
13
-
14
- should "set Content-Type to default text/html if none is set" do
14
+
15
+ it "set Content-Type to default text/html if none is set" do
15
16
  app = lambda { |env| [200, {}, "Hello, World!"] }
16
17
  headers = content_type(app).call(request)[1]
17
- headers['Content-Type'].should.equal 'text/html'
18
+ headers['Content-Type'].must_equal 'text/html'
18
19
  end
19
20
 
20
- should "set Content-Type to chosen default if none is set" do
21
+ it "set Content-Type to chosen default if none is set" do
21
22
  app = lambda { |env| [200, {}, "Hello, World!"] }
22
23
  headers =
23
24
  content_type(app, 'application/octet-stream').call(request)[1]
24
- headers['Content-Type'].should.equal 'application/octet-stream'
25
+ headers['Content-Type'].must_equal 'application/octet-stream'
25
26
  end
26
27
 
27
- should "not change Content-Type if it is already set" do
28
+ it "not change Content-Type if it is already set" do
28
29
  app = lambda { |env| [200, {'Content-Type' => 'foo/bar'}, "Hello, World!"] }
29
30
  headers = content_type(app).call(request)[1]
30
- headers['Content-Type'].should.equal 'foo/bar'
31
+ headers['Content-Type'].must_equal 'foo/bar'
31
32
  end
32
33
 
33
- should "detect Content-Type case insensitive" do
34
+ it "detect Content-Type case insensitive" do
34
35
  app = lambda { |env| [200, {'CONTENT-Type' => 'foo/bar'}, "Hello, World!"] }
35
36
  headers = content_type(app).call(request)[1]
36
37
  headers.to_a.select { |k,v| k.downcase == "content-type" }.
37
- should.equal [["CONTENT-Type","foo/bar"]]
38
+ must_equal [["CONTENT-Type","foo/bar"]]
38
39
  end
39
40
 
40
- should "not set Content-Type on 304 responses" do
41
+ it "not set Content-Type on 304 responses" do
41
42
  app = lambda { |env| [304, {}, []] }
42
43
  response = content_type(app, "text/html").call(request)
43
- response[1]['Content-Type'].should.equal nil
44
+ response[1]['Content-Type'].must_equal nil
44
45
  end
45
46
  end