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

David Chelimsky dchelimsky at gmail.com
Sun Mar 22 11:59:56 EDT 2009


On Sun, Mar 22, 2009 at 10:33 AM, Peter Jaros <peter.a.jaros at gmail.com> wrote:
> Going forward, what do people think about being able to say
>
> mock.should_receive(:debug).with_block  { |log_block|
>  # execute log_block, and check its return value
>  }
>
> Thoughts?

I like the idea, but I don't know how well it will play with other
sorts of expectations. We'd probably need to alias it with and_block
so you could say:

mock.should_receive(:message).with(:these, "args").and_block {|block| .... }

Would you please file a feature request for this?

Thanks,
David

>
> Peter
>
>
> On Sat, Mar 21, 2009 at 8:25 PM, Mark Wilden <mark at mwilden.com> wrote:
>> On Mon, Mar 16, 2009 at 4:00 AM, Yun Huang Yong <yun at nomitor.com> wrote:
>>>
>>> i.e. something like:
>>>  log_mock.should_receive(:debug) { |log_block|
>>>    # execute log_block, and check its return value
>>>  }
>>
>> I suppose you could always look at the source code for the debug
>> method, find out what it does with the result of the block and set an
>> expectation on that behavior.
>>
>> ///ark
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list