Skip to content

Commit

Permalink
Merge pull request #3486 from devendram/cukes-refactor
Browse files Browse the repository at this point in the history
Refactored cucumber features, steps, and support helpers for change pass...
  • Loading branch information
maxwell committed Aug 7, 2012
2 parents c6ff849 + 7c4c11f commit 6494b14
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 11 deletions.
19 changes: 8 additions & 11 deletions features/change_password.feature
Expand Up @@ -4,9 +4,7 @@ Feature: Change password
Scenario: Change my password
Given I am signed in
When I go to the users edit page
And I put in my password in "user_current_password"
And I fill in "user_password" with "newsecret"
And I fill in "user_password_confirmation" with "newsecret"
And I fill out change password section with my password and "newsecret" and "newsecret"
And I press "Change password"
Then I should see "Password changed"
Then I should be on the new user session page
Expand All @@ -15,13 +13,12 @@ Feature: Change password

Scenario: Reset my password
Given a user with email "forgetful@users.net"
Given I am on the new user password page
And I fill in "Email" with "Forgetful@users.net"
And I press "Send me reset password instructions"
Given I am on forgot password page
When I fill out forgot password form with "Forgetful@users.net"
And I submit forgot password form
Then I should see "You will receive an email with instructions"
And I follow the "Change my password" link from the last sent email
When I follow the "Change my password" link from the last sent email
Then I should see "Change my password"
And I fill in "Password" with "supersecret"
And I fill in "Password confirmation" with "supersecret"
And I press "Change my password"
Then I should be on the stream page
When I fill out reset password form with "supersecret" and "supersecret"
And I submit reset password form
Then I should be on the stream page
20 changes: 20 additions & 0 deletions features/step_definitions/session_steps.rb
Expand Up @@ -36,6 +36,26 @@
step %(I fill in "#{field}" with "#{@me.password}")
end

When /^I fill out change password section with my password and "([^"]*)" and "([^"]*)"$/ do |new_pass, confirm_pass|
fill_change_password_section(@me.password, new_pass, confirm_pass)
end

When /^I fill out forgot password form with "([^"]*)"$/ do |email|
fill_forgot_password_form(email)
end

When /^I submit forgot password form$/ do
submit_forgot_password_form
end

When /^I fill out reset password form with "([^"]*)" and "([^"]*)"$/ do |new_pass,confirm_pass|
fill_reset_password_form(new_pass, confirm_pass)
end

When /^I submit reset password form$/ do
submit_reset_password_form
end

When /^I (?:log|sign) out$/ do
logout
end
Expand Down
2 changes: 2 additions & 0 deletions features/support/paths.rb
Expand Up @@ -31,6 +31,8 @@ def path_to(page_name)
person_path(@me.person, :ex => true)
when /^the new stream$/
stream_path(:ex => true)
when /^forgot password page$/
new_user_password_path
when /^"(\/.*)"/
$1
else
Expand Down
30 changes: 30 additions & 0 deletions features/support/user_cuke_helpers.rb
Expand Up @@ -53,10 +53,40 @@ def logout
$browser.delete_all_visible_cookies if $browser
end

# go to user menu, expand it, and click logout
def manual_logout
find("#user_menu li:first-child a").click
find("#user_menu li:last-child a").click
end

# fill change password section on the user edit page
def fill_change_password_section(cur_pass, new_pass, confirm_pass)
fill_in 'user_current_password', :with => cur_pass
fill_in 'user_password', :with => new_pass
fill_in 'user_password_confirmation', :with => confirm_pass
end

# fill forgot password form to get reset password link
def fill_forgot_password_form(email)
fill_in 'user_email', :with => email
end

# submit forgot password form to get reset password link
def submit_forgot_password_form
find("#new_user input.button").click
end

# fill the reset password form
def fill_reset_password_form(new_pass, confirm_pass)
fill_in 'user_password', :with => new_pass
fill_in 'user_password_confirmation', :with => confirm_pass
end

# submit reset password form
def submit_reset_password_form
find(".button").click
end

end

World(UserCukeHelpers)

0 comments on commit 6494b14

Please sign in to comment.