Skip to content

Instantly share code, notes, and snippets.

@tkhduracell
Last active August 29, 2015 14:05
Show Gist options
  • Save tkhduracell/b17b2f2886cfe0d41c91 to your computer and use it in GitHub Desktop.
Save tkhduracell/b17b2f2886cfe0d41c91 to your computer and use it in GitHub Desktop.
Capybara::Email Cheatsheet
# Returns the currently set email.
current_email
# Returns a collection of all current emails retrieved.
current_emails
# Access all emails.
all_emails
# Clear the email queue.
clear_emails
#Access all emails for a recipient.
emails_sent_to(recipient)
# Access the first email for a recipient and set it to.
first_email_sent_to(recipient)
open_email(recipient)
# Nokogiri object for traversing content.
current_email.body
current_email.dom
# Plain text email contents.
current_email.raw
# String version of email HTML source.
current_email.source
#
# Assertions
#
# Assert content
expect(current_email).to have_content "my content"
# Assert headers
expect(current_email.header('reply-to')).to eq "reply-to@address"
# Click on link
current_email.click_on 'my link'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment