我有功能规格测试:
describe "Reset password" do
let(:last_email) { ActionMailer::Base.deliveries.last }
it "should be success" do
# ...
page.should have_content t("users.passwords.sent")
last_email.to.first.should eq user.email
last_email.body.should have_content t("mail.body.recovery_instructions")
# Here is click_link
page.should have_content t("passwords.updated")
end
end
如何点击位于last_email.body
的链接?
答案 0 :(得分:3)
您可以尝试这样的事情:
link = last_email.body.raw_source.match(/href="(?<url>.+?)">/)[:url]
visit link