Module: Mocktail::Bind
- Defined in:
- lib/mocktail/share/bind.rb,
lib/mocktail/sorbet/mocktail/share/bind.rb
Class Method Summary collapse
-
.call(mock, method_name, *args, **kwargs, &blk) ⇒ Object
sig intentionally omitted, because the wrapper will cause infinite recursion if certain methods are mocked.
Class Method Details
.call(mock, method_name, *args, **kwargs, &blk) ⇒ Object
sig intentionally omitted, because the wrapper will cause infinite recursion if certain methods are mocked
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/mocktail/share/bind.rb', line 4 def self.call(mock, method_name, *args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding if Mocktail.cabinet.double_for_instance(mock) 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 }) og_method.call(*args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding else mock.__send__(method_name, *args, **kwargs, &blk) # standard:disable Style/ArgumentsForwarding end end |