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

Mark Wilden mark at mwilden.com
Sun Mar 22 14:00:50 EDT 2009

On Mon, Mar 16, 2009 at 4:00 AM, Yun Huang Yong <yun at nomitor.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
>  }

Sorry - I don't quite understand. Do you want to test the logger debug
method's behavior when you pass it a certain block, or do you want to
test what the block itself does? If the former, it seems to me that
you wouldn't want to mock the logger object. If the latter, you can
just test the block directly.


More information about the rspec-users mailing list