vendor/bundle/ruby/1.8/gems/rspec-mocks-2.9.0/lib/rspec/mocks/message_expectation.rb
# Constrains a stub or message expectation to invocations with specific
# arguments.
#
# With a stub, if the message might be received with other args as well,
# you should stub a default value first, and then stub or mock the same
# message using `with` to constrain to specific arguments.
#
# A message expectation will fail if the message is received with different
# arguments.
#
# @example
#
#   cart.stub(:add) { :failure }
#   cart.stub(:add).with(Book.new(:isbn => 1934356379)) { :success }
#   cart.add(Book.new(:isbn => 1234567890))
#   # => :failure
#   cart.add(Book.new(:isbn => 1934356379))
#   # => :success
#
#   cart.should_receive(:add).with(Book.new(:isbn => 1934356379)) { :success }
#   cart.add(Book.new(:isbn => 1234567890))
#   # => failed expectation
#   cart.add(Book.new(:isbn => 1934356379))
#   # => passes
Constrains a stub or message expectation to invocations with specific
arguments.

With a stub, if the message might be received with other args as well,
you should stub a default value first, and then stub or mock the same
message using `with` to constrain to specific arguments.

A message expectation will fail if the message is received with different
arguments.
Constrains a stub or message expectation to invocations with specific arguments . With a stub if the message might be received with other args as well you should stub a default value first and then stub or mock the same message using ` with ` to constrain to specific arguments . A message expectation will fail if the message is received with different arguments .
def with(*args, &block)
        @return_block = block if block_given? unless args.empty?
        @argument_expectation = ArgumentExpectation.new(*args, &block)
        self
      end
def with ( * args , & block ) @return_block = block if block_given? unless args . empty? @argument_expectation = ArgumentExpectation . new ( * args , & block ) self end
Constrains a stub or message expectation to invocations with specific
arguments.
Constrains a stub or message expectation to invocations with specific arguments .
args
block
example
None