Skip to content

Commit

Permalink
Additional changes ported back from master to allow faraday 1.x and 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Feb 17, 2022
1 parent 63078a3 commit 8159799
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions lib/oauth2/client.rb
Expand Up @@ -59,15 +59,12 @@ def site=(value)

# The Faraday connection object
def connection
@connection ||= begin
conn = Faraday.new(site, options[:connection_opts])
if options[:connection_build]
conn.build do |b|
options[:connection_build].call(b)
@connection ||=
Faraday.new(site, options[:connection_opts]) do |builder|
if options[:connection_build]
options[:connection_build].call(builder)
end
end
conn
end
end

# The authorize endpoint URL of the OAuth2 provider
Expand Down
2 changes: 1 addition & 1 deletion spec/oauth2/client_spec.rb
Expand Up @@ -46,7 +46,7 @@
it 'is able to pass a block to configure the connection' do
connection = double('connection')
builder = double('builder')
allow(connection).to receive(:build).and_yield(builder)
allow(Faraday).to receive(:new).and_yield(builder)
allow(Faraday::Connection).to receive(:new).and_return(connection)

expect(builder).to receive(:adapter).with(:test)
Expand Down

0 comments on commit 8159799

Please sign in to comment.