Well, if articles is already scoped, you just say:<br><br>user.should_receive(&#39;articles&#39;).and_return(some_articles)<br><br>To make sure your articles method is scoped, write a model test that hits the database, and verify that only the user&#39;s articles are returned.
<br><br>As Daniel Tenner says, you should try to keep your controllers as thin as possible. In addition you should try to keep your tests as fast as possible - and you typically do that by not hitting the DB.<br><br>Stefan
<br><br><div><span class="gmail_quote">2007/12/3, Fischer, Daniel &lt;<a href="mailto:me@danielfischer.com">me@danielfischer.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
yuck, that seems kind of nasty, no?<div><br></div><div>user.articles is already scoped...</div><div><br></div><div>There has to be a different solution!<div><span class="e" id="q_1169f958499f6230_1"><br>
<br><div class="gmail_quote">On Dec 3, 2007 2:07 AM, Stefan Magnus Landrø &lt;<a href="mailto:stefan.landro@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">stefan.landro@gmail.com</a>&gt; wrote:
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Typically, I&#39;d write a method in your user model that returns the user&#39;s articles:<br><br>class User do<br><br>&nbsp; def find_articles_for_user<br>&nbsp;&nbsp; Article.find(:all, :conditions =&gt; [&#39;userid = ?&#39;, id)<br>

&nbsp; end
<br><br>end<br><br>Then you&#39;d use a mock in your controller spec, and make sure you test that your method is being called.<br><br>On the other hand, the user model should be tested directly against the db.<br><br>HTH,
<br><br>Stefan<br><br><div><span class="gmail_quote">2007/12/3, Fischer, Daniel &lt;<a href="mailto:daniel@helpmebuyacar.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">daniel@helpmebuyacar.org
</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>
Let&#39;s say you&#39;re using the restful_authentication plugin.<div><br></div><div>You have a model called articles. On the index action of the articlescontroller you simply want to spec out that it&#39;ll scope the results to the ownership of the current_user.
</div><div><br></div><div>It should NOT include any articles other than the articles that user owns.</div><div><br></div><div>How would you properly spec this out?&nbsp;
</div><div><br></div><div>Thanks for the help!</div></div></div>
<br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rspec-users@rubyforge.org
</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>Bekk Open Source<br><a href="http://boss.bekk.no" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://boss.bekk.no</a>
</font><br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">rspec-users@rubyforge.org
</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br></span></div></div>
<br>_______________________________________________<br>rspec-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Bekk Open Source<br><a href="http://boss.bekk.no">http://boss.bekk.no</a>