Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Test against Class#new and not Class.new for the "is it #new from Cla…
Browse files Browse the repository at this point in the history
…ss" 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).
  • Loading branch information
eregon authored and JonRowe committed Oct 25, 2022
1 parent ef9e17e commit 44cbdf7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec/mocks/method_reference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 44cbdf7

Please sign in to comment.