我正在尝试使用Devise获得注册表单;我正在用黄瓜进行测试。当使用Cucumber进行测试时,'确认令牌无效'
当用户注册时,我发送一封确认电子邮件。不过,运行我的测试时出现了问题。
这是我的情景:
Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| [email protected] | password | true |
And "[email protected]" opens the email with subject "Confirmation instructions"
And they click the first link in the email
Then I should see "Your account was successfully confirmed."
And I should see "Signed in as [email protected]"
不过,我得到以下错误:
expected there to be content "Your account was successfully confirmed. You are now signed in." in "\n Ticketee\n \n\nTicketee\nSign up\n Sign in\nResend confirmation instructions\n\n\n \n 1 error prohibited this user from being saved:\n Confirmation token is invalid\n\n\n Email\n\n \n\n Sign inSign upForgot your password?" (RSpec::Expectations::ExpectationNotMetError)
我想这里最重要的部分是:
1 error prohibited this user from being saved:\n Confirmation token is invalid
我有手动测试(注册并点击确认链接在电子邮件),这工作正常..只有当我通过黄瓜测试,我得到'确认令牌是无效'的消息。任何人都知道我可以解决这个问题?我想看到我的测试通过..
非常感谢。
编辑:步骤在评论中问:
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
open_email(address, :with_subject => subject)
end
clicking链接:
When /^(?:I|they) click the first link in the email$/ do
click_first_link_in_email
end
我只是看着确认的电子邮件,我得到了我的电子邮件地址解析为一个mailto :link;我改变了第一个链接步骤如下:
And they follow "Confirm my account" in the email
,但没有工作,要么..我仍然得到无效的令牌错误消息。
您可以发布涉及打开电子邮件并点击该链接的步骤步骤定义。 –
@AndyWaite我更新了这篇文章:) – cabaret
啊,你正在使用email_spec宝石?也许值得一提的是,我相信生成的电子邮件会出现在test.log中,因此请在那里检查并查看是否有正确的链接。 –