From 6cd70721804e8faa04cd8968f2272c3793ed6307 Mon Sep 17 00:00:00 2001 From: Daniel Leidert <14413364+dleidert@users.noreply.github.com> Date: Mon, 30 Mar 2020 17:16:18 +0200 Subject: [PATCH] Fix tests with excon >= 0.63 (#809) * Fix tests with excon >= 0.63 In this version an 'Accept' header has been added in excon [1] and needs to be added to the default headers to merge too. This should fix #801 and with the version check being backwards compatible [1] https://github.com/excon/excon/blame/master/lib/excon/constants.rb#L141 * Update spec/support/http_library_adapters.rb Prefer start_with() over to_f() for version comparison Co-Authored-By: Kurtis Rainbolt-Greene * Use patch by @terceiro Co-Authored-By: Olle Jonsson Co-authored-by: Kurtis Rainbolt-Greene Co-authored-by: Olle Jonsson --- spec/support/http_library_adapters.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/support/http_library_adapters.rb b/spec/support/http_library_adapters.rb index 99140972..90d7668b 100644 --- a/spec/support/http_library_adapters.rb +++ b/spec/support/http_library_adapters.rb @@ -227,7 +227,11 @@ def make_http_request(method, url, body = nil, headers = {}) end def normalize_request_headers(headers) - headers.merge('User-Agent' => [Excon::USER_AGENT]) + if Gem::Version.new(Excon::VERSION) < Gem::Version.new("0.63") + headers.merge('User-Agent' => [Excon::USER_AGENT]) + else + headers.merge('User-Agent' => [Excon::USER_AGENT], 'Accept' => ['*/*']) + end end end