Skip to content

Commit

Permalink
Add support for Ruby 3.2.0 in Faraday v1.x (#1483)
Browse files Browse the repository at this point in the history
* Run tests against Ruby 3.2

* Declare `DependencyLoader#new` with `ruby2_keywords` to fix Ruby 3.2.0

When adding a middleware that receives keyword arguments in the
constructor, the call from `DependencyLoader#new` fails because
the method is not defined using `ruby2_keywords`.

This adds the required `ruby2_keywords` declaration to
`DependencyLoader#new`, fixing the tests and getting Faraday v1.x
working with Ruby 3.2.0.

Fixes #1479.

Co-authored-by: Matt <iMacTia@users.noreply.github.com>
  • Loading branch information
timrogers and iMacTia committed Jan 18, 2023
1 parent d72db28 commit 16506ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
ruby: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']

steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 3 additions & 1 deletion lib/faraday/dependency_loader.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'ruby2_keywords'

module Faraday
# DependencyLoader helps Faraday adapters and middleware load dependencies.
module DependencyLoader
Expand All @@ -13,7 +15,7 @@ def dependency(lib = nil)
self.load_error = e
end

def new(*)
ruby2_keywords def new(*)
unless loaded?
raise "missing dependency for #{self}: #{load_error.message}"
end
Expand Down

0 comments on commit 16506ee

Please sign in to comment.