title: Using webmock to stub partial headers
body: <p>I am creating tests using webmock. I want to test that a particular header field is set, but I don't care about other header fields. When I use this:</p>
  
  <pre><code>stub_request(:get, "https://myhost.com/api").
    with(:headers =&gt; {:user_agent =&gt; 'Custom user agent'}).
    to_return(:status =&gt; 200, :body =&gt; '')
  </code></pre>
  
  <p>I get an error because I am not stubbing all the headers:</p>
  
  <pre><code>Unregistered request: GET https://myhost.com/api with headers {'Accept'=&gt;'application/json', 'Accept-Encoding'=&gt;'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=&gt;'Custom user agent'}
  
  You can stub this request with the following snippet:
  
  stub_request(:get, "https://myhost.com/api").
    with(:headers =&gt; {'Accept'=&gt;'application/json', 'Accept-Encoding'=&gt;'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=&gt;'Custom user agent'}).
    to_return(:status =&gt; 200, :body =&gt; "", :headers =&gt; {})
  </code></pre>
  
  <p>I don't care about the Accept and Accept-Encoding headers - how do I stub so they are ignored?</p>