module Mocha::API
def mock(*arguments)
- Example: Using expected_methods_vs_return_values Hash to setup expectations. -
Parameters:
-
expected_methods_vs_return_values(Hash) -- expected method name symbols as keys and corresponding return values as values - these expectations are setup as if {Mock#expects} were called multiple times. -
name(String, Symbol) -- identifies mock object in error messages. -
expected_methods_vs_return_values(Hash) -- expected method name symbols as keys and corresponding return values as values - these expectations are setup as if {Mock#expects} were called multiple times. -
name(String, Symbol) -- identifies mock object in error messages.
Overloads:
-
def mock(name, expected_methods_vs_return_values = {}) -
def mock(expected_methods_vs_return_values = {}) -
def mock(name)
Returns:
-
(Mock)- a new mock object
def mock(*arguments) name = arguments.shift.to_s if arguments.first.is_a?(String) || arguments.first.is_a?(Symbol) expectations = arguments.shift || {} mock = name ? Mockery.instance.named_mock(name) : Mockery.instance.unnamed_mock mock.expects(expectations) mock end