Module: Stubberry::Assertions

Defined in:
lib/stubberry/assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_method_called(object, method, inspect_params_callable = nil, &block) ⇒ Object

controlling the flow with minimum side effects



6
7
8
9
10
11
12
# File 'lib/stubberry/assertions.rb', line 6

def assert_method_called(object, method, inspect_params_callable = nil, &block)
  object_unbound_method = object.method(method.to_sym).unbind
  object.stub_must(method, ->(*args, **kwargs, &blk) {
    inspect_params_callable&.call(*args, **kwargs)
    object_unbound_method.bind(object).call(*args, **kwargs, &blk)
  }, &block)
end