Created
June 27, 2011 18:50
-
-
Save nruth/1049494 to your computer and use it in GitHub Desktop.
testing devise password recovery email with email_spec and capybara / rspec request spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "member password recovery" do | |
# As a member who forgot my password | |
# I want to recover my site access easily | |
# | |
attr_accessor :current_email_address | |
specify "email recovery of a new password" do | |
member = make_activated_member | |
original_password = member.password | |
visit dashboard_path | |
click_on "Forgot your password?" | |
fill_in "Email", :with => member.email | |
click_on "Send me reset password instructions" | |
self.current_email_address = member.email | |
# EmailSpec::EmailViewer::save_and_open_all_raw_emails | |
unread_emails_for(member.email).should be_present | |
open_email member.email, :with_subject => "Reset password instructions" | |
click_first_link_in_email | |
page.should have_content("Your password is") | |
new_password = page.find('#member_password').text | |
#the password should have changed | |
new_password.should_not == original_password | |
# and I should be signed in | |
visit dashboard_path | |
should_not_see_member_login | |
should_see_member_dashboard | |
#and I should be able to log in with the new password | |
log_out | |
member_log_in_as(member.email, new_password) | |
should_not_see_member_login | |
should_see_member_dashboard | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the crux of it being the attr_accessor which is provided in cucumber's email_steps.rb but absent in rspec.