faraday 1.0.0.pre.rc1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +350 -0
  3. data/LICENSE.md +1 -1
  4. data/README.md +6 -7
  5. data/Rakefile +7 -0
  6. data/examples/client_spec.rb +65 -0
  7. data/examples/client_test.rb +79 -0
  8. data/lib/faraday.rb +51 -41
  9. data/lib/faraday/adapter.rb +47 -1
  10. data/lib/faraday/adapter/em_http.rb +23 -20
  11. data/lib/faraday/adapter/em_http_ssl_patch.rb +1 -1
  12. data/lib/faraday/adapter/em_synchrony.rb +16 -13
  13. data/lib/faraday/adapter/excon.rb +26 -24
  14. data/lib/faraday/adapter/httpclient.rb +42 -40
  15. data/lib/faraday/adapter/net_http_persistent.rb +4 -2
  16. data/lib/faraday/adapter/patron.rb +42 -24
  17. data/lib/faraday/adapter/rack.rb +2 -1
  18. data/lib/faraday/adapter/typhoeus.rb +1 -1
  19. data/lib/faraday/adapter_registry.rb +3 -1
  20. data/lib/faraday/autoload.rb +1 -2
  21. data/lib/faraday/connection.rb +13 -25
  22. data/lib/faraday/encoders/flat_params_encoder.rb +16 -5
  23. data/lib/faraday/encoders/nested_params_encoder.rb +7 -2
  24. data/lib/faraday/error.rb +64 -12
  25. data/lib/faraday/{upload_io.rb → file_part.rb} +53 -3
  26. data/lib/faraday/logging/formatter.rb +28 -15
  27. data/lib/faraday/methods.rb +6 -0
  28. data/lib/faraday/middleware.rb +19 -1
  29. data/lib/faraday/options.rb +5 -9
  30. data/lib/faraday/options/env.rb +1 -1
  31. data/lib/faraday/options/request_options.rb +3 -2
  32. data/lib/faraday/param_part.rb +53 -0
  33. data/lib/faraday/rack_builder.rb +13 -12
  34. data/lib/faraday/request.rb +20 -10
  35. data/lib/faraday/request/authorization.rb +3 -1
  36. data/lib/faraday/request/multipart.rb +19 -4
  37. data/lib/faraday/request/retry.rb +2 -2
  38. data/lib/faraday/request/url_encoded.rb +3 -1
  39. data/lib/faraday/response.rb +6 -9
  40. data/lib/faraday/response/raise_error.rb +14 -1
  41. data/lib/faraday/utils.rb +11 -3
  42. data/lib/faraday/utils/headers.rb +2 -2
  43. data/lib/faraday/version.rb +5 -0
  44. data/spec/faraday/adapter/em_http_spec.rb +47 -0
  45. data/spec/faraday/adapter/em_synchrony_spec.rb +16 -0
  46. data/spec/faraday/adapter/excon_spec.rb +49 -0
  47. data/spec/faraday/adapter/httpclient_spec.rb +73 -0
  48. data/spec/faraday/adapter/net_http_persistent_spec.rb +57 -0
  49. data/spec/faraday/adapter/net_http_spec.rb +64 -0
  50. data/spec/faraday/adapter/patron_spec.rb +18 -0
  51. data/spec/faraday/adapter/rack_spec.rb +8 -0
  52. data/spec/faraday/adapter/test_spec.rb +260 -0
  53. data/spec/faraday/adapter/typhoeus_spec.rb +7 -0
  54. data/spec/faraday/adapter_registry_spec.rb +28 -0
  55. data/spec/faraday/adapter_spec.rb +55 -0
  56. data/spec/faraday/composite_read_io_spec.rb +80 -0
  57. data/spec/faraday/connection_spec.rb +691 -0
  58. data/spec/faraday/error_spec.rb +60 -0
  59. data/spec/faraday/middleware_spec.rb +52 -0
  60. data/spec/faraday/options/env_spec.rb +70 -0
  61. data/spec/faraday/options/options_spec.rb +297 -0
  62. data/spec/faraday/options/proxy_options_spec.rb +37 -0
  63. data/spec/faraday/options/request_options_spec.rb +19 -0
  64. data/spec/faraday/params_encoders/flat_spec.rb +42 -0
  65. data/spec/faraday/params_encoders/nested_spec.rb +142 -0
  66. data/spec/faraday/rack_builder_spec.rb +345 -0
  67. data/spec/faraday/request/authorization_spec.rb +88 -0
  68. data/spec/faraday/request/instrumentation_spec.rb +76 -0
  69. data/spec/faraday/request/multipart_spec.rb +302 -0
  70. data/spec/faraday/request/retry_spec.rb +242 -0
  71. data/spec/faraday/request/url_encoded_spec.rb +83 -0
  72. data/spec/faraday/request_spec.rb +120 -0
  73. data/spec/faraday/response/logger_spec.rb +220 -0
  74. data/spec/faraday/response/middleware_spec.rb +68 -0
  75. data/spec/faraday/response/raise_error_spec.rb +169 -0
  76. data/spec/faraday/response_spec.rb +75 -0
  77. data/spec/faraday/utils/headers_spec.rb +82 -0
  78. data/spec/faraday/utils_spec.rb +56 -0
  79. data/spec/faraday_spec.rb +37 -0
  80. data/spec/spec_helper.rb +132 -0
  81. data/spec/support/disabling_stub.rb +14 -0
  82. data/spec/support/fake_safe_buffer.rb +15 -0
  83. data/spec/support/helper_methods.rb +133 -0
  84. data/spec/support/shared_examples/adapter.rb +105 -0
  85. data/spec/support/shared_examples/params_encoder.rb +18 -0
  86. data/spec/support/shared_examples/request_method.rb +262 -0
  87. data/spec/support/streaming_response_checker.rb +35 -0
  88. data/spec/support/webmock_rack_app.rb +68 -0
  89. metadata +96 -12
  90. data/lib/faraday/adapter/net_http.rb +0 -205
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796572c71fdcd51b8c208072304ac74f0c408fece78878a69b1a1abb55a10939
4
- data.tar.gz: 3eea5a3f432b1979e6419dd5445507425a5859c53b3c7f62f14ad9d55cbbf787
3
+ metadata.gz: f907e999805c78e8c2e77cb4d6b29a0a6f8fd8fe1a7df9930f02be7ec113a630
4
+ data.tar.gz: 1ceac7f2b44d41d11d1ad3f7642daea9198ba3ac2f71a4932cf7d6b7b867f704
5
5
  SHA512:
