Saturday, November 6, 2010

Cucumber test for select box!

The behavior driven development is really fun. First of all you determine the flow of the program and then only write real codes. This technique is really effective as it saves time while programming, since the flow is already determined, the chance of hindrance is very low.

A simple test for seeing something in select box is:
Given I am on the index page
And the "Nepal" should be selected for "Country"
(where "Nepal" is your selected value and "Country" is the id/label of the select box)

The step definition for this step is
Then /^"([^\"]*)" should be selected for "([^\"]*)"$/ do |selected_value, field|
find_by_id(field).value.to_s.should == selected_value
end

No comments:

Post a Comment