<div>On Tue, Nov 10, 2009 at 5:00 PM, David Chelimsky <span dir="ltr">&lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt;</span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br></div><div class="gmail_quote"><div>[1,2,3].should yield_on(:each) ???</div></div></blockquote><div><br></div><div>This does follow rspec syntax more closely... Let&#39;s run through a few use cases I can imagine.</div>

<div><br></div><div>current_user.stub!(:admin?).and_return(true)</div><div>helper.should yield_on(:admin_only)</div><div># helper.admin_only &amp;should_yield</div><div><br></div><div>[1,2,3].should yield_on(:each).each_of(1,2,3)</div>

<div># [1,2,3].each &amp;should_yield_each(1,2,3)</div><div><br></div><div>h = { :a =&gt; 1, :b =&gt; 2 }</div><div>h.should yield_on(:each).each_of(*h.to_a)</div><div>h.each &amp;should_yield_each(*h.to_a)</div></div><div class="gmail_quote">

<br><div>helper.should yield_on(:link_to_function, &quot;link text&quot;).with(an_instance_of(JavaScriptHelper::JavaScriptBuilder))</div><div>#  helper.link_to_function &quot;link text&quot;, &amp;should_yield_with(an_instance_of(JavaScriptHelper::JavaScriptBuilder))</div>

<div><br></div><div>I think both are pretty clear until the last example when this part in my format:  <b>&quot;link text&quot;, &amp;should_yield(...)</b>   starts to confuse what&#39;s going on exactly. It very clearly breaks from rspec syntax in that example.</div>

<div><br></div><div>helper.link_to_functio(&quot;link text&quot;, &amp;assert_yielded_block)</div><div><br></div><div>That actually makes a bit more sense since the intention is clear. I&#39;m passing a block that asserts that it will be yielded. However, this isn&#39;t rspec at all written like that.</div>

<div><br></div><div>The yield_on format seems to specify &quot;When I call this method on the receiver, I expect it to yield.&quot; This is very similar to user.should be_an_admin in that the actual method call is not being called on the receiver but passed into the matcher.</div>

<div><br></div><div>Is this something we&#39;d like to add to rspec? If so, I&#39;ll work out a patch.</div><div><br></div><div>Martin</div></div>