6
- metadata.gz: 2ee806bf77a77b00b17c75644123b6c2eada90e1d096df5a5c21b588608133dfacbe74049a82c4980452e1155d03fcc2b1ceca131dcd5a349e131aa6aca44a08
7
- data.tar.gz: 147ad4806869e58ffe5e68936d1abe2559ead47b971441c57b47b930df3c74780c5d131c1d180bf2b74cac34df70628ebed3296e1fd4367ce46c87d98849047f
6
+ metadata.gz: 2eaf54d743ed3d7554fb2be17003e81b08c060582f140b06fb55e8aceb7dfcf2428e898f47f3760eddcdb4ad64aeaacc93916672b9ed10fa4a004d0ea1a20e1a
7
+ data.tar.gz: a700f0bc8999e9a0152843bbfbd23001fa23931614ae9573b13ff839e7af01f38ca2adbb01c82e4b387688496b3caff87357e3946d7500595a2f807313e177d7
@@ -0,0 +1,350 @@
1
+ # Faraday Changelog
2
+
3
+ ## [v1.2.0](https://github.com/lostisland/faraday/releases/tag/v1.2.0) (2020-12-23)
4
+
5
+ ### Features
6
+
7
+ * Introduces `on_request` and `on_complete` methods in `Faraday::Middleware`. (#1194, @iMacTia)
8
+
9
+ ### Fixes
10
+
11
+ * Require 'date' to avoid retry exception (#1206, @rustygeldmacher)
12
+ * Fix rdebug recursion issue (#1205, @native-api)
13
+ * Update call to `em_http_ssl_patch` (#1202, @kylekeesling)
14
+ * `EmHttp` adapter: drop superfluous loaded? check (#1213, @olleolleolle)
15
+ * Avoid 1 use of keyword hackery (#1211, @grosser)
16
+ * Fix #1219 `Net::HTTP` still uses env proxy (#1221, @iMacTia)
17
+
18
+ ### Documentation
19
+
20
+ * Add comment in gemspec to explain exposure of `examples` and `spec` folders. (#1192, @iMacTia)
21
+ * Adapters, how to create them (#1193, @olleolleolle)
22
+ * Update documentation on using the logger (#1196, @tijmenb)
23
+ * Adjust the retry documentation and spec to align with implementation (#1198, @nbeyer)
24
+
25
+ ### Misc
26
+
27
+ * Test against ruby head (#1208, @grosser)
28
+
29
+ ## [v1.1.0](https://github.com/lostisland/faraday/releases/tag/v1.1.0) (2020-10-17)
30
+
31
+ ### Features
32
+
33
+ * Makes parameters sorting configurable (#1162 @wishdev)
34
+ * Introduces `flat_encode` option for multipart adapter. (#1163 @iMacTia)
35
+ * Include request info in exceptions raised by RaiseError Middleware (#1181 @SandroDamilano)
36
+
37
+ ### Fixes
38
+
39
+ * Avoid `last arg as keyword param` warning when building user middleware on Ruby 2.7 (#1153 @dgholz)
40
+ * Limits net-http-persistent version to < 4.0 (#1156 @iMacTia)
41
+ * Update `typhoeus` to new stable version (`1.4`) (#1159 @AlexWayfer)
42
+ * Properly fix test failure with Rack 2.1+. (#1171 @voxik)
43
+
44
+ ### Documentation
45
+
46
+ * Improves documentation on how to contribute to the site by using Docker. (#1175 @iMacTia)
47
+ * Remove retry_change_requests from documentation (#1185 @stim371)
48
+
49
+ ### Misc
50
+
51
+ * Link from GitHub Actions badge to CI workflow (#1141 @olleolleolle)
52
+ * Return tests of `Test` adapter (#1147 @AlexWayfer)
53
+ * Add 1.0 release to wording in CONTRIBUTING (#1155 @olleolleolle)
54
+ * Fix linting bumping Rubocop to 0.90.0 (#1182 @iMacTia)
55
+ * Drop `git ls-files` in gemspec (#1183 @utkarsh2102)
56
+ * Upgrade CI to ruby/setup-ruby (#1187 @gogainda)
57
+
58
+ ## [v1.0.1](https://github.com/lostisland/faraday/releases/tag/v1.0.1) (2020-03-29)
59
+
60
+ ### Fixes
61
+
62
+ * Use Net::HTTP#start(&block) to ensure closed TCP connections (#1117)
63
+ * Fully qualify constants to be checked (#1122)
64
+ * Allows `parse` method to be private/protected in response middleware (#1123)
65
+ * Encode Spaces in Query Strings as '%20' Instead of '+' (#1125)
66
+ * Limits rack to v2.0.x (#1127)
67
+ * Adapter Registry reads also use mutex (#1136)
68
+
69
+ ### Documentation
70
+
71
+ * Retry middleware documentation fix (#1109)
72
+ * Docs(retry): precise usage of retry-after (#1111)
73
+ * README: Link the logo to the website (#1112)
74
+ * Website: add search bar (#1116)
75
+ * Fix request/response mix-up in docs text (#1132)
76
+
77
+ ## v1.0
78
+
79
+ Features:
80
+
81
+ * Add #trace support to Faraday::Connection #861 (@technoweenie)
82
+ * Add the log formatter that is easy to override and safe to inherit #889 (@prikha)
83
+ * Support standalone adapters #941 (@iMacTia)
84
+ * Introduce Faraday::ConflictError for 409 response code #979 (@lucasmoreno)
85
+ * Add support for setting `read_timeout` option separately #1003 (@springerigor)
86
+ * Refactor and cleanup timeout settings across adapters #1022 (@technoweenie)
87
+ * Create ParamPart class to allow multipart posts with JSON content and file upload at the same time #1017 (@jeremy-israel)
88
+ * Copy UploadIO const -> FilePart for consistency with ParamPart #1018, #1021 (@technoweenie)
89
+ * Implement streaming responses in the Excon adapter #1026 (@technoweenie)
90
+ * Add default implementation of `Middleware#close`. #1069 (@ioquatix)
91
+ * Add `Adapter#close` so that derived classes can call super. #1091 (@ioquatix)
92
+ * Add log_level option to logger default formatter #1079 (@amrrbakry)
93
+ * Fix empty array for FlatParamsEncoder `{key: []} -> "key="` #1084 (@mrexox)
94
+
95
+ Bugs:
96
+
97
+ * Explicitly require date for DateTime library in Retry middleware #844 (@nickpresta)
98
+ * Refactor Adapter as final endpoints #846 (@iMacTia)
99
+ * Separate Request and Response bodies in Faraday::Env #847 (@iMacTia)
100
+ * Implement Faraday::Connection#options to make HTTP requests with the OPTIONS verb. #857 (@technoweenie)
101
+ * Multipart: Drop Ruby 1.8 String behavior compat #892 (@olleolleolle)
102
+ * Fix Ruby warnings in Faraday::Options.memoized #962 (@technoweenie)
103
+ * Allow setting min/max SSL version for a Net::HTTP::Persistent connection #972, #973 (@bdewater, @olleolleolle)
104
+ * Fix instances of frozen empty string literals #1040 (@BobbyMcWho)
105
+ * remove temp_proxy and improve proxy tests #1063 (@technoweenie)
106
+ * improve error initializer consistency #1095 (@technoweenie)
107
+
108
+ Misc:
109
+
110
+ * Convert minitest suite to RSpec #832 (@iMacTia, with help from @gaynetdinov, @Insti, @technoweenie)
111
+ * Major effort to update code to RuboCop standards. #854 (@olleolleolle, @iMacTia, @technoweenie, @htwroclau, @jherdman, @Drenmi, @Insti)
112
+ * Rubocop #1044, #1047 (@BobbyMcWho, @olleolleolle)
113
+ * Documentation tweaks (@adsteel, @Hubro, @iMacTia, @olleolleolle, @technoweenie)
114
+ * Update license year #981 (@Kevin-Kawai)
115
+ * Configure Jekyll plugin jekyll-remote-theme to support Docker usage #999 (@Lewiscowles1986)
116
+ * Fix Ruby 2.7 warnings #1009 (@tenderlove)
117
+ * Cleanup adapter connections #1023 (@technoweenie)
118
+ * Describe clearing cached stubs #1045 (@viraptor)
119
+ * Add project metadata to the gemspec #1046 (@orien)
120
+
121
+ ## v0.17.3
122
+
123
+ Fixes:
124
+
125
+ * Reverts changes in error classes hierarchy. #1092 (@iMacTia)
126
+ * Fix Ruby 1.9 syntax errors and improve Error class testing #1094 (@BanzaiMan,
127
+ @mrexox, @technoweenie)
128
+
129
+ Misc:
130
+
131
+ * Stops using `&Proc.new` for block forwarding. #1083 (@olleolleolle)
132
+ * Update CI to test against ruby 2.0-2.7 #1087, #1099 (@iMacTia, @olleolleolle,
133
+ @technoweenie)
134
+ * require FARADAY_DEPRECATE=warn to show Faraday v1.0 deprecation warnings
135
+ #1098 (@technoweenie)
136
+
137
+ ## v0.17.1
138
+
139
+ Final release before Faraday v1.0, with important fixes for Ruby 2.7.
140
+
141
+ Fixes:
142
+
143
+ * RaiseError response middleware raises exception if HTTP client returns a nil
144
+ status. #1042 (@jonnyom, @BobbyMcWho)
145
+
146
+ Misc:
147
+
148
+ * Fix Ruby 2.7 warnings (#1009)
149
+ * Add `Faraday::Deprecate` to warn about upcoming v1.0 changes. (#1054, #1059,
150
+ #1076, #1077)
151
+ * Add release notes up to current in CHANGELOG.md (#1066)
152
+ * Port minimal rspec suite from main branch to run backported tests. (#1058)
153
+
154
+ ## v0.17.0
155
+
156
+ This release is the same as v0.15.4. It was pushed to cover up releases
157
+ v0.16.0-v0.16.2.
158
+
159
+ ## v0.15.4
160
+
161
+ * Expose `pool_size` as a option for the NetHttpPersistent adapter (#834)
162
+
163
+ ## v0.15.3
164
+
165
+ * Make Faraday::Request serialisable with Marshal. (#803)
166
+ * Add DEFAULT_EXCEPTIONS constant to Request::Retry (#814)
167
+ * Add support for Ruby 2.6 Net::HTTP write_timeout (#824)
168
+
169
+ ## v0.15.2
170
+
171
+ * Prevents `Net::HTTP` adapters to retry request internally by setting `max_retries` to 0 if available (Ruby 2.5+). (#799)
172
+ * Fixes `NestedParamsEncoder` handling of empty array values (#801)
173
+
174
+ ## v0.15.1
175
+
176
+ * NetHttpPersistent adapter better reuse of SSL connections (#793)
177
+ * Refactor: inline cached_connection (#797)
178
+ * Logger middleware: use $stdout instead of STDOUT (#794)
179
+ * Fix: do not memoize/reuse Patron session (#796)
180
+
181
+ Also in this release:
182
+
183
+ * Allow setting min/max ssl version for Net::HTTP (#792)
184
+ * Allow setting min/max ssl version for Excon (#795)
185
+
186
+ ## v0.15.0
187
+
188
+ Features:
189
+
190
+ * Added retry block option to retry middleware. (#770)
191
+ * Retry middleware improvements (honour Retry-After header, retry statuses) (#773)
192
+ * Improve response logger middleware output (#784)
193
+
194
+ Fixes:
195
+
196
+ * Remove unused class error (#767)
197
+ * Fix minor typo in README (#760)
198
+ * Reuse persistent connections when using net-http-persistent (#778)
199
+ * Fix Retry middleware documentation (#781)
200
+ * Returns the http response when giving up on retrying by status (#783)
201
+
202
+ ## v0.14.0
203
+
204
+ Features:
205
+
206
+ * Allow overriding env proxy #754 (@iMacTia)
207
+ * Remove legacy Typhoeus adapter #715 (@olleolleolle)
208
+ * External Typhoeus Adapter Compatibility #748 (@iMacTia)
209
+ * Warn about missing adapter when making a request #743 (@antstorm)
210
+ * Faraday::Adapter::Test stubs now support entire urls (with host) #741 (@erik-escobedo)
211
+
212
+ Fixes:
213
+
214
+ * If proxy is manually provided, this takes priority over `find_proxy` #724 (@iMacTia)
215
+ * Fixes the behaviour for Excon's open_timeout (not setting write_timeout anymore) #731 (@apachelogger)
216
+ * Handle all connection timeout messages in Patron #687 (@stayhero)
217
+
218
+ ## v0.13.1
219
+
220
+ * Fixes an incompatibility with Addressable::URI being used as uri_parser
221
+
222
+ ## v0.13.0
223
+
224
+ Features:
225
+
226
+ * Dynamically reloads the proxy when performing a request on an absolute domain (#701)
227
+ * Adapter support for Net::HTTP::Persistent v3.0.0 (#619)
228
+
229
+ Fixes:
230
+
231
+ * Prefer #hostname over #host. (#714)
232
+ * Fixes an edge-case issue with response headers parsing (missing HTTP header) (#719)
233
+
234
+ ## v0.12.2
235
+
236
+ * Parse headers from aggregated proxy requests/responses (#681)
237
+ * Guard against invalid middleware configuration with warning (#685)
238
+ * Do not use :insecure option by default in Patron (#691)
239
+ * Fixes an issue with HTTPClient not raising a `Faraday::ConnectionFailed` (#702)
240
+ * Fixes YAML serialization/deserialization for `Faraday::Utils::Headers` (#690)
241
+ * Fixes an issue with Options having a nil value (#694)
242
+ * Fixes an issue with Faraday.default_connection not using Faraday.default_connection_options (#698)
243
+ * Fixes an issue with Options.merge! and Faraday instrumentation middleware (#710)
244
+
245
+ ## v0.12.1
246
+
247
+ * Fix an issue with Patron tests failing on jruby
248
+ * Fix an issue with new `rewind_files` feature that was causing an exception when the body was not an Hash
249
+ * Expose wrapped_exception in all client errors
250
+ * Add Authentication Section to the ReadMe
251
+
252
+ ## v0.12.0.1
253
+
254
+ * Hotfix release to address an issue with TravisCI deploy on Rubygems
255
+
256
+ ## v0.12.0
257
+
258
+ Features:
259
+
260
+ * Proxy feature now relies on Ruby `URI::Generic#find_proxy` and can use `no_proxy` ENV variable (not compatible with ruby < 2.0)
261
+ * Adds support for `context` request option to pass arbitrary information to middlewares
262
+
263
+ Fixes:
264
+
265
+ * Fix an issue with options that was causing new options to override defaults ones unexpectedly
266
+ * Rewind `UploadIO`s on retry to fix a compatibility issue
267
+ * Make multipart boundary unique
268
+ * Improvements in `README.md`
269
+
270
+ ## v0.11.0
271
+
272
+ Features:
273
+
274
+ * Add `filter` method to Logger middleware
275
+ * Add support for Ruby2.4 and Minitest 6
276
+ * Introduce block syntax to customise the adapter
277
+
278
+ Fixes:
279
+
280
+ * Fix an issue that was allowing to override `default_connection_options` from a connection instance
281
+ * Fix a bug that was causing newline escape characters ("\n") to be used when building the Authorization header
282
+
283
+ ## v0.10.1
284
+
285
+ - Fix an issue with HTTPClient adapter that was causing the SSL to be reset on every request
286
+ - Rescue `IOError` instead of specific subclass
287
+ - `Faraday::Utils::Headers` can now be successfully serialised in YAML
288
+ - Handle `default_connection_options` set with hash
289
+
290
+ ## v0.10.0
291
+
292
+ Breaking changes:
293
+ - Drop support for Ruby 1.8
294
+
295
+ Features:
296
+ - Include wrapped exception/reponse in ClientErrors
297
+ - Add `response.reason_phrase`
298
+ - Provide option to selectively skip logging request/response headers
299
+ - Add regex support for pattern matching in `test` adapter
300
+
301
+ Fixes:
302
+ - Add `Faraday.respond_to?` to find methods managed by `method_missing`
303
+ - em-http: `request.host` instead of `connection.host` should be taken for SSL validations
304
+ - Allow `default_connection_options` to be merged when options are passed as url parameter
305
+ - Improve splitting key-value pairs in raw HTTP headers
306
+
307
+ ## v0.9.2
308
+
309
+ Adapters:
310
+ - Enable gzip compression for httpclient
311
+ - Fixes default certificate store for httpclient not having default paths.
312
+ - Make excon adapter compatible with 0.44 excon version
313
+ - Add compatibility with Patron 0.4.20
314
+ - Determine default port numbers in Net::HTTP adapters (Addressable compatibility)
315
+ - em-http: wrap "connection closed by server" as ConnectionFailed type
316
+ - Wrap Errno::ETIMEDOUT in Faraday::Error::TimeoutError
317
+
318
+ Utils:
319
+ - Add Rack-compatible support for parsing `a[][b]=c` nested queries
320
+ - Encode nil values in queries different than empty strings. Before: `a=`; now: `a`.
321
+ - Have `Faraday::Utils::Headers#replace` clear internal key cache
322
+ - Dup the internal key cache when a Headers hash is copied
323
+
324
+ Env and middleware:
325
+ - Ensure `env` stored on middleware response has reference to the response
326
+ - Ensure that Response properties are initialized during `on_complete` (VCR compatibility)
327
+ - Copy request options in Faraday::Connection#dup
328
+ - Env custom members should be copied by Env.from(env)
329
+ - Honour per-request `request.options.params_encoder`
330
+ - Fix `interval_randomness` data type for Retry middleware
331
+ - Add maximum interval option for Retry middleware
332
+
333
+ ## v0.9.1
334
+
335
+ * Refactor Net:HTTP adapter so that with_net_http_connection can be overridden to allow pooled connections. (@Ben-M)
336
+ * Add configurable methods that bypass `retry_if` in the Retry request middleware. (@mike-bourgeous)
337
+
338
+ ## v0.9.0
339
+
340
+ * Add HTTPClient adapter (@hakanensari)
341
+ * Improve Retry handler (@mislav)
342
+ * Remove autoloading by default (@technoweenie)
343
+ * Improve internal docs (@technoweenie, @mislav)
344
+ * Respect user/password in http proxy string (@mislav)
345
+ * Adapter options are structs. Reinforces consistent options across adapters
346
+ (@technoweenie)
347
+ * Stop stripping trailing / off base URLs in a Faraday::Connection. (@technoweenie)
348
+ * Add a configurable URI parser. (@technoweenie)
349
+ * Remove need to manually autoload when using the authorization header helpers on `Faraday::Connection`. (@technoweenie)
350
+ * `Faraday::Adapter::Test` respects the `Faraday::RequestOptions#params_encoder` option. (@technoweenie)
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2019 Rick Olson, Zack Hobson
1
+ Copyright (c) 2009-2020 Rick Olson, Zack Hobson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # ![Faraday](./docs/assets/img/repo-card-slim.png)
1
+ # [![Faraday](./docs/assets/img/repo-card-slim.png)][website]
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/faraday.svg)](https://rubygems.org/gems/faraday)
4
- [![CircleCI](https://circleci.com/gh/lostisland/faraday/tree/master.svg?style=svg)](https://circleci.com/gh/lostisland/faraday/tree/master)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/f869daab091ceef1da73/test_coverage)](https://codeclimate.com/github/lostisland/faraday/test_coverage)
4
+ [![GitHub Actions CI](https://github.com/lostisland/faraday/workflows/CI/badge.svg)](https://github.com/lostisland/faraday/actions?query=workflow%3ACI)
6
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/f869daab091ceef1da73/maintainability)](https://codeclimate.com/github/lostisland/faraday/maintainability)
7
6
  [![Gitter](https://badges.gitter.im/lostisland/faraday.svg)](https://gitter.im/lostisland/faraday?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
8
7
 
@@ -18,10 +17,10 @@ Need more details? See the [Faraday API Documentation][apidoc] to see how it wor
18
17
 
19
18
  ## Supported Ruby versions
20
19
 
21
- This library aims to support and is [tested against][circle_ci] the following Ruby
20
+ This library aims to support and is [tested against][actions] the following Ruby
22
21
  implementations:
23
22
 
24
- * Ruby 2.3+
23
+ * Ruby 2.4+
25
24
 
26
25
  If something doesn't work on one of these Ruby versions, it's a bug.
27
26
 
@@ -43,13 +42,13 @@ Open the issues page and check for the `help wanted` label!
43
42
  But before you start coding, please read our [Contributing Guide][contributing]
44
43
 
45
44
  ## Copyright
46
- &copy; 2009 - 2019, the [Faraday Team][faraday_team]. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
45
+ &copy; 2009 - 2020, the [Faraday Team][faraday_team]. Website and branding design by [Elena Lo Piccolo](https://elelopic.design).
47
46
 
48
47
  [website]: https://lostisland.github.io/faraday
49
48
  [faraday_team]: https://lostisland.github.io/faraday/team
50
49
  [contributing]: https://github.com/lostisland/faraday/blob/master/.github/CONTRIBUTING.md
51
50
  [apidoc]: http://www.rubydoc.info/gems/faraday
52
- [circle_ci]: https://circleci.com/gh/lostisland/faraday
51
+ [actions]: https://github.com/lostisland/faraday/actions
53
52
  [jruby]: http://jruby.org/
54
53
  [rubinius]: http://rubini.us/
55
54
  [license]: LICENSE.md
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Requires Ruby with rspec and faraday gems.
4
+ # rspec client_spec.rb
5
+
6
+ require 'faraday'
7
+ require 'json'
8
+
9
+ # Example API client
10
+ class Client
11
+ def initialize(conn)
12
+ @conn = conn
13
+ end
14
+
15
+ def sushi(jname)
16
+ res = @conn.get("/#{jname}")
17
+ data = JSON.parse(res.body)
18
+ data['name']
19
+ end
20
+ end
21
+
22
+ RSpec.describe Client do
23
+ let(:stubs) { Faraday::Adapter::Test::Stubs.new }
24
+ let(:conn) { Faraday.new { |b| b.adapter(:test, stubs) } }
25
+ let(:client) { Client.new(conn) }
26
+
27
+ it 'parses name' do
28
+ stubs.get('/ebi') do |env|
29
+ # optional: you can inspect the Faraday::Env
30
+ expect(env.url.path).to eq('/ebi')
31
+ [
32
+ 200,
33
+ { 'Content-Type': 'application/javascript' },
34
+ '{"name": "shrimp"}'
35
+ ]
36
+ end
37
+
38
+ # uncomment to trigger stubs.verify_stubbed_calls failure
39
+ # stubs.get('/unused') { [404, {}, ''] }
40
+
41
+ expect(client.sushi('ebi')).to eq('shrimp')
42
+ stubs.verify_stubbed_calls
43
+ end
44
+
45
+ it 'handles 404' do
46
+ stubs.get('/ebi') do
47
+ [
48
+ 404,
49
+ { 'Content-Type': 'application/javascript' },
50
+ '{}'
51
+ ]
52
+ end
53
+ expect(client.sushi('ebi')).to be_nil
54
+ stubs.verify_stubbed_calls
55
+ end
56
+
57
+ it 'handles exception' do
58
+ stubs.get('/ebi') do
59
+ raise Faraday::ConnectionFailed, nil
60
+ end
61
+
62
+ expect { client.sushi('ebi') }.to raise_error(Faraday::ConnectionFailed)
63
+ stubs.verify_stubbed_calls
64
+ end
65
+ end