title: Rspec Stubbing Behavior
body: <p>I'm having some trouble with stubs, and I think I must be misunderstanding how they work.</p>
  
  <p>Do stubs only exist within the context that they are created? That is my expectation, but in my experience if I stub a method within a context it still exists in another context.</p>
  
  <p>my controller test is similar to this:</p>
  
  <pre><code>describe '.load_articles' do
    context 'articles' do
      before(:each) do
        Article.stub_chain(:meth1, :meth2).and_return(['article'])
      end
      it 'sets articles' do
        controller.load_articles.should == ['article']
      end
  
    end
    context 'no articles' do
      before(:each) do
        Article.stub_chain(:meth1, :meth2).and_return([])
      end
      it 'sets article' do
        controller.load_articles.should == []
      end
  
    end
  end
  </code></pre>
  
  <p>and for the second example <code>controller.load_articles</code> still returns <code>['article']</code> when I'm expecting <code>[]</code></p>
  
  <p>I've been stuck on this for too long; any help is greatly appreciated!</p>