2013-06-04 48 views
4

試圖得到一個非常簡單的場景用黃瓜和設計路過的時候重定向到example.com - 在用戶簽名...(EPIC FAIL)嘗試與水豚,黃瓜,RSpec的登錄,並制定

我有像這樣的步驟:

user = create(user_sym) 
user.confirm! 

visit new_user_session_path 
fill_in 'Email',:with => user.email 
fill_in 'Password',:with => attributes_for(user_sym)[:password] 
click_button 'Sign in' 
page.should have_content('Sign out') 

日誌告訴我一切都很好(確認電子郵件發送,UPDATE插入正確的確認標誌),然後我看到了重定向到

www.example.com 

很多職位這裏nd其他地方提到這一點,並使用login_user:callback => false使它工作,但我想使用「訪問」。

什麼可以導致此。實際的錯誤是失敗的測試,即註銷文本沒有出現。正在呈現的是Rails主頁,即

expected there to be text "Sign out" in "Browse the documentation Rails Guides Rails API Ruby core Ruby standard library Welcome aboard 

我不知道哪部分堆棧正在拋出(因爲我是新的!)。據推測,水豚重新定向?我已經看到人們得到這個工作,並且在我的Dev堆棧中,它顯然會按照您的預期重定向到用戶索引頁面。

任何光讚賞。

+1

你從刪除'index.html'的'公共目錄並在你的'routes.rb'文件中配置'root'? – muttonlamb

回答

1

我解決了這個問題在ApplicationController中返回的after_sign_in_path_for具體路徑

def after_sign_in_path_for(resource) 
    xxxxx_path 
    end 

不知怎的,在黃瓜測試根路徑被重定向到「example.com」

+0

我發現example.com是Capybara測試的默認域名。因此root_path將指向「www.example.com/」,而users_path將在測試環境中運行時指向「www.example.com/users」。 – georgelx