2009-07-08 41 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