http 5.3.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +241 -41
  3. data/LICENSE.txt +1 -1
  4. data/README.md +110 -13
  5. data/UPGRADING.md +491 -0
  6. data/http.gemspec +32 -29
  7. data/lib/http/base64.rb +11 -1
  8. data/lib/http/chainable/helpers.rb +62 -0
  9. data/lib/http/chainable/verbs.rb +136 -0
  10. data/lib/http/chainable.rb +232 -136
  11. data/lib/http/client.rb +158 -127
  12. data/lib/http/connection/internals.rb +141 -0
  13. data/lib/http/connection.rb +126 -97
  14. data/lib/http/content_type.rb +61 -6
  15. data/lib/http/errors.rb +25 -1
  16. data/lib/http/feature.rb +65 -5
  17. data/lib/http/features/auto_deflate.rb +124 -17
  18. data/lib/http/features/auto_inflate.rb +38 -15
  19. data/lib/http/features/caching/entry.rb +178 -0
  20. data/lib/http/features/caching/in_memory_store.rb +63 -0
  21. data/lib/http/features/caching.rb +216 -0
  22. data/lib/http/features/digest_auth.rb +234 -0
  23. data/lib/http/features/instrumentation.rb +97 -17
  24. data/lib/http/features/logging.rb +183 -5
  25. data/lib/http/features/normalize_uri.rb +17 -0
  26. data/lib/http/features/raise_error.rb +18 -3
  27. data/lib/http/form_data/composite_io.rb +106 -0
  28. data/lib/http/form_data/file.rb +95 -0
  29. data/lib/http/form_data/multipart/param.rb +62 -0
  30. data/lib/http/form_data/multipart.rb +106 -0
  31. data/lib/http/form_data/part.rb +52 -0
  32. data/lib/http/form_data/readable.rb +58 -0
  33. data/lib/http/form_data/urlencoded.rb +175 -0
  34. data/lib/http/form_data/version.rb +8 -0
  35. data/lib/http/form_data.rb +102 -0
  36. data/lib/http/headers/known.rb +3 -0
  37. data/lib/http/headers/normalizer.rb +17 -36
  38. data/lib/http/headers.rb +172 -65
  39. data/lib/http/mime_type/adapter.rb +24 -9
  40. data/lib/http/mime_type/json.rb +19 -4
  41. data/lib/http/mime_type.rb +21 -3
  42. data/lib/http/options/definitions.rb +189 -0
  43. data/lib/http/options.rb +172 -125
  44. data/lib/http/redirector.rb +80 -75
  45. data/lib/http/request/body.rb +87 -6
  46. data/lib/http/request/builder.rb +184 -0
  47. data/lib/http/request/proxy.rb +83 -0
  48. data/lib/http/request/writer.rb +76 -16
  49. data/lib/http/request.rb +214 -98
  50. data/lib/http/response/body.rb +103 -18
  51. data/lib/http/response/inflater.rb +35 -7
  52. data/lib/http/response/parser.rb +98 -4
  53. data/lib/http/response/status/reasons.rb +2 -4
  54. data/lib/http/response/status.rb +141 -31
  55. data/lib/http/response.rb +219 -61
  56. data/lib/http/retriable/delay_calculator.rb +38 -11
  57. data/lib/http/retriable/errors.rb +21 -0
  58. data/lib/http/retriable/performer.rb +82 -38
  59. data/lib/http/session.rb +280 -0
  60. data/lib/http/timeout/global.rb +147 -34
  61. data/lib/http/timeout/null.rb +155 -9
  62. data/lib/http/timeout/per_operation.rb +139 -18
  63. data/lib/http/uri/normalizer.rb +82 -0
  64. data/lib/http/uri/parsing.rb +182 -0
  65. data/lib/http/uri.rb +289 -124
  66. data/lib/http/version.rb +2 -1
  67. data/lib/http.rb +11 -2
  68. data/sig/deps.rbs +122 -0
  69. data/sig/http.rbs +1619 -0
  70. data/test/http/base64_test.rb +28 -0
  71. data/test/http/client_test.rb +739 -0
  72. data/test/http/connection_test.rb +1533 -0
  73. data/test/http/content_type_test.rb +190 -0
  74. data/test/http/errors_test.rb +28 -0
  75. data/test/http/feature_test.rb +49 -0
  76. data/test/http/features/auto_deflate_test.rb +317 -0
  77. data/test/http/features/auto_inflate_test.rb +213 -0
  78. data/test/http/features/caching_test.rb +942 -0
  79. data/test/http/features/digest_auth_test.rb +996 -0
  80. data/test/http/features/instrumentation_test.rb +246 -0
  81. data/test/http/features/logging_test.rb +654 -0
  82. data/test/http/features/normalize_uri_test.rb +41 -0
  83. data/test/http/features/raise_error_test.rb +77 -0
  84. data/test/http/form_data/composite_io_test.rb +215 -0
  85. data/test/http/form_data/file_test.rb +255 -0
  86. data/test/http/form_data/fixtures/the-http-gem.info +1 -0
  87. data/test/http/form_data/multipart_test.rb +303 -0
  88. data/test/http/form_data/part_test.rb +90 -0
  89. data/test/http/form_data/urlencoded_test.rb +164 -0
  90. data/test/http/form_data_test.rb +232 -0
  91. data/test/http/headers/normalizer_test.rb +93 -0
  92. data/test/http/headers_test.rb +888 -0
  93. data/test/http/mime_type/json_test.rb +39 -0
  94. data/test/http/mime_type_test.rb +150 -0
  95. data/test/http/options/base_uri_test.rb +148 -0
  96. data/test/http/options/body_test.rb +21 -0
  97. data/test/http/options/features_test.rb +38 -0
  98. data/test/http/options/form_test.rb +21 -0
  99. data/test/http/options/headers_test.rb +32 -0
  100. data/test/http/options/json_test.rb +21 -0
  101. data/test/http/options/merge_test.rb +78 -0
  102. data/test/http/options/new_test.rb +37 -0
  103. data/test/http/options/proxy_test.rb +32 -0
  104. data/test/http/options_test.rb +575 -0
  105. data/test/http/redirector_test.rb +639 -0
  106. data/test/http/request/body_test.rb +318 -0
  107. data/test/http/request/builder_test.rb +623 -0
  108. data/test/http/request/writer_test.rb +391 -0
  109. data/test/http/request_test.rb +1733 -0
  110. data/test/http/response/body_test.rb +292 -0
  111. data/test/http/response/parser_test.rb +105 -0
  112. data/test/http/response/status_test.rb +322 -0
  113. data/test/http/response_test.rb +502 -0
  114. data/test/http/retriable/delay_calculator_test.rb +194 -0
  115. data/test/http/retriable/errors_test.rb +71 -0
  116. data/test/http/retriable/performer_test.rb +551 -0
  117. data/test/http/session_test.rb +424 -0
  118. data/test/http/timeout/global_test.rb +239 -0
  119. data/test/http/timeout/null_test.rb +218 -0
  120. data/test/http/timeout/per_operation_test.rb +220 -0
  121. data/test/http/uri/normalizer_test.rb +89 -0
  122. data/test/http/uri_test.rb +1140 -0
  123. data/test/http/version_test.rb +15 -0
  124. data/test/http_test.rb +818 -0
  125. data/test/regression_tests.rb +27 -0
  126. data/test/support/dummy_server/encoding_routes.rb +47 -0
  127. data/test/support/dummy_server/routes.rb +201 -0
  128. data/test/support/dummy_server/servlet.rb +81 -0
  129. data/test/support/dummy_server.rb +200 -0
  130. data/{spec → test}/support/fakeio.rb +2 -2
  131. data/test/support/http_handling_shared/connection_reuse_tests.rb +97 -0
  132. data/test/support/http_handling_shared/timeout_tests.rb +134 -0
  133. data/test/support/http_handling_shared.rb +11 -0
  134. data/test/support/proxy_server.rb +207 -0
  135. data/test/support/servers/runner.rb +67 -0
  136. data/{spec → test}/support/simplecov.rb +11 -2
  137. data/test/support/ssl_helper.rb +108 -0
  138. data/test/test_helper.rb +38 -0
  139. metadata +108 -168
  140. data/.github/workflows/ci.yml +0 -67
  141. data/.gitignore +0 -15
  142. data/.rspec +0 -1
  143. data/.rubocop/layout.yml +0 -8
  144. data/.rubocop/metrics.yml +0 -4
  145. data/.rubocop/rspec.yml +0 -9
  146. data/.rubocop/style.yml +0 -32
  147. data/.rubocop.yml +0 -11
  148. data/.rubocop_todo.yml +0 -219
  149. data/.yardopts +0 -2
  150. data/CHANGES_OLD.md +0 -1002
  151. data/Gemfile +0 -51
  152. data/Guardfile +0 -18
  153. data/Rakefile +0 -64
  154. data/lib/http/headers/mixin.rb +0 -34
  155. data/lib/http/retriable/client.rb +0 -37
  156. data/logo.png +0 -0
  157. data/spec/lib/http/client_spec.rb +0 -556
  158. data/spec/lib/http/connection_spec.rb +0 -88
  159. data/spec/lib/http/content_type_spec.rb +0 -47
  160. data/spec/lib/http/features/auto_deflate_spec.rb +0 -77
  161. data/spec/lib/http/features/auto_inflate_spec.rb +0 -86
  162. data/spec/lib/http/features/instrumentation_spec.rb +0 -81
  163. data/spec/lib/http/features/logging_spec.rb +0 -65
  164. data/spec/lib/http/features/raise_error_spec.rb +0 -62
  165. data/spec/lib/http/headers/mixin_spec.rb +0 -36
  166. data/spec/lib/http/headers/normalizer_spec.rb +0 -52
  167. data/spec/lib/http/headers_spec.rb +0 -527
  168. data/spec/lib/http/options/body_spec.rb +0 -15
  169. data/spec/lib/http/options/features_spec.rb +0 -33
  170. data/spec/lib/http/options/form_spec.rb +0 -15
  171. data/spec/lib/http/options/headers_spec.rb +0 -24
  172. data/spec/lib/http/options/json_spec.rb +0 -15
  173. data/spec/lib/http/options/merge_spec.rb +0 -68
  174. data/spec/lib/http/options/new_spec.rb +0 -30
  175. data/spec/lib/http/options/proxy_spec.rb +0 -20
  176. data/spec/lib/http/options_spec.rb +0 -13
  177. data/spec/lib/http/redirector_spec.rb +0 -530
  178. data/spec/lib/http/request/body_spec.rb +0 -211
  179. data/spec/lib/http/request/writer_spec.rb +0 -121
  180. data/spec/lib/http/request_spec.rb +0 -234
  181. data/spec/lib/http/response/body_spec.rb +0 -85
  182. data/spec/lib/http/response/parser_spec.rb +0 -74
  183. data/spec/lib/http/response/status_spec.rb +0 -253
  184. data/spec/lib/http/response_spec.rb +0 -262
  185. data/spec/lib/http/retriable/delay_calculator_spec.rb +0 -69
  186. data/spec/lib/http/retriable/performer_spec.rb +0 -302
  187. data/spec/lib/http/uri/normalizer_spec.rb +0 -95
  188. data/spec/lib/http/uri_spec.rb +0 -71
  189. data/spec/lib/http_spec.rb +0 -535
  190. data/spec/regression_specs.rb +0 -24
  191. data/spec/spec_helper.rb +0 -89
  192. data/spec/support/black_hole.rb +0 -13
  193. data/spec/support/dummy_server/servlet.rb +0 -203
  194. data/spec/support/dummy_server.rb +0 -44
  195. data/spec/support/fuubar.rb +0 -21
  196. data/spec/support/http_handling_shared.rb +0 -190
  197. data/spec/support/proxy_server.rb +0 -39
  198. data/spec/support/servers/config.rb +0 -11
  199. data/spec/support/servers/runner.rb +0 -19
  200. data/spec/support/ssl_helper.rb +0 -104
  201. /data/{spec → test}/support/capture_warning.rb +0 -0
