title: Playing a cassete whose request is not inside the use_cassete scope using VCR for Rails
body: <p>I've built an API (<code>MyAPI</code>) that connects to an external API for authentication (<code>ExAPI</code>).</p>
  
  <p>For all the requests to MyAPI where the user needs to be authenticated, he sends a cookie with a token that is then sent to ExAPI, and then it gets the user information.</p>
  
  <p>I've recorded a cassete with this request:</p>
  
  <pre><code>describe 'VCR-RSpec integration' do
    def make_http_request
      connect = Faraday.new(url: (ENV['EX_API']).to_s) do |faraday|
        faraday.request :url_encoded
        faraday.response :logger 
        faraday.adapter Faraday.default_adapter 
      end
      connect.authorization :Bearer, ENV['USER_TOKEN']
      connect.get('/auth/...')
    end
  
    skip 'without an explicit cassette name' do
      it 'records an http request' do
        VCR.use_cassette('user_token') do
          expect(make_http_request).to be_success
        end
      end
    end
  end
  </code></pre>
  
  <p>So, in my code, if I do a call to <code>user_stories</code> it expects a cookie with the <code>user_token</code> sends it to the ExAPI and if valid, executes the desired action.</p>
  
  <p>This is how the spec is:</p>
  
  <pre><code>describe UserStoriesController, type: :controller do
    before(:each) do
      set_cookies
    end
  
    context do
      let!(:user) {
        FactoryGirl.create(:user)
      }
      let!(:some_user_stories) {
        FactoryGirl.create_list(:user_story, 3, user: user)
      }
  
      describe 'GET index' do
        it 'returns a successful 200 response' do
          VCR.use_cassette('user_token') do
            get :index
            expect(response).to be_success
          end
        end
      end
    end
  end
  </code></pre>
  
  <p>The problem is that the cassete is not used (I'm assuming that it's because the code to connect to the ExAPI is not inside the <code>VCR.use_cassete</code> scope, but in a method inside the controller.</p>
  
  <p>Is that a way to do this?</p>
  
  <p>Thanks</p>