From 5cf5ad303dce2d01e2e451ee87762677c37db45b Mon Sep 17 00:00:00 2001 From: Eric Mueller Date: Thu, 9 May 2024 09:38:09 -0400 Subject: [PATCH] In 1.8.7, Object#methods returns an array of strings Luckily, we already have some code in this very file that handles that situation, so we can just ride along. --- lib/rspec/matchers/built_in/has.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/rspec/matchers/built_in/has.rb b/lib/rspec/matchers/built_in/has.rb index 8cea6a47d..91d971829 100644 --- a/lib/rspec/matchers/built_in/has.rb +++ b/lib/rspec/matchers/built_in/has.rb @@ -51,7 +51,7 @@ def description # queries `has_receiveddd?`, the spy _fakes_ the method, returning its (truthy) self. def really_responds_to?(method) if defined?(RSpec::Mocks::Double) && @actual.is_a?(RSpec::Mocks::Double) - @actual.respond_to?(method) && @actual.methods.include?(method) + @actual.respond_to?(method) && methods_include?(method) else @actual.respond_to?(method) end @@ -70,11 +70,19 @@ def predicate_accessible? def private_predicate? @actual.private_methods.include? predicate.to_s end + + def methods_include?(method) + @actual.methods.include?(method.to_s) + end # :nocov: else def private_predicate? @actual.private_methods.include? predicate end + + def methods_include?(method) + @actual.methods.include?(method) + end end def predicate_result