我开始使用 RSpec。我有一个新的 rails 3 应用程序,它使用 HTTP_ACCEPT_HEADER 或请求 2 字母子域来设置应用程序语言并相应地重定向。我正在使用 Cucumber 成功测试我的重定向代码。
现在我想编写我的 Controller 规范,我需要在测试之前设置请求子域。
在我的 cucumber 步骤中,我可以指定:
header 'HTTP_HOST', 'es.mysite.local'
visit '/'
但是当我尝试在规范文件中执行此操作时
header 'HTTP_HOST', 'es.mysite.local'
get 'index'
我收到此错误:
Failure/Error: header 'HTTP_HOST', "es.mysite.local"
LoadError:
no such file to load -- action_controller/integration
关于如何解决这个问题的任何线索?
最佳答案
试试这个:
request.env['HTTP_HOST'] = 'es.mysite.local'
get 'index'
关于ruby-on-rails - 设置 http header RSpec 2.4/Rails 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4947943/