Module | RR::DoubleDefinitions::DoubleDefinition::DefinitionConstructionMethods |
In: |
lib/rr/double_definitions/double_definition.rb
|
Double#after_call creates a callback that occurs after call is called. The passed in block receives the return value of the Double being called. An Expection will be raised if no block is passed in.
mock(subject).method_name {return_value}.after_call {|return_value|} subject.method_name # return_value
This feature is built into proxies.
mock.proxy(User).find('1') {|user| mock(user).valid? {false}}
Double#verbose sets the Double to print out each method call it receives.
Passing in a block sets the return value
Double#yields sets the Double to invoke a passed in block when the Double is called. An Expection will be raised if no block is passed in when the Double is called.
Passing in a block sets the return value.
mock(subject).method_name.yields(yield_arg1, yield_arg2) {return_value} subject.method_name {|yield_arg1, yield_arg2|}