title: Why can't I access the controller object in RSpec when testing a controller?
body: <p>I'm using rspec-rails, version 1.2.6. In a controller test</p>
  
  <pre><code>describe WebsController do ...
  </code></pre>
  
  <p>I don't seem to have access to the controller object in order to stub methods. For example, the following won't work:</p>
  
  <pre><code>  before :all do
      @feed = mock_model(Feed)
      controller.should_receive(:feed_from_params).and_return @feed    
    end
  </code></pre>
  
  <p>I get warnings like </p>
  
  <pre><code>An expectation of :feed_from_params was set on nil. 
  </code></pre>
  
  <p>and firing up a debug session from the spec tells on the line just before the method mock, I get the following:</p>
  
  <pre><code>(rdb:1) self.respond_to? :controller
  true
  (rdb:1) controller
  nil
  </code></pre>
  
  <p>From all the examples, accessing the controller variable should work, but it doesn't. What gives? How can I mock or stub methods in a controller under test?</p>