title: Rspec: stubbing controller methods ineffective (before_filter, private)
body: <p>I am failing to stub a controller method even after reading dozens of threads and blog posts, so here's my situation:</p>
  
  <p><strong>My controller</strong>: app/controllers/my_controller.rb</p>
  
  <pre><code>class MyController &lt; ApplicationController
    before_filter :my_private_method, only:[:new]
  
    # ...
  
    private
  
    # This should be stubbed and not fire
    def my_private_method
      binding.pry
      redirect_to '/failure.html'
    end
  end
  </code></pre>
  
  <p><strong>My spec</strong>: spec/controllers/my_spec.rb</p>
  
  <pre><code>describe MyController do
    before :each do   
      controller.stub!(:my_private_method).and_return(true)
    end
  
    it 'should load' do
      binding.pry
      visit new_my_path
      response.status.should == 200
    end
  end
  </code></pre>
  
  <p>My system:</p>
  
  <p>ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]</p>
  
  <p>Rails 3.2.13</p>
  
  <p><strong>Any help?</strong></p>
  
  <p>Incidentally, I find when I use <code>binding.pry</code> to check <code>controller.object_id</code> in my <code>it 'should load'</code> block, I get a <em>different</em> object_id than when I check <code>self.object_id</code> in <code>my_private_method</code>.</p>