title: RSpec.configure and the request object
body: <p>I have a Rails 3.1 application that is being built out as a RESTful API.  The plan is to handle authentication based on an API key that is passed on each request via the Authorization HTTP header.  In order to test this in RSpec, I wanted to set the <code>request.env["HTTP_AUTHORIZATION"]</code> attribute in the <code>config.before</code> block:</p>
  
  <pre class="lang-rb prettyprint-override"><code>RSpec.configure do |config|
    config.mock_with :rspec
    config.use_transactional_fixtures = true
    config.before(:each) do
      # Set API key in Authorization header
      request.env["HTTP_AUTHORIZATION"] = "6db13cc8-815f-42ce-aa9e-446556fe3d72"
    end
  end
  </code></pre>
  
  <p>Unfortunately, this throws an exception because the <code>request</code> object doesn't exist in the <code>config.before</code> block.</p>
  
  <p>Is there another approach to setting this header outside of including
  it in the <code>before</code> block of each controller test file?</p>