Skip to content

Commit fd7ac9f

Browse files
authored
Fix compatibility with both Ruby 3.0 and Faraday 0.17.x (#206)
* Add webrick dependency This is required for testing and is no longer bundled as of Ruby 3.0 * Allow specifying faraday version in Gemfile * Specify faraday adapter in directory client This is required for the test suite to pass in Faraday 0.17.x * Fix kwarg issue under faraday 0.17.x and Ruby 3
1 parent cb3ef5d commit fd7ac9f

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ source 'https://rubygems.org'
22

33
gemspec
44

5+
if faraday_version = ENV['FARADAY_VERSION']
6+
gem 'faraday', faraday_version
7+
end
8+
59
group :development, :test do
610
gem 'pry'
711
gem 'rubocop', '~> 0.49.0'

acme-client.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
2525
spec.add_development_dependency 'rspec', '~> 3.9'
2626
spec.add_development_dependency 'vcr', '~> 2.9'
2727
spec.add_development_dependency 'webmock', '~> 3.8'
28+
spec.add_development_dependency 'webrick'
2829

2930
spec.add_runtime_dependency 'faraday', '>= 0.17', '< 2.0.0'
3031
end

lib/acme/client/faraday_middleware.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ class Acme::Client::FaradayMiddleware < Faraday::Middleware
55

66
CONTENT_TYPE = 'application/jose+json'
77

8-
def initialize(app, client:, mode:)
8+
def initialize(app, options)
99
super(app)
10-
@client = client
11-
@mode = mode
10+
@client = options.fetch(:client)
11+
@mode = options.fetch(:mode)
1212
end
1313

1414
def call(env)

lib/acme/client/resources/directory.rb

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def load_directory
7070
def fetch_directory
7171
connection = Faraday.new(url: @directory, **@connection_options) do |configuration|
7272
configuration.use Acme::Client::FaradayMiddleware, client: nil, mode: nil
73+
74+
configuration.adapter Faraday.default_adapter
7375
end
7476
connection.headers[:user_agent] = Acme::Client::USER_AGENT
7577
response = connection.get(@url)

0 commit comments

Comments
 (0)