Permalink
Browse files

cucumber features that came with template now pass, huzzah

  • Loading branch information...
1 parent 67e65ce commit 3517cfcd6a9af8b6e43b7504c4e6ad2cf6663b54 @towynlin committed Nov 17, 2011
View
92 features/step_definitions/user_steps.rb
@@ -10,50 +10,100 @@
end
Then /^I should be already signed in$/ do
- And %{I should see "Logout"}
+ step %{I should see "logout"}
end
Given /^I am signed up as "(.*)\/(.*)"$/ do |email, password|
- Given %{I am not logged in}
- When %{I go to the sign up page}
- And %{I fill in "Email" with "#{email}"}
- And %{I fill in "Password" with "#{password}"}
- And %{I fill in "Password confirmation" with "#{password}"}
- And %{I press "Sign up"}
- Then %{I should see "You have signed up successfully. If enabled, a confirmation was sent to your e-mail."}
- And %{I am logout}
+ step %{I am not logged in}
+ step %{I go to the sign up page}
+ step %{I fill in "Email" with "#{email}"}
+ step %{I fill in "Password" with "#{password}"}
+ step %{I fill in "Password confirmation" with "#{password}"}
+ step %{I press "Sign up"}
+ step %{I should see "You have signed up successfully. If enabled, a confirmation was sent to your e-mail."}
+ step %{I am logout}
end
Then /^I sign out$/ do
visit('/users/sign_out')
end
Given /^I am logout$/ do
- Given %{I sign out}
+ step %{I sign out}
end
Given /^I am not logged in$/ do
- Given %{I sign out}
+ step %{I sign out}
end
When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
- Given %{I am not logged in}
- When %{I go to the sign in page}
- And %{I fill in "Email" with "#{email}"}
- And %{I fill in "Password" with "#{password}"}
- And %{I press "Sign in"}
+ step %{I am not logged in}
+ step %{I go to the sign in page}
+ step %{I fill in "Email" with "#{email}"}
+ step %{I fill in "Password" with "#{password}"}
+ step %{I press "Sign in"}
end
Then /^I should be signed in$/ do
- Then %{I should see "Signed in successfully."}
+ step %{I should see "Signed in successfully."}
end
When /^I return next time$/ do
- And %{I go to the home page}
+ step %{I go to the home page}
end
Then /^I should be signed out$/ do
- And %{I should see "Sign up"}
- And %{I should see "Login"}
- And %{I should not see "Logout"}
+ step %{I should see "sign up"}
+ step %{I should see "login"}
+ step %{I should not see "logout"}
+end
+
+When /^I go to the sign in page$/ do
+ visit new_user_session_path
+end
+
+Then /^I should see "([^"]*)"$/ do |arg1|
+ page.should have_content(arg1)
+end
+
+When /^I go to the homepage$/ do
+ visit '/'
+end
+
+Then /^I go to the home page$/ do
+ visit '/'
+end
+
+Given /^I am on the home page$/ do
+ step %{I go to the home page}
+end
+
+Given /^I go to the sign up page$/ do
+ click_on 'sign up'
+end
+
+Given /^I fill in the following:$/ do |table|
+ table.raw.each do |row|
+ fill_in row[0], with: row[1]
+ end
+end
+
+When /^I follow "([^"]*)"$/ do |arg1|
+ click_on arg1
+end
+
+When /^I fill in "([^"]*)" with "([^"]*)"$/ do |arg1, arg2|
+ fill_in arg1, with: arg2
+end
+
+When /^I press "([^"]*)"$/ do |arg1|
+ click_on arg1
+end
+
+Then /^I should not see "([^"]*)"$/ do |arg1|
+ page.should_not have_content(arg1)
+end
+
+Then /^the "([^"]*)" field should contain "([^"]*)"$/ do |arg1, arg2|
+ page.should have_xpath("//input[@name='user[#{arg1.downcase}]' and @value='#{arg2}']")
end
View
2 features/users/sign_up.feature
@@ -15,7 +15,7 @@ Feature: Sign up
| Password | please |
| Password confirmation | please |
And I press "Sign up"
- Then I should see "Welcome! You have signed up successfully."
+ Then I should see "Welcome! You have signed up successfully."
Scenario: User signs up with invalid email
And I fill in the following:
View
6 features/users/user_edit.feature
@@ -7,9 +7,9 @@ Feature: Edit User
Given I am a user named "foo" with an email "user@test.com" and password "please"
When I sign in as "user@test.com/please"
Then I should be signed in
- When I follow "Edit account"
+ When I follow "edit account"
And I fill in "Name" with "baz"
And I fill in "Current password" with "please"
And I press "Update"
- And I go to the homepage
- Then I should see "User: baz"
+ And I follow "edit account"
+ Then the "Name" field should contain "baz"
View
9 features/users/user_show.feature
@@ -1,9 +0,0 @@
-Feature: Show Users
- As a visitor to the website
- I want to see registered users listed on the homepage
- so I can know if the site has users
-
- Scenario: Viewing users
- Given I am a user named "foo" with an email "user@test.com" and password "please"
- When I go to the homepage
- Then I should see "User: foo"

0 comments on commit 3517cfc

Please sign in to comment.