<span class="gmail_quote">On 1/10/08, <b class="gmail_sendername">David Chelimsky</b> &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; wrote:</span><br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
album = mock(&quot;album&quot;)<br>songs = mock(&quot;songs&quot;)<br>album.stub!(:songs).and_return(songs)<br>songs.stub!(:streamable).and_return(true)<br><br>That&#39;s the general idea. Specifics will vary for each example.
</blockquote><div><br>If I do this, I end up with a mock object when I call @album.songs. I need that object to act like a Rails association -- so it should respond to #each, #first, and all our other Enumerable friends, since my view iterates over it, as well as the stubbed call to #streamable, which returns a &quot;filtered&quot; version of the assocation (see Rails code in OP). But I certainly don&#39;t want to start stubbing Enumerable methods.
<br><br># Let&#39;s say song1, song2, and song3 are instances of Song.<br># Song has a boolean attribute, streamable.<br># song1.streamable? =&gt; true<br># song2.streamable? =&gt; true<br># song3.streamable? =&gt; false<br>
album = mock(&quot;album&quot;)<br>songs = mock(&quot;songs&quot;)<br>album.stub!(:songs).and_return(songs)<br>songs.stub!(:streamable).and_return([song1, song2])<br><br>So now album.songs.streamable returns [song1, song2] -- perfect. But I need 
album.songs to return [song1, song2, song3] as well. That&#39;s the problem.<br><br>I hope that&#39;s a little clearer. Thanks for the help.<br><br>Chris<br></div></div>