测试用户注册与黄瓜 - 失败

时间:2011-04-09 21:36:47

标签: ruby-on-rails cucumber devise

我正在尝试测试用户注册。使用rails + devise 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 "me@gmail.com"
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

它只是测试失败,实际的注册功能很好。

2 个答案:

答案 0 :(得分:1)

这已在另一个堆栈溢出帖子中得到解答。基本上,flash消息不会通过redirect_to持久存在,但渲染:action => xxxx将使其有效。

authlogic flash[:notice] does not show up in cucumber webrat step

答案 1 :(得分:0)

我建议将Devise升级为最新版本(1.2,当前正在撰写)。

然后我会通过将Then show me the page置于失败的步骤之上来调试此处发生的事情。我认为你的flash消息是错误的。

相关问题