
Untitled
By: a guest on
May 7th, 2012 | syntax:
None | size: 1.16 KB | hits: 10 | expires: Never
Cucumber-rails | Defining a step which describe changes in a database
Scenario: Creating a user
Given I am on the users creation page
When I fill in "Name" with "Chandler Bing"
And I click "Create User"
Then the user should be added into the database
Then /^the user should be added into the database$/ do
User.count.should eq 1
end
Scenario: Creating a user
When I create the following users:
| name |
| Chandler Bing |
| Some Other Guy |
Then I should have the following users:
| name |
| Chandler Bing |
| Some Other Guy |
Given /^I create the following users:$/ do |table|
table.hashes.each do |row|
visit new_user_path
fill_in 'Name', with: row['name']
click_button 'Create User'
end
end
Then /^I should have the following users:$/ do |table|
# Ensure users with same name are taken into account
table.hashes.size.should == User.count
table.hashes.each do |row|
user = User.find_by_name(row['name'])
user.should_not be_nil
end
end
Feature: Creating a user
Scenario: Successful ....
Given a user exists with name: "Said"
..............
..............