Module: RR::DoubleDefinitions::DoubleDefinition::ArgumentDefinitionConstructionMethods
- Included in:
- RR::DoubleDefinitions::DoubleDefinition, SpyVerification
- Defined in:
- lib/rr/double_definitions/double_definition.rb
Instance Method Summary collapse
-
#with(*args, &return_value_block) ⇒ Object
Double#with sets the expectation that the Double will receive the passed in arguments.
-
#with_any_args(&return_value_block) ⇒ Object
Double#with_any_args sets the expectation that the Double can receive any arguments.
-
#with_no_args(&return_value_block) ⇒ Object
Double#with_no_args sets the expectation that the Double will receive no arguments.
Instance Method Details
#with(*args, &return_value_block) ⇒ Object
Double#with sets the expectation that the Double will receive the passed in arguments.
Passing in a block sets the return value.
mock(subject).method_name.with(1, 2) {:return_value}
46 47 48 49 50 51 |
# File 'lib/rr/double_definitions/double_definition.rb', line 46 def with(*args, **kwargs, &return_value_block) @argument_expectation = Expectations::ArgumentEqualityExpectation.new(args, kwargs) install_method_callback return_value_block self end |
#with_any_args(&return_value_block) ⇒ Object
Double#with_any_args sets the expectation that the Double can receive any arguments.
Passing in a block sets the return value.
mock(subject).method_name.with_any_args {:return_value}
67 68 69 70 71 |
# File 'lib/rr/double_definitions/double_definition.rb', line 67 def with_any_args(&return_value_block) @argument_expectation = Expectations::AnyArgumentExpectation.new install_method_callback return_value_block self end |
#with_no_args(&return_value_block) ⇒ Object
Double#with_no_args sets the expectation that the Double will receive no arguments.
Passing in a block sets the return value.
mock(subject).method_name.with_no_args {:return_value}
79 80 81 82 83 84 |
# File 'lib/rr/double_definitions/double_definition.rb', line 79 def with_no_args(&return_value_block) @argument_expectation = Expectations::ArgumentEqualityExpectation.new([], {}) install_method_callback return_value_block self end |