我正在運行rails 3.0.0,rspec-rails 2.0.0.beta.20,webrat 0.7.2.beta.1,cucumber-rails 0.3.2 我有這種情況:黃瓜/ Webrat不遵循redirect_to
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
難道我想念g一步?我認爲webrat會遵循所有重定向。由於
使用launchy寶石,我得到一個網頁,上面寫着:
「你將被重定向」一個鏈接到access_path
?
你確定它沒有關注重定向嗎?也許表單無效,它會再次呈現新的動作?你可以嘗試'給我看看頁面'的步驟(你需要啓動寶石),看看它是不是顯示你錯過的任何錯誤? – Cimm 2010-09-03 13:41:49
謝謝你可以試試。無法看到它失敗的原因,即使我刪除渲染:新的它仍然會出現相同的... – Cameron 2010-09-03 13:50:22