class RSpec::Mocks::ClassNewMethodReference

@private
This method reference implementation handles that specific case.
all args…so the method with the actually used signature is ‘#initialize`.
`def new(*args)` and it simply delegates to `#initialize` and forwards
signature from `#initialize` because `.new`’s signature is a generic
When a class’s ‘.new` method is stubbed, we want to use the method

def self.applies_to?(method_name)

def self.applies_to?(method_name)
  return false unless method_name == :new
  klass = yield
  return false unless ::Class === klass && klass.respond_to?(:new, true)
  # We only want to apply our special logic to normal `new` methods.
  # Methods that the user has monkeyed with should be left as-is.
  uses_class_new?(klass)
end

def self.uses_class_new?(klass)

def self.uses_class_new?(klass)
  ::RSpec::Support.method_handle_for(klass, :new) == CLASS_NEW.bind(klass)
end

def self.uses_class_new?(klass)

Ruby 2's Method#== is too strict
def self.uses_class_new?(klass)
  ::RSpec::Support.method_handle_for(klass, :new).owner == ::Class
end

def with_signature

def with_signature
  @object_reference.when_loaded do |klass|
    yield Support::MethodSignature.new(klass.instance_method(:initialize))
  end
end