如何使用capybara-webkit将消息发送到外部网络

时间:2015-06-25 09:13:18

标签: ruby-on-rails capybara capybara-webkit

假设用户正在更新其密码,然后单击“提交”,系统将发送一封电子邮件,其中包含指向其邮箱的确认链接。我的问题是:当我使用rspec + capybara-webkit测试我的系统时,如何收到电子邮件并单击确认链接,

1 个答案:

答案 0 :(得分:0)

希望您想通过打开它来测试ActionMailer的电子邮件。

请使用capybara-email gem

https://github.com/dockyard/capybara-email

你可以做以下事情

Scenario: Email is sent to winning user
  Given "me@example.com" is playing a game
  When that user picks a winning piece
  Then "me@example.com" receives an email with "You've Won!" as the subject

Then /^"([^"]*)" receives an email with "([^"]*)" as the subject$/ do |email_address, subject|
  open_email(email_address)
  expect(current_email.subject).to eq subject
end