gpt4 book ai didi

ruby-on-rails - 使用 Cucumber 进行测试时出现“确认 token 无效”

转载 作者:行者123 更新时间:2023-12-04 06:13:12 24 4
gpt4 key购买 nike

我正在尝试获取与 Devise 合作的注册表单;我正在用 cucumber 测试它。

当用户注册时,我会发送一封确认电子邮件。但是,运行我的测试时出了点问题。

这是我的场景:

  Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| user@ticketee.com | password | true |
And "user@ticketee.com" 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 user@ticketee.com"

但是,我收到以下错误:
 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
我已经手动测试过这个(去注册并点击电子邮件中的确认链接),这很好用。只有当我通过 Cucumber 进行测试时,我才会收到“确认 token 无效”消息。有谁知道我该如何解决这个问题?我希望看到我的测试通过..

非常感谢。

编辑:评论中要求的步骤:
When /^(?:I|they|"([^"]*?)") opens? the email with subject "([^"]*?)"$/ do |address, subject|
open_email(address, :with_subject => subject)
end

点击链接:
When /^(?:I|they) click the first link in the email$/ do
click_first_link_in_email
end

我刚刚查看了收到的确认电子邮件,我的电子邮件地址被解析为 mailto: 链接;我将第一个链接步骤更改为:
And they follow "Confirm my account" in the email
但这也不起作用..我仍然收到无效 token 错误消息。

最佳答案

所以..我在这上面浪费了两个小时。我有一个错字。

我有以下几行:
unconfirmed = attributes.delete("unconfirmed") == "true"
我忘了在 true 周围加上引号.没有引号,测试通过..

天啊。

感谢所有花时间帮助我的人:)

关于ruby-on-rails - 使用 Cucumber 进行测试时出现“确认 token 无效”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7548504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com