Module RR::DoubleDefinitions::DoubleDefinition::DefinitionConstructionMethods
In: lib/rr/double_definitions/double_definition.rb

Methods

Public Instance methods

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#implemented_by sets the implementation of the Double. This method takes a Proc or a Method. Passing in a Method allows the Double to accept blocks.

  obj = Object.new
  def obj.foobar
    yield(1)
  end
  mock(obj).method_name.implemented_by(obj.method(:foobar))

Double#ordered sets the Double to have an ordered expectation.

Passing in a block sets the return value.

  mock(subject).method_name.ordered {return_value}

Double#returns accepts an argument value or a block. It will raise an ArgumentError if both are passed in.

Passing in a block causes Double to return the return value of the passed in block.

Passing in an argument causes Double to return the argument.

strong()
then(&return_value_block)

Alias for ordered

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|}

Protected Instance methods

[Validate]