2011-04-09 87 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