title: How to set HTTP_USER_AGENT in rspec testing
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4383971/is-it-possible-to-specify-a-user-agent-in-a-rails-integration-test-or-spec">Is it possible to specify a user agent in a rails integration test or spec?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm testing a request in my rails app using rspec. I need to be able to set the user agent before the request. </p>
  
  <p>This is not working: </p>
  
  <pre><code>  describe "GET /articles feed for feedburner" do
  it "displays article feed if useragent is feedburner" do
    # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
    @articles=[]
    5.times do
      @articles &lt;&lt; Factory(:article, :status=&gt;1, :created_at=&gt;3.days.ago)
    end
    request.env['HTTP_USER_AGENT'] = 'feedburner'
    get "/news.xml" 
    response.should be_success
    response.content_type.should eq("application/xml")
    response.should include("item[title='#{@articles.first.title}']")
  end
  </code></pre>
  
  <p>end</p>
  
  <p>How can I properly specify the user agent? </p>