0
我正在尝试重新设置密码的设备功能,但我在尝试测试邮件中的链接并访问链接的页面时遇到了一些问题。Rails-测试设计。重置密码。在邮件中打开链接
我曾尝试2种方法来做到这一点:
1)
scenario "User resets his password" do
user2 = FactoryGirl.create(
:user, reset_password_token: "new_password",
)
visit new_user_password_path
fill_in "Email", with: user2.email
click_on "Send me reset password instructions"
open_email(user2.email)
click_first_link_in_email
expect(page).to have_content("Reset your password")
end
如果我这样做,我得到的错误:
Failure/Error: click_first_link_in_email
ActionController::RoutingError:
No route matches [GET] "/1999/xhtml'"
2)
scenario "User resets his password" do
user2 = FactoryGirl.create(:user, reset_password_token: "new_password")
visit edit_user_password_path(reset_password_token:
expect(page).to have_content("Reset your password")
end
如果我这样做, l页说:
"You can't access this page without coming from a password reset email"
reset_password_token后:我有一个 user2.reset_password_token) – Wesley
第二个例子是可以理解的。它需要通过邮件并单击邮件中的重置密码链接。我会建议你使用[letter opener](https://github.com/ryanb/letter_opener)或[邮件捕获器](https://github.com/sj26/mailcatcher) – CallmeSurge
你为什么要测试这个@Westey?设计已经过测试和修补。我想你不应该担心这种测试。 – Guido