我正在使用rspec在我的rails应用程序中测试请求.我需要能够在请求之前设置用户代理.
这不起作用:
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 << Factory(:article, :status=>1, :created_at=>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
Run Code Online (Sandbox Code Playgroud)
结束
如何正确指定用户代理?