Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.16 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Cucumber-rails | Defining a step which describe changes in a database
  2. Scenario: Creating a user
  3.   Given I am on the users creation page
  4.   When I fill in "Name" with "Chandler Bing"
  5.   And I click "Create User"
  6.   Then the user should be added into the database
  7.        
  8. Then /^the user should be added into the database$/ do
  9.   User.count.should eq 1
  10. end
  11.        
  12. Scenario: Creating a user
  13.   When I create the following users:
  14.     | name           |
  15.     | Chandler Bing  |
  16.     | Some Other Guy |
  17.   Then I should have the following users:
  18.     | name           |
  19.     | Chandler Bing  |
  20.     | Some Other Guy |
  21.        
  22. Given /^I create the following users:$/ do |table|
  23.   table.hashes.each do |row|
  24.     visit new_user_path
  25.     fill_in 'Name', with: row['name']
  26.     click_button 'Create User'
  27.   end
  28. end
  29.  
  30. Then /^I should have the following users:$/ do |table|
  31.   # Ensure users with same name are taken into account
  32.   table.hashes.size.should == User.count
  33.  
  34.   table.hashes.each do |row|
  35.     user = User.find_by_name(row['name'])
  36.     user.should_not be_nil
  37.   end
  38. end
  39.        
  40. Feature: Creating a user
  41.   Scenario: Successful ....
  42.     Given a user exists with name: "Said"
  43.     ..............
  44.      ..............