Skip to content

Commit

Permalink
Successful registration: Detail pushed down. Using Capybara.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Martin committed Mar 31, 2012
1 parent 70b31cf commit 12b8ce3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
13 changes: 0 additions & 13 deletions features/registration.feature
Expand Up @@ -5,26 +5,13 @@ Feature: Registration

Scenario: Successful registration
Given I have started registration
#Given I have opened the homepage
#When I click on the 'sign-up' button
#Then I should see the registration page

When I complete registration with the following:
| Field | Value |
| name | Andy |
| email | andy@example.com |
| password | p4$$wd |
| confirmation | p4$$wd |

#When I fill in the name with 'andy'
#And I fill in the email with 'andy@example.com'
#And I fill in the password with 'p4$$wd'
#And I fill in the confirmation with 'p4$$wd'
#And I click the create my account button

Then I should see that I am registered
#Then I should see the message 'Welcome to the Sample App!'
#And I should see my username as 'andy'

Scenario Outline: Invalid details
Given I have started registration
Expand Down
32 changes: 28 additions & 4 deletions features/step_definitions/registering_microposter.rb
Expand Up @@ -3,16 +3,40 @@
ADDRESS=GREEDY_CAPTURE

Given /^I have started registration$/ do
pending # express the regexp above with the code you wish you had
#Given I have opened the homepage
visit '/'
#When I click on the 'sign-up' button
click_on 'Sign up now!'
#Then I should see the registration page
page.should have_content('Sign up')
end

When /^I complete registration with the following:$/ do |table|
# table is a Cucumber::Ast::Table
pending # express the regexp above with the code you wish you had
#When I fill in the name with 'andy'
#And I fill in the email with 'andy@example.com'
#And I fill in the password with 'p4$$wd'
#And I fill in the confirmation with 'p4$$wd'
#And I click the create my account button
table.map_column!('Field') do |field_name|
prefix = "user_"
prefix = "#{prefix}password_" if field_name =~ /confirmation/
"#{prefix}#{field_name}"
end

table.hashes.each do |row|
field = row.fetch('Field')
value = row.fetch('Value')
@username = value if field =~ /name/
fill_in(field, :with => value)
end
click_on 'Create my account'
end

Then /^I should see that I am registered$/ do
pending # express the regexp above with the code you wish you had
#Then I should see the message 'Welcome to the Sample App!'
page.should have_css('.alert-success', :text => 'Welcome to the Sample App!')
#And I should see my username as 'andy'
page.should have_css('h1', :text => @username)
end

Given /^a user with the email '#{ADDRESS}' exists$/ do |email|
Expand Down

0 comments on commit 12b8ce3

Please sign in to comment.