在rails测试中检测无限重定向

时间:2011-02-02 00:35:55

标签: ruby-on-rails testing integration-testing

在我的Ruby on Rails集成测试中,我有

assert_redirected_to buyer_deals_path(buyer)

这过去了。但是,实际上它会重定向到该页面,然后在无限重定向中重定向。反正有没有发现这个?或者更简单地说,检测到它重定向到那个页面并留在那里(没有重定向到其他地方)?

1 个答案:

答案 0 :(得分:2)

如果你在集成测试中这样做(我假设你是,从标签中),它实际上非常简单:

get "/whatever/caused/the/redirect"
assert_redirected_to buyer_deals_path(buyer)

follow_redirect!
assert_response 200

我认为follow_redirect!仅适用于集成测试,因此,如果您在功能测试中尝试这样做,则必须找到其他内容。