Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
Created November 29, 2011 22:37
Show Gist options
  • Select an option

  • Save daniel-nelson/1406923 to your computer and use it in GitHub Desktop.

Select an option

Save daniel-nelson/1406923 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe "change my password" do
before(:each) do
@user = Factory(:user)
i_sign_in(@user)
visit edit_user_registration_path
end
it "should require my current password" do
fill_in('Password', :with => 'modified')
fill_in('Password confirmation', :with => 'modified')
click_button('Update')
page.should have_content("Current password (required to change password or email address)can't be blank")
end
it "should notify me when my current password is incorrect" do
fill_in('Password', :with => 'modified')
fill_in('Password confirmation', :with => 'modified')
fill_in('Current password', :with => 'incorrect')
click_button('Update')
page.should have_content("Current password (required to change password or email address)is invalid")
end
it "should change my password when my current password is correct" do
fill_in('Password', :with => 'modified')
fill_in('Password confirmation', :with => 'modified')
fill_in('Current password', :with => 'secret')
click_button('Update')
@user.reload
@user.valid_password?('modified').should be_true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment