Sha256: 782ad6168f2f355ffd03bd59afe9e60834dee99910940884905d82d74aae121b

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

# typed: true

module Mocktail
  module Bind
    # sig intentionally omitted, because the wrapper will cause infinite recursion if certain methods are mocked
    def self.call(mock, method_name, *args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding
      if Mocktail.cabinet.double_for_instance(mock)
        T.unsafe(Object.instance_method(method_name)).bind_call(mock, *args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding
      elsif (mock.is_a?(Module) || mock.is_a?(Class)) &&
          (type_replacement = TopShelf.instance.type_replacement_if_exists_for(mock)) &&
          (og_method = type_replacement.original_methods&.find { |m| m.name == method_name })
        T.unsafe(og_method).call(*args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding
      else
        T.unsafe(mock).__send__(method_name, *args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mocktail-2.0.0 lib/mocktail/sorbet/mocktail/share/bind.rb