2012-03-21 36 views
1

有沒有一種方法可以測試我們最終在rspec的預期路徑?Rspec確保我們結束了正確的路徑

喜歡的東西:

it "should be the forgot password path" do 
    response.should redirect_to(new_user_password_path) 
end 

這給了我一個錯誤:

Failure/Error: response.should redirect_to(new_user_password_path) 
ArgumentError: 
    @request must be an ActionDispatch::Request 

回答

1

我有這個問題一次,那是因爲水豚訪問方法不設置@requests變量,一個rails用來做重定向斷言(應該redirect_to調用rails assert_redirected_to)。

這很令人傷心,但是您必須以不同的方式進行測試,例如檢查頁面的內容。

+0

無賴。你的意思是「很傷心」? – 2012-03-21 16:25:42

+0

yep ahaha,typo = D – Castilho 2012-03-22 10:45:49