class RSpec::Mocks::MessageExpectation

def and_yield(*args, &block)

stream.stub(:open).and_yield(StringIO.new)

@example

is received.
Tells the object to yield one or more args to a block when the message
def and_yield(*args, &block)
  yield @eval_context = Object.new if block
  @args_to_yield << args
  self.initial_implementation_action = AndYieldImplementation.new(@args_to_yield, @eval_context, @error_generator)
  self
end