title: stub an instance variable inside controller
body: <p>I'm using rspec 1.3.2 to test a controller action that looks something like this:</p>
  
  <pre><code>def action_foo
    ...
    @bar.can_do_something?
    ...
  end
  </code></pre>
  
  <p>I'm trying to stub <code>@bar</code> (assume it's an instance of class <code>Bar</code>) instance variable but am unable to. I think if I had access to <code>any_instance</code> then I could do <code>Bar.any_instance.stub(:can_do_something?)</code> but that's not available in the version of rspec I am using.</p>
  
  <p>Is there another way to access and stub <code>@bar</code>? None of the following worked:</p>
  
  <pre><code>@bar.stub(:can_do_something?)
  controller.instance_variable_get("@bar").stub(:can_do_something?)
  controller.stub_chain(:bar, :can_do_something?)
  Bar.new.stub(:can_do_something?)
  </code></pre>
  
  <p>Edit:</p>
  
  <p><code>@bar</code> is assigned in a <code>before_filter</code>. something like <code>@bar = Bar.find(n)</code></p>