我有以下代码
require 'test_helper'
class ApplicationControllerTest < ActionController::TestCase
test "should display the page in german" do
get :index
assert_response :success
# ...
request.env["HTTP_REFERER"] = :index
# ...
end
end
如果我使用
运行此rails功能测试$ rake test:functionals
我收到此错误:
test_should_display_the_page_in_german(ApplicationControllerTest):
NameError: undefined local variable or method `request' for #<ApplicationControllerTest:0x1044c6d00>
如何访问“请求”变量?
答案 0 :(得分:6)
@request.env["HTTP_REFERER"] = :index
4.4可用的实例变量 您还可以在功能测试中访问三个实例变量:
@controller – The controller processing the request
@request – The request
@response – The response