Duplicar posible:
Is it possible to specify a user agent in a rails integration test or spec?Cómo establecer HTTP_USER_AGENT en las pruebas rspec
Estoy probando una petición en mi rieles aplicación usando rspec. Necesito poder configurar el agente de usuario antes de la solicitud.
Esto no está funcionando:
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
final
¿Cómo puedo especificar correctamente el agente de usuario?
Si va a marcar una pregunta como un duplicado, ¿no sería una buena idea vincular el duplicado? – opsb