Skip to content

Commit

Permalink
simplified the cucumber features to assume the password is 'password'…
Browse files Browse the repository at this point in the history
…, so you don't have to type it everywhere
  • Loading branch information
Dan Croak committed Jun 29, 2011
1 parent 9a53175 commit 76ca2ee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 42 deletions.
11 changes: 7 additions & 4 deletions features/engine/visitor_resets_password.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Feature: Password reset
Then I should see "Unknown email"

Scenario: User is signed up and requests password reset
Given I signed up with "email@example.com/password"
Given I signed up with "email@example.com"
When I request password reset link to be sent to "email@example.com"
Then I should see "instructions for changing your password"
And a password reset message should be sent to "email@example.com"

Scenario: User tries to reset his password with a blank password
Given I signed up with "email@example.com/password"
Given I signed up with "email@example.com"
And I go to the password reset request page
Then I should see an email field
And I fill in "Email address" with "email@example.com"
Expand All @@ -27,7 +27,7 @@ Feature: Password reset
And I should be signed out

Scenario: User is signed up and updates his password
Given I signed up with "email@example.com/password"
Given I signed up with "email@example.com"
And I go to the password reset request page
And I fill in "Email address" with "email@example.com"
And I press "Reset password"
Expand All @@ -36,7 +36,10 @@ Feature: Password reset
Then I should be signed in
When I sign out
Then I should be signed out
And I sign in as "email@example.com/newpassword"
When I go to the sign in page
And I fill in "Email" with "email@example.com"
And I fill in "Password" with "newpassword"
And I press "Sign in"
Then I should be signed in

Scenario: User who was created before Clearance was installed creates password for first time
Expand Down
22 changes: 10 additions & 12 deletions features/engine/visitor_signs_in.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,32 @@ Feature: Sign in
I want to sign in

Scenario: Visitor is not signed up
Given no user exists with an email of "email@person.com"
Given no user exists with an email of "email@example.com"
When I go to the sign in page
And I sign in as "email@person.com/password"
And I sign in as "email@example.com"
Then I should see "Bad email or password"
And I should be signed out

Scenario: Visitor enters wrong password
Given I am signed up as "email@person.com/password"
Given I am signed up as "email@example.com"
When I go to the sign in page
And I sign in as "email@person.com/wrongpassword"
And I fill in "Email" with "email@example.com"
And I fill in "Password" with "badpassword"
And I press "Sign in"
Then I should see "Bad email or password"
And I should be signed out

Scenario: Visitor signs in successfully
Given I am signed up as "email@person.com/password"
Given I am signed up as "email@example.com"
When I go to the sign in page
Then I should see an email field
And I sign in as "email@person.com/password"
And I sign in as "email@example.com"
Then I should see "Signed in"
And I should be signed in
When I return next time
Then I should be signed in

Scenario: Visitor signs in successfully with uppercase email
Given I am signed up as "email@person.com/password"
Given I am signed up as "email@example.com"
When I go to the sign in page
And I sign in as "Email@person.com/password"
And I sign in as "Email@example.com"
Then I should see "Signed in"
And I should be signed in
When I return next time
Then I should be signed in
6 changes: 2 additions & 4 deletions features/engine/visitor_signs_out.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ Feature: Sign out
I want to sign out

Scenario: User signs out
Given I am signed up as "email@person.com/password"
When I sign in as "email@person.com/password"
Given I am signed up as "email@example.com"
When I sign in as "email@example.com"
Then I should be signed in
And I sign out
Then I should see "Signed out"
And I should be signed out
When I return next time
Then I should be signed out
25 changes: 8 additions & 17 deletions features/step_definitions/engine/clearance_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
assert_nil User.find_by_email(email)
end

Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)\/(.*)"$/ do |email, password|
Factory(:user,
:email => email,
:password => password)
Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)"$/ do |email|
Factory(:user, :email => email)
end

Given /^a user "([^"]*)" exists without a salt, remember token, or password$/ do |email|
Expand All @@ -46,21 +44,14 @@
Then %{I should see "Sign in"}
end

When /^session is cleared$/ do
# TODO: This doesn't work with Capybara
# TODO: I tried Capybara.reset_sessions! but that didn't work
#request.reset_session
#controller.instance_variable_set(:@_current_user, nil)
end

Given /^(?:I am|I have|I) signed in (?:with|as) "(.*)\/(.*)"$/ do |email, password|
Given %{I am signed up as "#{email}/#{password}"}
And %{I sign in as "#{email}/#{password}"}
Given /^(?:I am|I have|I) signed in (?:with|as) "(.*)"$/ do |email|
Given %{I am signed up as "#{email}"}
And %{I sign in as "#{email}"}
end

Given /^I sign in$/ do
email = Factory.next(:email)
Given %{I have signed in with "#{email}/password"}
Given %{I have signed in with "#{email}"}
end

# Emails
Expand Down Expand Up @@ -90,10 +81,10 @@

# Actions

When /^I sign in (?:with|as) "(.*)\/(.*)"$/ do |email, password|
When /^I sign in (?:with|as) "(.*)"$/ do |email|
When %{I go to the sign in page}
And %{I fill in "Email" with "#{email}"}
And %{I fill in "Password" with "#{password}"}
And %{I fill in "Password" with "password"}
And %{I press "Sign in"}
end

Expand Down
10 changes: 5 additions & 5 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"user#{n}@example.com"
end

Factory.define :user do |user|
user.email { Factory.next :email }
user.password { "password" }
Factory.define :user do |factory|
factory.email { Factory.next :email }
factory.password { "password" }
end

Factory.define :email_confirmed_user, :parent => :user do |user|
user.after_build { warn "[DEPRECATION] The :email_confirmed_user factory is deprecated, please use the :user factory instead." }
Factory.define :email_confirmed_user, :parent => :user do |factory|
factory.after_build { warn "[DEPRECATION] The :email_confirmed_user factory is deprecated, please use the :user factory instead." }
end

0 comments on commit 76ca2ee

Please sign in to comment.