[rspec-users] Cucmber Step to insert Test Data into Database

Smita Sreekanth lists at ruby-forum.com
Wed May 27 05:20:00 EDT 2009


Hi,

We run the feature created for a form to identify the fields and also to
add data into the respective fields.

But while running the cucumber features, all the scenario and steps are
getting passed but the record is not getting inserted into the
application / the database.

We have also wrote the feature as:

Feature: Adding a user
  In order to add a user to the organization
  As a administrator
  I want to create and add new user

Scenario: Create User
  Given that I have no users
  And I am on the "List of users"
  When I follow "New User"
  And I fill in "First Name" with "Rebecca"
  And I fill in "Second Name" with "Martin"
  And I fill in "Title" with "Miss"
  And I fill in "Email" with "rebeccamartin at me.com"
  And I fill in "Telephone" with "01617867645"
  And I fill in "Mobile" with "01777867645"
  And I fill in "Fax" with "01617867640Î"
  And I fill in "Address Line 1" with "58"
  And I fill in "Address Line 2" with "West Tree rd"
  And I fill in "Address Line 3" with "Stockport"
  And I fill in "County" with "Cheshire"
  And I fill in "Country" with "United Kingdom"
  And I fill in "Zip Code" with "sk8 4ty"
  And I press "Create"
  Then I should have 1 user


And steps as:

Then /^I should have ([0-9]+) user$/ do |c|
 User.count.should==c.to_i
end

Given /^that I have no users$/ do
  User.delete_all
end

If somebody could help us out, how to execute the steps so that the data
gets inserted into the database.

Smita.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list