@@ -0,0 +1,322 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class HTTPResponseStatusTest < Minitest::Test
6
+ cover "HTTP::Response::Status*"
7
+
8
+ # ---------------------------------------------------------------------------
9
+ # .new
10
+ # ---------------------------------------------------------------------------
11
+ def test_new_fails_if_given_value_does_not_respond_to_to_i
12
+ assert_raises(TypeError) { HTTP::Response::Status.new(Object.new) }
13
+ end
14
+
15
+ def test_new_accepts_any_object_that_responds_to_to_i
16
+ HTTP::Response::Status.new(fake(to_i: 200))
17
+ end
18
+
19
+ # ---------------------------------------------------------------------------
20
+ # #code
21
+ # ---------------------------------------------------------------------------
22
+ def test_code_returns_the_integer_code
23
+ status = HTTP::Response::Status.new("200.0")
24
+
25
+ assert_equal 200, status.code
26
+ end
27
+
28
+ def test_code_is_an_integer
29
+ status = HTTP::Response::Status.new("200.0")
30
+
31
+ assert_kind_of Integer, status.code
32
+ end
33
+
34
+ # ---------------------------------------------------------------------------
35
+ # #reason
36
+ # ---------------------------------------------------------------------------
37
+ def test_reason_with_unknown_code_returns_nil
38
+ assert_nil HTTP::Response::Status.new(1024).reason
39
+ end
40
+
41
+ HTTP::Response::Status::REASONS.each do |code, reason|
42
+ define_method(:"test_reason_#{code}_returns_#{reason.downcase.gsub(/[^a-z0-9]/, '_')}") do
43
+ assert_equal reason, HTTP::Response::Status.new(code).reason
44
+ end
45
+
46
+ define_method(:"test_reason_#{code}_is_frozen") do
47
+ assert_predicate HTTP::Response::Status.new(code).reason, :frozen?
48
+ end
49
+ end
50
+
51
+ # ---------------------------------------------------------------------------
52
+ # category methods
53
+ # ---------------------------------------------------------------------------
54
+ all_category_methods = %i[informational? success? redirect? client_error? server_error?]
55
+
56
+ {
57
+ 100...200 => :informational?,
58
+ 200...300 => :success?,
59
+ 300...400 => :redirect?,
60
+ 400...500 => :client_error?,
61
+ 500...600 => :server_error?
62
+ }.each do |range, positive_method|
63
+ prefix = range.first / 100
64
+
65
+ define_method(:"test_#{prefix}xx_codes_are_#{positive_method.to_s.chomp('?')}") do
66
+ statuses = range.map { |code| HTTP::Response::Status.new(code) }
67
+
68
+ assert(statuses.all?(&positive_method))
69
+ end
70
+
71
+ (all_category_methods - [positive_method]).each do |method|
72
+ define_method(:"test_#{prefix}xx_codes_are_not_#{method.to_s.chomp('?')}") do
73
+ statuses = range.map { |code| HTTP::Response::Status.new(code) }
74
+
75
+ assert(statuses.none?(&method))
76
+ end
77
+ end
78
+ end
79
+
80
+ # ---------------------------------------------------------------------------
81
+ # #to_sym
82
+ # ---------------------------------------------------------------------------
83
+ def test_to_sym_with_unknown_code_returns_nil
84
+ assert_nil HTTP::Response::Status.new(1024).to_sym
85
+ end
86
+
87
+ HTTP::Response::Status::SYMBOLS.each do |code, symbol|
88
+ define_method(:"test_to_sym_#{code}_returns_#{symbol}") do
89
+ assert_equal symbol, HTTP::Response::Status.new(code).to_sym
90
+ end
91
+ end
92
+
93
+ # ---------------------------------------------------------------------------
94
+ # #inspect
95
+ # ---------------------------------------------------------------------------
96
+ def test_inspect_returns_quoted_code_and_reason_phrase
97
+ status = HTTP::Response::Status.new(200)
98
+
99
+ assert_equal "#<HTTP::Response::Status 200 OK>", status.inspect
100
+ end
101
+
102
+ # ---------------------------------------------------------------------------
103
+ # ::SYMBOLS
104
+ # ---------------------------------------------------------------------------
105
+ def test_symbols_maps_200_to_ok
106
+ assert_equal :ok, HTTP::Response::Status::SYMBOLS[200]
107
+ end
108
+
109
+ def test_symbols_maps_400_to_bad_request
110
+ assert_equal :bad_request, HTTP::Response::Status::SYMBOLS[400]
111
+ end
112
+
113
+ # ---------------------------------------------------------------------------
114
+ # symbol? predicate methods
115
+ # ---------------------------------------------------------------------------
116
+ HTTP::Response::Status::SYMBOLS.each do |code, symbol|
117
+ define_method(:"test_#{symbol}_predicate_returns_true_when_code_is_#{code}") do
118
+ assert HTTP::Response::Status.new(code).send(:"#{symbol}?")
119
+ end
120
+
121
+ define_method(:"test_#{symbol}_predicate_returns_false_when_code_is_higher_than_#{code}") do
122
+ refute HTTP::Response::Status.new(code + 1).send(:"#{symbol}?")
123
+ end
124
+
125
+ define_method(:"test_#{symbol}_predicate_returns_false_when_code_is_lower_than_#{code}") do
126
+ refute HTTP::Response::Status.new(code - 1).send(:"#{symbol}?")
127
+ end
128
+ end
129
+
130
+ # ---------------------------------------------------------------------------
131
+ # #to_s
132
+ # ---------------------------------------------------------------------------
133
+ def test_to_s_strips_trailing_whitespace_for_unknown_codes
134
+ assert_equal "1024", HTTP::Response::Status.new(1024).to_s
135
+ end
136
+
137
+ # ---------------------------------------------------------------------------
138
+ # #initialize error message
139
+ # ---------------------------------------------------------------------------
140
+ def test_initialize_includes_inspected_object_in_error_message
141
+ obj = Object.new
142
+ def obj.to_s = "custom"
143
+
144
+ err = assert_raises(TypeError) { HTTP::Response::Status.new(obj) }
145
+ assert_match(/#<Object:0x\h+>/, err.message)
146
+ refute_includes err.message, "custom"
147
+ end
148
+
149
+ # ---------------------------------------------------------------------------
150
+ # #to_i
151
+ # ---------------------------------------------------------------------------
152
+ def test_to_i_returns_the_integer_code
153
+ assert_equal 200, HTTP::Response::Status.new(200).to_i
154
+ end
155
+
156
+ # ---------------------------------------------------------------------------
157
+ # #to_int
158
+ # ---------------------------------------------------------------------------
159
+ def test_to_int_returns_the_integer_code
160
+ assert_equal 200, HTTP::Response::Status.new(200).to_int
161
+ end
162
+
163
+ # ---------------------------------------------------------------------------
164
+ # #<=>
165
+ # ---------------------------------------------------------------------------
166
+ def test_spaceship_compares_by_code
167
+ assert_equal(-1, HTTP::Response::Status.new(200) <=> HTTP::Response::Status.new(404))
168
+ end
169
+
170
+ def test_spaceship_compares_with_integers
171
+ assert_equal 0, HTTP::Response::Status.new(200) <=> 200
172
+ end
173
+
174
+ def test_spaceship_returns_nil_for_non_numeric
175
+ assert_nil HTTP::Response::Status.new(200) <=> Object.new
176
+ end
177
+
178
+ def test_spaceship_compares_with_objects_that_respond_to_to_i_but_not_to_int
179
+ assert_equal 1, HTTP::Response::Status.new(200) <=> "abc"
180
+ end
181
+
182
+ # ---------------------------------------------------------------------------
183
+ # #==
184
+ # ---------------------------------------------------------------------------
185
+ def test_equal_to_another_status_with_same_code
186
+ assert_equal HTTP::Response::Status.new(200), HTTP::Response::Status.new(200)
187
+ end
188
+
189
+ def test_not_equal_to_status_with_different_code
190
+ refute_equal HTTP::Response::Status.new(200), HTTP::Response::Status.new(404)
191
+ end
192
+
193
+ # ---------------------------------------------------------------------------
194
+ # #hash
195
+ # ---------------------------------------------------------------------------
196
+ def test_hash_is_same_for_equal_statuses
197
+ assert_equal HTTP::Response::Status.new(200).hash, HTTP::Response::Status.new(200).hash
198
+ end
199
+
200
+ def test_hash_is_consistent_with_codes_hash
201
+ assert_equal 200.hash, HTTP::Response::Status.new(200).hash
202
+ end
203
+
204
+ # ---------------------------------------------------------------------------
205
+ # #deconstruct_keys
206
+ # ---------------------------------------------------------------------------
207
+ def test_deconstruct_keys_returns_all_keys_when_given_nil
208
+ status = HTTP::Response::Status.new(200)
209
+
210
+ assert_equal({ code: 200, reason: "OK" }, status.deconstruct_keys(nil))
211
+ end
212
+
213
+ def test_deconstruct_keys_returns_only_requested_keys
214
+ status = HTTP::Response::Status.new(200)
215
+ result = status.deconstruct_keys([:code])
216
+
217
+ assert_equal({ code: 200 }, result)
218
+ end
219
+
220
+ def test_deconstruct_keys_excludes_unrequested_keys
221
+ status = HTTP::Response::Status.new(200)
222
+
223
+ refute_includes status.deconstruct_keys([:code]).keys, :reason
224
+ end
225
+
226
+ def test_deconstruct_keys_returns_empty_hash_for_empty_keys
227
+ status = HTTP::Response::Status.new(200)
228
+
229
+ assert_equal({}, status.deconstruct_keys([]))
230
+ end
231
+
232
+ def test_deconstruct_keys_returns_nil_reason_for_unknown_code
233
+ unknown = HTTP::Response::Status.new(1024)
234
+
235
+ assert_equal({ code: 1024, reason: nil }, unknown.deconstruct_keys(nil))
236
+ end
237
+
238
+ def test_deconstruct_keys_supports_pattern_matching_with_case_in
239
+ status = HTTP::Response::Status.new(200)
240
+ matched = case status
241
+ in { code: 200..299 }
242
+ true
243
+ else
244
+ false
245
+ end
246
+
247
+ assert matched
248
+ end
249
+
250
+ def test_deconstruct_keys_supports_pattern_matching_with_specific_code
251
+ status = HTTP::Response::Status.new(200)
252
+ matched = case status
253
+ in { code: 200, reason: "OK" }
254
+ true
255
+ else
256
+ false
257
+ end
258
+
259
+ assert matched
260
+ end
261
+
262
+ # ---------------------------------------------------------------------------
263
+ # boundary conditions
264
+ # ---------------------------------------------------------------------------
265
+ def test_code_99_is_not_informational
266
+ refute_predicate HTTP::Response::Status.new(99), :informational?
267
+ end
268
+
269
+ def test_code_600_is_not_server_error
270
+ refute_predicate HTTP::Response::Status.new(600), :server_error?
271
+ end
272
+
273
+ # ---------------------------------------------------------------------------
274
+ # .coerce
275
+ # ---------------------------------------------------------------------------
276
+ def test_coerce_with_string_coerces_reasons
277
+ assert_equal HTTP::Response::Status.new(400), HTTP::Response::Status.coerce("Bad request")
278
+ end
279
+
280
+ def test_coerce_with_string_coerces_hyphenated_reasons
281
+ assert_equal HTTP::Response::Status.new(207), HTTP::Response::Status.coerce("Multi-Status")
282
+ end
283
+
284
+ def test_coerce_with_string_coerces_reasons_with_multiple_words
285
+ assert_equal HTTP::Response::Status.new(203), HTTP::Response::Status.coerce("Non-Authoritative Information")
286
+ end
287
+
288
+ def test_coerce_with_string_fails_when_reason_is_unknown
289
+ assert_raises(HTTP::Error) { HTTP::Response::Status.coerce("foobar") }
290
+ end
291
+
292
+ def test_coerce_with_symbol_coerces_symbolized_reasons
293
+ assert_equal HTTP::Response::Status.new(400), HTTP::Response::Status.coerce(:bad_request)
294
+ end
295
+
296
+ def test_coerce_with_symbol_fails_when_symbolized_reason_is_unknown
297
+ assert_raises(HTTP::Error) { HTTP::Response::Status.coerce(:foobar) }
298
+ end
299
+
300
+ def test_coerce_with_numeric_coerces_as_fixnum_code
301
+ assert_equal HTTP::Response::Status.new(200), HTTP::Response::Status.coerce(200.1)
302
+ end
303
+
304
+ def test_coerce_returns_a_status_instance
305
+ result = HTTP::Response::Status.coerce(:ok)
306
+
307
+ assert_instance_of HTTP::Response::Status, result
308
+ end
309
+
310
+ def test_coerce_fails_if_coercion_failed
311
+ err = assert_raises(HTTP::Error) { HTTP::Response::Status.coerce(true) }
312
+ assert_includes err.message, "TrueClass"
313
+ assert_includes err.message, "true"
314
+ assert_includes err.message, "HTTP::Response::Status"
315
+ end
316
+
317
+ def test_coerce_is_aliased_as_brackets
318
+ status = HTTP::Response::Status[:ok]
319
+
320
+ assert_equal 200, status.code
321
+ end
322
+ end