Pragmatic – Leading provider of open source business applications OpenERP, Ruby on Rails, Node.js, Talend, jaspersoft  – Pragmatic
Beyonce Adams

Testing with ruby on rails with cucumber

Testing with ruby on rails with cucumber
For testing a rails application i use cucumber . cucumber uses a Gherkin language. what need to be done here is first need to define Feature.Feature means a short description of what we are going to test.then need to write a Scenario . Scenario are a small steps which normally a user follows when he visits a web click on link or click on buttons and fills a text fields etc . so the user interacts with web pages and the same steps will be written in the scenario.
        The next step we need to follow is to write a code for executing this steps and that will be written in step defination folder.i am writing an example for executing a Sign up feature. as follows. so in featues folder i am writing a sign_up.feature file

Feature: Sign up
As an unauthorized user
I want to signup with my details
So that I can login

Scenario: Password doesn’t match confirmation
Given I am on the signup page
When I fill in all user details
Then I should see a success flash notice 

And now in step_definitions folder i am writing a sign_up.rb
Given(/^I am on the signup page$/) do
visit “/user/new”

When(/^I fill in all user details$/) do
fill_in “user_email”, :with => “”
fill_in “user_password”, :with => “good123”
fill_in “user_password_confirmation”, :with => “good123”
fill_in “user_city”, :with => “pune”
fill_in “user_weight”, :with => “82”
fill_in “user_height”, :with => “5.6”
fill_in “user_last_name”, :with => “pathak”
fill_in “user_first_name”, :with => “kedar”
click_button “Create User”

Then(/^I should see a success flash notice$/) do page.html.should match(/Sing Up successfully. Pending for approval/i)



Leave a Reply

Subscribe to Blog via Email.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Recent Comments

Related Posts