On Fri, Nov 6, 2009 at 10:43 PM, Martin Emde <span dir="ltr">&lt;<a href="mailto:martin.emde@gmail.com">martin.emde@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>I have the code working for this but I wanted an opinion on making a patch.</div><div><br></div><div>I sometimes have the need to expect that a method will yield a block it&#39;s given. Usually this means something like this:</div>


<div><br></div><div>    yielded = false</div><div>    subject.method { yielded = true }</div><div>    yielded.should == true</div><div><br></div><div>which is a bit tedious and ugly. My solution might be just as ugly, but I wanted to get feedback because it saves that tedious code.</div>


<div><br></div><div>    subject.method(&amp;should_yield)</div><div><br></div><div>I wrote a few methods, that when called, return an object with #to_proc that expects that the proc is called (or not called). I have the following forms available fairly simply:</div>


<div><br></div><div>    subject.method(&amp;should_not_yield)</div><div>    subject.method(&amp;should_yield_with(object))</div><div><br></div><div>    # Expects 3 yields, one with each argument</div><div>    [1,2,3].each(&amp;should_yield_each(1,2,3))</div>


<div> </div><div>I think this is a little cleaner and the code is very simple. I wanted to get an opinion on whether this is worth making into a patch.</div><div><br></div><font color="#888888">Martin Emde<br>Tw: @martinemde</font></blockquote>
<div><br></div><div>Generally this looks really nice, and I can see the use, but it&#39;s so different from everything else that I need to think about it a bit more. Have you played around w/ any other syntax options that would be more aligned w/ the &quot;actual.should matcher&quot; format? Something like:</div>
<div><br></div><div>[1,2,3].should yield_on(:each) ???</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "> </span></font></blockquote>
</div>