Skip to content

Commit 8159799

Browse files
committed
Additional changes ported back from master to allow faraday 1.x and 2.x
1 parent 63078a3 commit 8159799

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

lib/oauth2/client.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,12 @@ def site=(value)
5959

6060
# The Faraday connection object
6161
def connection
62-
@connection ||= begin
63-
conn = Faraday.new(site, options[:connection_opts])
64-
if options[:connection_build]
65-
conn.build do |b|
66-
options[:connection_build].call(b)
62+
@connection ||=
63+
Faraday.new(site, options[:connection_opts]) do |builder|
64+
if options[:connection_build]
65+
options[:connection_build].call(builder)
6766
end
6867
end
69-
conn
70-
end
7168
end
7269

7370
# The authorize endpoint URL of the OAuth2 provider

spec/oauth2/client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
it 'is able to pass a block to configure the connection' do
4747
connection = double('connection')
4848
builder = double('builder')
49-
allow(connection).to receive(:build).and_yield(builder)
49+
allow(Faraday).to receive(:new).and_yield(builder)
5050
allow(Faraday::Connection).to receive(:new).and_return(connection)
5151

5252
expect(builder).to receive(:adapter).with(:test)

0 commit comments

Comments
 (0)