how to use capybara-webkit to get a message send to external network

46 views Asked by At

Assume a user is updating his password, and click submit, the system will send an email which include a confirmation link to his mailbox. My question is: how can I get the email and click the confirmation link when I use rspec+capybara-webkit test my system,

1

There are 1 answers

0
Rajarshi Das On BEST ANSWER

Hope you want to test email of ActionMailer by opening it.

Please use capybara-email gem

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

you can do below stuff

Scenario: Email is sent to winning user
  Given "[email protected]" is playing a game
  When that user picks a winning piece
  Then "[email protected]" 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