title: Stubbing 3rd party API calls in Rails integration tests
body: <p>I have a <code>TwitterAPI</code> class defined, which interacts with Twitter's API.  The methods in the module make two separate API calls.  So I have two WebMock <code>stub_request</code>s defined in before blocks in my unit tests for the <code>TwitterAPI</code> class.</p>
  
  <p>I am writing capybara/rspec-based integration tests now.  Some of the test scenarios involve pages that use Twitter API data, e.g.:</p>
  
  <pre><code>feature 'View Twitter feed,' do
  
    let(:twitter_feed_page)      { TwitterFeedPage.new }
    let(:user)                   { FactoryGirl.create :user }
  
    scenario "Twitter feed is displayed" do
      login(user)
      twitter_feed_page.load
      expect(twitter_feed_page).to have_text("Test tweet")
      # etc.
    end
  end
  </code></pre>
  
  <p>I want these integration tests to use the same stubbed data as my unit tests. So the stub_requests will be shared among multiple tests.  Should I just move the stub_requests I've defined to my <code>rails_helper.rb</code> and have some sort of flag that allows specific tests to use the stubs?  Or should I just copy/paste the stub_requests to the integration test itself?  Having multiple copies of the stub requests is not the DRY way to do this, but it seems easier to read/understand how the stubbing works.</p>