2012-03-21 34 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