Skip to content

Commit

Permalink
Merge pull request #149 from yuki24/faraday
Browse files Browse the repository at this point in the history
Address Faraday warnings
  • Loading branch information
dblock authored Aug 26, 2019
2 parents 55e8a81 + 31ed208 commit bcdd213
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 @@ -2,6 +2,7 @@

### 0.9.2 (Next)

* [#149](https://github.com/codegram/hyperclient/pull/149): Address Faraday warnings - [@yuki24](https://github.com/yuki24).
* Your contribution here.

### 0.9.1 (2019/08/25)
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)

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 bcdd213

Please sign in to comment.