Eventuali duplicati:
Is it possible to specify a user agent in a rails integration test or spec?Come impostare HTTP_USER_AGENT nei test rspec
sto testando una richiesta nel mio rotaie applicazione utilizzando RSpec. Devo essere in grado di impostare l'agente utente prima della richiesta.
questo non sta funzionando:
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
fine
Come posso specificare correttamente l'user agent?
Se si intende contrassegnare una domanda come duplicata, potrebbe non essere una buona idea collegarsi al duplicato ?! – opsb