Skip to content

Commit

Permalink
Fix Faraday.default_connection_options deep-merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iMacTia committed Nov 30, 2021
1 parent 64058b9 commit 65b8d39
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions spec/faraday/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,19 +641,22 @@ def decode(params)
end

context 'preserving a user_agent assigned via default_conncetion_options' do
around do |example|
old = Faraday.default_connection_options
Faraday.default_connection_options = { headers: { user_agent: 'My Agent 1.2' } }
example.run
Faraday.default_connection_options = old
end

context 'when url is a Hash' do
let(:conn) { Faraday.new(url: 'http://example.co', headers: { 'CustomHeader' => 'CustomValue' }) }

before { Faraday.default_connection_options = { headers: { user_agent: 'My Agent 1.2' } } }

it { expect(conn.headers).to eq('CustomHeader' => 'CustomValue', 'User-Agent' => 'My Agent 1.2') }
end

context 'when url is a String' do
let(:conn) { Faraday.new('http://example.co', headers: { 'CustomHeader' => 'CustomValue' }) }

before { Faraday.default_connection_options = { headers: { user_agent: 'My Agent 1.2' } } }

it { expect(conn.headers).to eq('CustomHeader' => 'CustomValue', 'User-Agent' => 'My Agent 1.2') }
end
end
Expand Down

0 comments on commit 65b8d39

Please sign in to comment.