Skip to content

Commit

Permalink
Address Faraday warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki24 committed Aug 25, 2019
1 parent 403c35e commit ecf5ad2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [#139](https://github.com/codegram/hyperclient/pull/139): Test `hyperclient` against newer versions of MRI Ruby, up until 2.6.x - [@mrcasals](https://github.com/mrcasals).
* [#141](https://github.com/codegram/hyperclient/pull/141): Replace `uri_template` with `addressable` library - [@mrcasals](https://github.com/mrcasals).
* [#136](https://github.com/codegram/hyperclient/pull/136), [#146](https://github.com/codegram/hyperclient/pull/146): Upgraded Danger plugins - [@dblock](https://github.com/dblock), [@ivoanjo](https://github.com/ivoanjo).
* [#149](https://github.com/codegram/hyperclient/pull/149): Address Faraday warnings - [@yuki24](https://github.com/yuki24)
* Your contribution here.

### 0.9.0 (2018/01/10)
Expand Down
8 changes: 5 additions & 3 deletions lib/hyperclient/entry_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def connection(options = {}, &block)
block
else
lambda do |conn|
default_faraday_block.call conn
yield conn
default_faraday_block.call(conn, &block)
end
end
else
Expand Down Expand Up @@ -138,11 +137,14 @@ def faraday_block=(value)
#
# Returns a block.
def default_faraday_block
lambda do |connection|
lambda do |connection, &block|
connection.use Faraday::Response::RaiseError
connection.use FaradayMiddleware::FollowRedirects
connection.request :hal_json
connection.response :hal_json, content_type: /\bjson$/

block.call(connection) if block

connection.adapter :net_http
connection.options.params_encoder = Faraday::FlatParamsEncoder
end
Expand Down
9 changes: 8 additions & 1 deletion test/hyperclient/entry_point_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ module Hyperclient

it 'can insert additional middleware after a connection has been constructed' do
entry_point.connection.must_be_kind_of Faraday::Connection
entry_point.connection.use :instrumentation

warning = "WARNING: Unexpected middleware set after the adapter. " \
"This won't be supported from Faraday 1.0.\n"

assert_output nil, warning do
entry_point.connection.use :instrumentation
end

handlers = entry_point.connection.builder.handlers
handlers.must_include FaradayMiddleware::Instrumentation
end
Expand Down

0 comments on commit ecf5ad2

Please sign in to comment.