Skip to content

Commit

Permalink
Merge pull request cheezy#1 from sivart84/radio_button_group_tests
Browse files Browse the repository at this point in the history
Initial commit for radio button group tests
  • Loading branch information
sivart84 committed Jan 12, 2014
2 parents 6e25956 + 284e860 commit d896581
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
7 changes: 7 additions & 0 deletions features/html/static_elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
<input type="radio" id="milk_id" name="milk_name" class="milk_class" value="Milk"> Milk <br/>
<input type="radio" id="butter_id" name="butter_name" class="butter_class" value="Butter">Butter

<br/>
<label>Radio Button Group</label>
<input type="radio" name="fav_cheese" value="ched">Cheddar</input>
<input type="radio" name="fav_cheese" value="emmen">Emmental</input>
<input type="radio" name="fav_cheese" value="muen">Muenster</input>
<br/>

<div id="div_id" name="div_name" class="div_class" title="div_title">
page-object rocks!
</div>
Expand Down
40 changes: 40 additions & 0 deletions features/radio_button_group.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Radio Button Groups
In order to interact with radio button groups
Testers will need access and interrogation ability


Background:
Given I am on the static elements page

Scenario: Confirm existence of a radio button group
When a page has a radio button group
Then I should see that the radio button group exists

Scenario: No radio buttons in the group have been selected
When no radio buttons have been selected
Then no radio buttons should be selected

Scenario: Selecting grouped radio buttons by text
When I select the "Cheddar" radio button
Then the "Cheddar" radio button should be selected
Then the "Emmental" radio button should not be selected
Then the "Muenster" radio button should not be selected
When I select the "Emmental" radio button
Then the "Cheddar" radio button should not be selected
Then the "Emmental" radio button should be selected
Then the "Muenster" radio button should not be selected

Scenario: Selecting grouped radio buttons by value
When I select the "ched" radio button
Then the "Cheddar" radio button should be selected
Then the "Emmental" radio button should not be selected
Then the "Muenster" radio button should not be selected
When I select the "muen" radio button
Then the "Cheddar" radio button should not be selected
Then the "Emmental" radio button should not be selected
Then the "Muenster" radio button should be selected

Scenario: Getting an array of elements for each radio button in the group
When I ask for the elements of a radio button group
Then I should have an array with elements for each radio button
And the radio button element values should be "ched", "emmen", "muen"
36 changes: 36 additions & 0 deletions features/step_definitions/radio_button_group_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
When /^no radio buttons have been selected$/ do
# nothing to do here
end

Then /^no radio buttons should be selected$/ do
@page.favorite_cheese_selected?.should == false
end

When /^I select the "([^\"]*)" radio button$/ do |how|
@page.send "select_favorite_cheese(#{how})"
end

Then /^the "([^\"]*)" radio button should be selected$/ do |how|
@page.favorite_cheese_selected?.should == "#{how}"
end

Then /^the "([^\"]*)" radio button should not be selected$/ do |how|
@page.favorite_cheese_selected?.should != "#{how}"
end

Then /^I should see that the radio button group exists$/ do
@page.favorite_cheese?.should == true
end

When /^I ask for the elements of a radio button group$/ do
@elems = @page.favorite_cheese_elements
end

Then /^I should have an array with elements for each radio button$/ do
@elems.length.should == 3
end

And /^the radio button element values should be "([^\"]*)", "([^\"]*)", "([^\"]*)"$/ do |val1, val2, val3|
elem_arr = @elems.collect { |elem| elem.value }
elem_arr.should == [val1, val2, val3]
end
2 changes: 2 additions & 0 deletions features/support/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Page

radio_button(:butter_id, :id => 'butter_id')

radio_button_group(:favorite_cheese, name: 'fav_cheese')

div(:div_id, :id => 'div_id')
div(:div_name, :name => 'div_name')
div(:div_class, :class => 'div_class')
Expand Down

0 comments on commit d896581

Please sign in to comment.