Ruby on rails Rspec确保我们的路线正确

Ruby on rails Rspec确保我们的路线正确,ruby-on-rails,rspec,routes,Ruby On Rails,Rspec,Routes,有没有办法用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 A

有没有办法用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

我曾经遇到过这个问题,这是因为capybara visit方法没有设置@requests变量,rails使用该变量来执行重定向断言(should redirect_to调用rails assert_redirected_to)


遗憾的是,您必须以不同的方式进行测试,比如检查页面内容。

我曾经遇到过这个问题,这是因为capybara-visit方法没有设置@requests变量,rails使用该变量来执行重定向断言(应该重定向到调用rails断言重定向到)

这很糟糕,但你必须以不同的方式进行测试,比如检查页面内容。

Bummer。你是说“很伤心”吗?糟糕。你是说“很悲伤”吗?