2013-06-04 50 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