应重定向到不工作

问题描述:

redirect_to在我的黄瓜测试中失败。该step_definition方法是应重定向到不工作

Then /^I should be redirected to "(.*)"$/ do |url| 
    response.should redirect_to(url) 
end 

在Rails 2.3.3我这样做:

redirect_to some_url, :status => 301 and return false 

我正在从application_controller.rb和返回false。当我I尾部看到它重定向test.log中尚未黄瓜测试仍然失败了

expected redirect_to ..., got no redirect 

黄瓜代码如下所示:

Given I go to "/blogs?page=1" 
Then I should be redirected to "/blogs" 

任何想法,我缺少的是什么?

+1

FYI返回false在before_filters里面什么都不做了http://dev.rubyonrails.org/changeset/7984 – BaroqueBobcat 2009-11-04 02:48:54

有时你只需要save_and_open_page。我发现黄瓜在任何时候都给我带来麻烦,这是因为会话这样的事情,我打开最终的页面来找到一个令人讨厌的Flash错误,或者说明了为什么我这次是一个白痴。 :)

不暗示你是一个白痴,只有我这样做,我认为。至少这是rspec在大多数时候似乎对我的看法。

可能会将'response.should redirect_to(url)'改为'response.should redirect_to(url,:status => 301)',除此之外我看不到任何错误。