黄瓜/ Webrat没有关注redirect_to

时间:2010-09-03 13:34:05

标签: ruby-on-rails rspec cucumber webrat

我正在运行rails 3.0.0,rspec-rails 2.0.0.beta.20,webrat 0.7.2.beta.1,cucumber-rails 0.3.2 我有这种情况:

Scenario:
  Given I am on the new account page
  And I fill in "Name" with "John Doe"
  When I press "Create"
  Then I should be on the access page

当我跑步时,我得到:

expected: "/access",
got: "/accounts"

就像它不遵循控制器中的redirect_to一样:

#accounts_controller.rb
def create
  @account = Account.new(params[:account])
  if @account.save
    flash[:notice] = "Saved!"
    redirect_to access_url  
  else
    flash[:alert] = "Error!"
    render :new
  end
end

我错过了一步吗?我认为webrat遵循所有重定向。感谢

使用launchy gem我得到一个页面:

“您正被重定向”,其中包含指向access_path的链接

3 个答案:

答案 0 :(得分:2)

不确定这是否适用于Rails 3,但您可以尝试使用此方法“follow_redirect!”

答案 1 :(得分:0)

答案 2 :(得分:0)