-
Notifications
You must be signed in to change notification settings - Fork 53
sample devise spec with rspec, factory girl, launchy and capybara email
shicholas edited this page Mar 8, 2013
·
2 revisions
Before I start, I must admit I'm a still noob and had problems digesting what 'email_trigger_path' meant in the README. I was looking for a route in sextant that would match an e-mail path to no avail.
Anyways, here is how I tested the reset password email that devise provides through its recoverable module with capybara-email:
feature 'UserEmails' do
let(:user) {create(:user)}
background do
clear_emails
end
scenario 'reset password through email' do
visit new_user_password_path
fill_in "Email", with: user.email
click_on "Send me reset password instructions"
last_email.to.should include(user.email)
open_email(user.email)
# current_email.save_and_open # this will open the email in your browser
current_email.first(:link, 'Change my password').click #first is used because the e-mail has both a text and html version
# save_and_open_page # this will open the linked page in your browser
page.should have_content 'New password'
page.should have_content 'Confirm your new password'
end
end
not the most elegant code but it got the job done.