Links to My Posts

Labels

Blogumulus by Roy Tanck and Amanda Fazani
free counters

How many in online

Cucumber and Ruby on Rails (Part 1)



I write this post to exchange my experienced with you about Cucumber and ruby and rails.

What is cucumber?
Actually when i heard this word i get a funny and i get a picture as follows.

After that i searched web and i try to find tutorials for learning this myself. when i was finding about cucumber i got idea about as follows.


After that i started finding and do various type of tutorials and try to get basics of cucumber. But it was very difficult to me learn this because there are not much tutorials for that i found 2 tutorials and by refering them i got basic idea and i think to share my knowledge with others so that is why this kind of blog post is come out. I think this will for the begginers to get an idea.

Now lets see what is the cucumber in ruby on rais and in other post how to start to test a project using cucumber.

Cucumber (Behavioral Driven Development ) is used for testing the behavior of a code. the programmers says that cucumber is used for accepting testing. Any way this is used for behaviral testing.

Reads plain texts….
Texts are written as scenarios
Scenarios interact with the code
Check the Codes are correct

Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain-specific language and serves as documentation, automated tests and development-aid - all rolled into one format.

Lets see the simple senario and discuss about it.

Scenario: Listing & showing products
Given I have products titled Java, description Platform Independent, Image url java.jpg, Price 20
When I go to the list of Products
Then I should see "Java"
And I should see "Platform Independent"
And I should see "java.jpg"
And I should see "20"

As u can see the the senario is describe in palain text. here the Given, When, Then and And are the key words which is used by the cucumber. how the cucumber work with this type of plain text for that it uses the regular expressions. See the folowing regular expression (Don't wory that much about that we'll see them leter in detail)

Given /^I have products titled (.+), description (.+), Image url (.+), Price (.+)$/ do
|title,description,image_url,price|
Product.create!(:title => title, :description => description, :image_url => image_url, :price => price)
end

This describes the first step of the above senario. we do not much trouble with regular expressions. Becuse when we generate cucumber we get predefine regular expressions in webrat_steps.rb file.

Now I think u have basic idea about cucumber. In next posts lets see step by step to create a project and testing project using cucumber.

0 comments: