title: RSpec Request - How to set http authorization header for all requests
body: <p>I'm using rspec request to test a JSON API that requires an api-key in the header of each request. </p>
  
  <p>I know I can do this:</p>
  
  <pre><code>get "/v1/users/janedoe.json", {}, { 'HTTP_AUTHORIZATION'=&gt;"Token token=\"mytoken\"" }
  </code></pre>
  
  <p>But it is tedious to do that for each request. </p>
  
  <p>I've tried setting <code>request.env</code> in the before block, but I get the <code>no method NilClass error</code> since request doesn't exist. </p>
  
  <p>I need some way, maybe in the <code>spec-helper</code>, to globally get this header sent with all requests. </p>