From 44cbdf75d0ba399f0ee8cd55d5bca3462eb3b6b8 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 13 Jun 2022 13:00:37 +0200 Subject: [PATCH] Test against Class#new and not Class.new for the "is it #new from Class" check * On CRuby this makes currently no difference (there is no Class.new, only Class#new), but on TruffleRuby there is both (in order for Class objects to be fully initialized on creation). --- lib/rspec/mocks/method_reference.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec/mocks/method_reference.rb b/lib/rspec/mocks/method_reference.rb index 276202563..50608b01a 100644 --- a/lib/rspec/mocks/method_reference.rb +++ b/lib/rspec/mocks/method_reference.rb @@ -193,7 +193,7 @@ def self.applies_to?(method_name) end if RUBY_VERSION.to_i >= 3 - CLASS_NEW = ::Class.singleton_class.instance_method(:new) + CLASS_NEW = ::Class.instance_method(:new) def self.uses_class_new?(klass) ::RSpec::Support.method_handle_for(klass, :new) == CLASS_NEW.bind(klass)