2009-07-08 38 views
0

我有我的Rails应用程序黄瓜步:如何获得在黄瓜步骤中从机架返回的响应?

Then /^I should be redirected to the sign in page$/ do 
    assert_equal 302, @response.status 
end 

但是@response对象是我Controller返回的一个,它的机架中间件状态设置为我所期望的那样。我如何获得从最外层中间件返回的响应,而不是从控制器返回的响应?

回答

-1

尝试使用只有response没有'@'。它会给你WebRat看到的响应对象。

0

从你的步骤定义这听起来像你应该测试你是否是在登录页,你不是是否得到了302但是,为了走你的路,这里的步骤:

Then /^I should be redirected to the sign in page$/ do |url| 
    assert @integration_session.status == 302, "Expected status to be 302, got #{@integration_session.status}" 
end