Fix "method redefined" warnings introduced in Faraday 2.7.5 (#1506)

* Print Ruby warnings when running specs

* Fix 'method redefined' warnings
This commit is contained in:
Matt Brictson 2023-06-07 01:46:49 -07:00 committed by GitHub
parent d40f3dbb99
commit 86298d0c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,8 @@
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec) do |task|
task.ruby_opts = %w[-W]
end
task default: :spec

View File

@ -174,6 +174,7 @@ module Faraday
memoized_attributes[key.to_sym] = block
class_eval <<-RUBY, __FILE__, __LINE__ + 1
remove_method(key) if method_defined?(key, false)
def #{key}() self[:#{key}]; end
RUBY
end

View File

@ -42,6 +42,7 @@ module Faraday
end
end
remove_method :params=
# Replace params, preserving the existing hash type.
#
# @param hash [Hash] new params
@ -53,6 +54,7 @@ module Faraday
end
end
remove_method :headers=
# Replace request headers, preserving the existing hash type.
#
# @param hash [Hash] new headers

View File

@ -6,11 +6,13 @@ module Faraday
class Instrumentation < Faraday::Middleware
# Options class used in Request::Instrumentation class.
Options = Faraday::Options.new(:name, :instrumenter) do
remove_method :name
# @return [String]
def name
self[:name] ||= 'request.faraday'
end
remove_method :instrumenter
# @return [Class]
def instrumenter
self[:instrumenter] ||= ActiveSupport::Notifications