是否可以在Rails集成测试或规范中指定用户代理? [英] Is it possible to specify a user agent in a rails integration test or spec?

查看:48
本文介绍了是否可以在Rails集成测试或规范中指定用户代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前在ActionController::IntegrationTest中的Rails 2应用程序中使用

I was doing this before in a rails 2 app in a ActionController::IntegrationTest with

get '/', {}, {:user_agent => "Googlebot"}

但这在Rails 3中似乎不再起作用.

but this seems to not work anymore in Rails 3.

我该怎么办?

推荐答案

如果在应用程序中使用request.user_agent,则可以编写以下代码:

If you use request.user_agent in your application, you can write the following code:

get '/', {}, { "HTTP_USER_AGENT" => "Googlebot" }

这篇关于是否可以在Rails集成测试或规范中指定用户代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