Thursday, September 24, 2009

Working with Ruby on Rails Cucumber From the Beginning(Part I)


Create a project and do testing using cucumber.

Project name “product”


Requirement

  1. The user can see the available products.

When the user come to the page he should be able to see all the available products with description like

Title: Ruby on Rails

Description: Model, view, controller architecture

Image Url: ror.jpg

Price: 21

  1. He should be able to add new products.

  2. He should be able to show the products.

  3. He should be able to edit products.

  4. He should be able to validate products details when adding new products.

Error massages should be display when there is a wrong with adding data like

Price should be number

Title cant be blank etc.


  1. When Edit product the validation also should be done.

  2. He should be able to navigate any places by clicking links.

  3. He should be able to delete products.

Product table contents

Title = String

Description = String

Image Url = String

Price = Decimal


Lets start developing the project.


  1. Install cucumber

sudo gem1.8 install cucumber


  1. The plugins’ dependencies must be installed separately:

gem install term-ansicolor treetop diff-lcs nokogiri



  1. Lets start developing our project

Open a terminal then type

rails -d mysql product

cd product

rake db:create:all

rake db:migrate




  1. Now lets try to create cucumber

ruby script/generate cucumber


  1. Then run

Rake Features Or Cucumber features


  1. Then u can see as follows



  1. Now you are ready to work with cucumber

  2. lets see that in next post.






No comments: