在 Rails 功能测试中发送浏览器字符串
应用程序应该根据浏览器设置设置区域设置,但我不知道如何测试它。我不知道我可以提供什么代码示例来解释,但测试是这样的:
def test_locale_settings
get :index, {}, {:user_id => 1} # send browser settings to english
assert_select '.nav .welcome', :text => 'Welcome'
get :index, {}, {:user_id => 1} # send browser settings to spanish
assert_select '.nav .welcome', :text => 'Bienvenido'
end
The application should set the locale based on browser settings, but I don't realize how to test it. I don't know what code sample could I provide to explain, but the test is something like this:
def test_locale_settings
get :index, {}, {:user_id => 1} # send browser settings to english
assert_select '.nav .welcome', :text => 'Welcome'
get :index, {}, {:user_id => 1} # send browser settings to spanish
assert_select '.nav .welcome', :text => 'Bienvenido'
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否有效,但请尝试一下:
当然,您的应用程序需要知道如何解析 HTTP Accept Language 标头的格式。
Not sure if this works, but give it a try:
Of course your application will need to know how to parse the format of the HTTP Accept Language header.