<br><br><div><span class="gmail_quote">On 7/6/07, <b class="gmail_sendername">Daniel N</b> &lt;<a href="mailto:has.sox@gmail.com">has.sox@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div><span class="q"><span class="gmail_quote">On 7/6/07, <b class="gmail_sendername">David Chelimsky</b> &lt;<a href="mailto:dchelimsky@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
dchelimsky@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 7/5/07, Daniel N &lt;<a href="mailto:has.sox@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">has.sox@gmail.com</a>&gt; wrote:<br>&gt; Hi,<br>&gt;<br>&gt; I&#39;m very new to rspec so please be patient with me.
<br>&gt;<br>&gt; I&#39;ve tried to take some of my tests out of the controller specs to check for
<br>&gt; things that are rendered.<br>&gt;<br>&gt; This has not worked so well, since my views have the controller method<br>&gt;<br>&gt; current_user<br>&gt;<br>&gt; in quite a few places.<br>&gt;<br>&gt; Is there any way that I can define this so that my views will be executed?
<br>&gt; Will this same thing occur for all helper methods that are definied in the<br>&gt; controller?<br><br>If I understand you correctly, you are trying to take tests for views<br>that were previously rails functional tests and turn them into rspec
<br>view examples. If that is the case, you should be able to do this:<br><br>template.stub!(:current_user).and_return(mock_model(User))<br><br>If not, please provide an explicit example so we can better understand<br>what you&#39;re talking about.
<br><br>Cheers,<br>David</blockquote></span><div><br><br>Thanx David,&nbsp; <br><br>That looks like what I was looking for.&nbsp; <br><br>I will try it when I get home.<br><br>Cheers<br>Daniel</div></div></blockquote><div><br>Ok I&#39;ve started to have a crack at this but it&#39;s getting way out of hand. &nbsp; Everytime I stub a method there&#39;s another one to do.&nbsp; 
<br><br>I&#39;ve also found that when there&#39;s a partial _detail and I&#39;ve passed the :collection =&gt; @things to it it blows up complaining that the local variable is nil in<br>dom_id( detail )<br><br>Am I doing someting wrong?&nbsp; The start of my specs is 
<br><br>&nbsp; before do<br>&nbsp;&nbsp;&nbsp; @u = mock_model( User )<br>&nbsp;&nbsp;&nbsp; @book = mock_model( Book )<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; public_book = mock_model( Book )<br>&nbsp;&nbsp;&nbsp; private_book = mock_model( Book )<br>&nbsp;&nbsp;&nbsp; public_book.stub!(:title=).and_return( &quot;Public Title&quot; )
<br>&nbsp;&nbsp;&nbsp; private_book.stub!(:title=).and_return( &quot;Private Title&quot; )<br>&nbsp;&nbsp;&nbsp; public_book.stub!( :title ).and_return( &quot;Public Title&quot; )<br>&nbsp;&nbsp;&nbsp; private_book.stub!( :title ).and_return( &quot;Private Title&quot; )
<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; @u.stub!( :public_books ).and_return( [public_book] )<br>&nbsp;&nbsp;&nbsp; @u.stub!( :private_books ).and_return( [private_book] )<br>&nbsp;&nbsp;&nbsp; @clip = mock_model( Clip )<br>&nbsp;&nbsp;&nbsp; @clip.stub!( :id ).and_return( 1 )<br>&nbsp;&nbsp;&nbsp; @clips = [ @clip ]
<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; template.stub!( :current_user ).and_return( @u )<br>&nbsp; end<br><br>and I&#39;ve only started.&nbsp; Is it normal to have to stub this much for a view?<br><br>Cheers<br>Daniel<br></div><br></div><br>