diff --git a/ipinfo.gemspec b/ipinfo.gemspec index da0ee5f..62a8e82 100644 --- a/ipinfo.gemspec +++ b/ipinfo.gemspec @@ -16,7 +16,17 @@ Gem::Specification.new do |spec| spec.description = ' This is a ruby wrapper for http://ipinfo.io. ' spec.homepage = 'https://ipinfo.io' - spec.add_runtime_dependency 'faraday', '~> 1.0' + spec.add_runtime_dependency 'faraday', '~> 2.0' + # add development dependency to test against faraday adapters that are been moved out the gem + spec.add_development_dependency 'async-http-faraday' + spec.add_development_dependency 'faraday-net_http_persistent', '~> 2.0' + spec.add_development_dependency 'faraday-typhoeus', '~> 1.0' + spec.add_development_dependency 'faraday-patron', '~> 2.0' + spec.add_development_dependency 'faraday-httpclient', '~> 2.0' + spec.add_development_dependency 'faraday-excon', '~> 2.1' + # spec.add_development_dependency 'faraday-em_http', '~> 1.0' + # spec.add_development_dependency 'faraday-em_synchrony', '~> 1.0' + spec.add_runtime_dependency 'json', '~> 2.1' spec.add_runtime_dependency 'lru_redux', '~> 1.1' spec.add_development_dependency 'byebug' diff --git a/lib/ipinfo/adapter.rb b/lib/ipinfo/adapter.rb index d19ae3a..a49f8fc 100644 --- a/lib/ipinfo/adapter.rb +++ b/lib/ipinfo/adapter.rb @@ -35,8 +35,8 @@ def post(uri, body, timeout = 2) attr_reader :token def connection(adapter) - Faraday.new(url: "https://#{HOST}") do |conn| - conn.adapter(adapter) + Faraday.new(url: "https://#{HOST}") do |f| + f.adapter(adapter) end end diff --git a/test/lib/adapter_test.rb b/test/lib/adapter_test.rb index c36e026..3793212 100644 --- a/test/lib/adapter_test.rb +++ b/test/lib/adapter_test.rb @@ -3,6 +3,17 @@ require 'test_helper' require_relative '../../lib/ipinfo/adapter' +require 'faraday/net_http_persistent' +require 'faraday/typhoeus' +require 'faraday/patron' +require 'faraday/httpclient' +require 'faraday/excon' + +# No updates since 2021, the method `dependecy` from the class Faraday::Adapter has been removed +# https://github.com/lostisland/faraday/blob/main/UPGRADING.md#the-dependency-method-in-middlewares-has-been-removed +# require 'faraday/em_http' +# require 'faraday/em_synchrony' + class IPinfo::AdapterTest < Minitest::Test def test_default adapter = IPinfo::Adapter.new @@ -17,8 +28,8 @@ def test_default net_http_persistent: Faraday::Adapter::NetHttpPersistent, typhoeus: Faraday::Adapter::Typhoeus, patron: Faraday::Adapter::Patron, - em_synchrony: Faraday::Adapter::EMSynchrony, - em_http: Faraday::Adapter::EMHttp, + # em_synchrony: Faraday::Adapter::EMSynchrony, + # em_http: Faraday::Adapter::EMHttp, excon: Faraday::Adapter::Excon, httpclient: Faraday::Adapter::HTTPClient }.freeze