diff options
| author | mo khan <mo@mokhan.ca> | 2015-02-01 21:44:34 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-02-01 21:44:34 -0700 |
| commit | a5205fa447f5c0c8c531d64b2908fb5e75065b7a (patch) | |
| tree | 759f50a20ca948245519f2232c520e3517dbf509 /spec/features | |
| parent | 74fbea95e4f4a27e3e4fdc2b4e897b0316bd56f2 (diff) | |
extract page objects for password reset.
Diffstat (limited to 'spec/features')
| -rw-r--r-- | spec/features/forgot_password_spec.rb | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/spec/features/forgot_password_spec.rb b/spec/features/forgot_password_spec.rb index a89b196f..da0e5830 100644 --- a/spec/features/forgot_password_spec.rb +++ b/spec/features/forgot_password_spec.rb @@ -1,37 +1,27 @@ require "rails_helper" -describe "password retrieval", :js => true do +describe "password retrieval" do context "when a user attempts to retrieve their password" do + subject { PasswordResetRequestPage.new } let(:user) { create(:user) } - let(:error_message) { I18n.t('passwords.send_instructions') } - - before :each do - visit login_path - click_link "Forgot your password?" - within "#new_user" do - fill_in "user_email", :with => user.email - end - click_button "Send me reset password instructions" - end + let(:error_message) { I18n.t("passwords.send_instructions") } it "sends them an email with instructions" do + subject.visit_page + subject.reset_password(user.email) expect(page).to have_content(error_message) end end - context "when a password is reset" do + context "when a reset link is sent" do let(:user) { create(:user, reset_password_token: SecureRandom.hex(32)) } + subject { PasswordResetPage.new(user.reset_password_token) } - it "lets them log in with the new password" do - visit edit_password_path(user.reset_password_token) - fill_in "user_password", with: 'donkey' - click_button "Change my password" - within('.form-inline') do - fill_in('session_username', with: user.email) - fill_in('session_password', with: "donkey") - end - click_button("Sign In") - expect(page).to have_content("Log Out") + it "lets them reset their password" do + subject.visit_page + subject.change_password_to("donkey") + expect(current_path).to eql(new_session_path) + expect(user.reload.authenticate("donkey")).to be_truthy end end end |
