Skip to content

Commit

Permalink
bumped faraday to latest version and included adapters for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolapagiaro committed May 31, 2023
1 parent 08a6dfd commit fc84a30
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
12 changes: 11 additions & 1 deletion ipinfo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions lib/ipinfo/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions test/lib/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit fc84a30

Please sign in to comment.