[rspec-users] What is the best way to verify that yield is called?
ben at benmabey.com
Wed Apr 9 10:59:10 EDT 2008
>> it "should yield the given block" do
>> @block_yieled = false
>> create_message_in_factory do |message_delivery|
>> @block_yieled = true
>> @block_yieled.should be_true
>> Seems kinda hackish, but it did work. Is this the best way to spec this
>> or is there already a matcher for this?
> Another approach might be:
> it "should yield the given block" do
> block_body = mock("block body")
> create_message_in_factory_do | message_delivery |
Both of these way work but I think they are both too ugly and should be
created into a more expressive matcher.
Given the above two options can anyone see an advantage to one way or
the other? Or maybe another option is out there that is better?
More information about the rspec-users