[rspec-users] Testing return value of a block argument

Mark Wilden mark at mwilden.com
Mon Mar 16 12:03:26 EDT 2009

On Mon, Mar 16, 2009 at 8:33 AM, Nick Hoffman <nick at deadorange.com> wrote:
>> Is there any way to test what the resultant log message is from evaluating
>> the block?
>> i.e. something like:
>>  log_mock.should_receive(:debug) { |log_block|
>>    # execute log_block, and check its return value
>>  }
> Hi Yun. Have a look at #and_yield , described at
> http://rspec.info/documentation/mocks/message_expectations.html .

That was my first thought, but and_yield stubs what the method will
yield, not what it should yield. It's like and_return.


More information about the rspec-users mailing list