2011-04-09 102 views
0

我試圖測試用戶註冊。使用Rails +設計1.1.rc2 我有這樣的測試:測試用戶註冊黃瓜 - 失敗

Given I am on the landing page 
When I go to the registration page 
And I fill in "Firstname" with "F" 
And I fill in "Lastname" with "L" 
And I fill in "Country" with "C" 
And I fill in "State" with "S" 
And I fill in "City" with "C" 
And I fill in "Email" with "[email protected]" 
And I fill in "Password" with "password" 
And I fill in "Password Confirmation" with "password" 
And I press "Register" 
Then I should see "You have registered successfully. If enabled, a confirmation was sent your e-mail." 

這是錯誤片段:

expected the following element's content to include "You have registered successfully. If enabled, a confirmation was sent your e-mail.": 
You are being redirected. (RSpec::Expectations::ExpectationNotMetError) 
./features/step_definitions/web_steps.rb:145:in `/^(?:|I)should see "([^"]*)"$/' 
features/registration.feature:42:in `Then I should see "You have registered successfully. If enabled, a confirmation was sent your e-mail." 

我認爲它有事情做一個重定向,不知道如何解決這個問題?但在我app_controller.rb我有這個所以用戶被引導到儀表板頁面...

def after_sign_in_path_for(resource_or_scope) 
    "/dashboard" 
end 

它只是測試這就是失敗的,實際的註冊功能是好的。

+0

太可怕了......介紹請乾淨,如果你想別人看 – apneadiving 2011-04-09 21:56:17

回答

0

我會推薦將Devise升級爲最新的版本(1.2,現在寫作)。

然後,我將通過將Then show me the page放在失敗的步驟之上來調試發生了什麼。我認爲你的Flash消息是錯誤的。

+0

感謝瑞安,我不知道launchy,我已經升級到1.2版本,並加入了一步,我已經安裝了launchy,但不斷收到此錯誤消息:「對不起,您需要安裝launchy才能打開頁面:'gem install launchy'」 - 然而,我已經運行系統並註冊並檢查了閃存消息,它符合預期的100%。你正在被重定向。可能是這個問題......我正在玩更多,所有的建議歡迎 – 2011-04-09 22:40:22

+0

到目前爲止沒有運氣......有趣的是,該功能在系統運行時工作,但黃瓜測試失敗... – 2011-04-09 23:21:45

+0

類似的東西是發生登錄。當我進入登錄頁面並登錄時,黃瓜測試不會找到閃光消息,因此該步驟失敗。我已經檢查過哪個頁面,它似乎在登錄而不是重定向到我的根頁面。當然,當我運行這個系統的時候,這一切都只是丹迪。我不確定這些重定向如何工作,但設計+黃瓜變成痛苦。你有這個問題嗎? – 2011-04-11 08:37:27