class RSpec::Mocks::MessageExpectation

def and_return(first_value, *values, &_block)

Returns:
  • (nil) - No further chaining is supported after this.

Overloads:
  • and_return(first_value, second_value)
  • and_return(value)
def and_return(first_value, *values, &_block)
  raise_already_invoked_error_if_necessary(__method__)
  if negative?
    raise "`and_return` is not supported with negative message expectations"
  end
  if block_given?
    raise ArgumentError, "Implementation blocks aren't supported with `and_return`"
  end
  values.unshift(first_value)
  @expected_received_count = [@expected_received_count, values.size].max unless ignoring_args? || (@expected_received_count == 0 && @at_least)
  self.terminal_implementation_action = AndReturnImplementation.new(values)
  nil
end