Skip to content

Instantly share code, notes, and snippets.

@relaxdiego
Created March 28, 2012 09:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save relaxdiego/2224979 to your computer and use it in GitHub Desktop.
Save relaxdiego/2224979 to your computer and use it in GitHub Desktop.
Feature: Create a User
Background:
* Clarice is a system administrator
* Dave is an ordinary user
Scenario Outline:
Given <User> is logged in
When she tries to create a user
Then the new user will <Be Created or Not>
Examples
| User | Be Created or Not |
| Clarice | be created |
| Paul | not be created |
Given /^(.+) is logged in$/ do |user|
steps %{
* visit '/'
* fill in username with username of #{user}
* fill in password with password of #{user}
* click on login
}
end
When /^(?:he|she) tries to create a user$/ do
steps %{
* visit '/users'
* fill in name with Albert
* fill in email with albert@email.com
* fill in password thisismypassword
* fill in password confirmation with thisismypassword
* click on save
}
end
Then /^the new user will be created$/ do
steps %{
* click on logout
* visit '/'
* fill in email with albert@email.com
* fill in password with thisismypassword
* click on login
* current path should be '/welcome'
}
end
When /^visit (.+) page$/ do |page|
visit page
end
When /^fill in (.+) with (\S+)$/ do |element_id, value|
page.should have_selector("\##{field_id}")
fill_in element_id, :with => value
end
When /^fill in (.+) with (\S+) of (\S+)$/ do |element_id, attribute, username|
page.should have_selector("\##{field_id}")
fill_in element_id, :with => @users[username][attribute]
end
When /^click on (.+)$/ do |element_id|
page.should have_selector("\##{element_id}")
click on element_id, :with => value
end
Then /^current path should be '(.+)'$/ do |path|
current_path.should == path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment