title: rspec view stubs and partials
body: <p>I'm testing a view with RSpec (2.12 on Rails 3.2.8). I'm using CanCan to conditionally display certain elements on a page. This requires a controller method 'current_user'. In some of my specs I've been able to stub out current_user, eg.
      controller.stub(:current_user).and_return(etc) 
  or 
      view.stub.etc . </p>
  
  <p>This works for some of my specs. But I've got a couple where it's not working and I don't understand why.</p>
  
  <p>The two specs where it's not working test a view, which calls down into a partial, and inside the partial I access 'current_user' as a method. The error is  </p>
  
  <pre><code>undefined local variable or method `current_user' 
  </code></pre>
  
  <p>So I guess my question is how to stub methods correctly so that they can be accessed down inside partials.</p>
  
  <p>How should it be done?</p>