Created a cucumber example along with documentation about what it means.

This commit is contained in:
Dylan Lacey
2013-02-06 00:07:13 -08:00
parent 1b9623abcc
commit 604bd45d1f
3 changed files with 57 additions and 0 deletions
@@ -0,0 +1,15 @@
# Features describe what something should allow a user to accomplish. They're
# high-level things, like you'd put in your manual or marketing copy. For more
# information about features, check out the documentation at:
Feature: Addition
In order to revolutionize maths teaching
As an iOS developer
I want to be able to sum two numbers
Scenario: Add two numbers
Given I have entered 4 into field 1 of the calculator
And I have entered 7 into field 2 of the calculator
When I press button 1
Then the result should be displayed as 11
@@ -0,0 +1,17 @@
# These are the 'step definitions' which Cucumber uses to
#
Given /^I have entered (\d+) into field (\d+) of the calculator$/ do |value, field|
puts "Called: #{value} #{field}"
elements = selenium.find_elements(:tag_name, "textField")
elements[field.to_i - 1].send_keys value
end
Then /^the result should be displayed as (\d+)$/ do |expected|
result = selenium.find_element(:tag_name, "staticText")
result.attribute("value").should eq expected
end
And /^I press button (\d+)$/ do |button_index|
button = selenium.find_elements(:tag_name, "button")[button_index.to_i - 1]
button.click
end
@@ -0,0 +1,25 @@
require 'rspec/expectations'
require 'selenium-webdriver'
APP_PATH = '../../../../../apps/TestApp/build/release-iphonesimulator/TestApp.app'
def capabilities
{
'browserName' => 'iOS',
'platform' => 'Mac',
'version' => '6.0',
'app' => absolute_app_path
}
end
def absolute_app_path
File.join(File.dirname(__FILE__), APP_PATH)
end
def server_url
"http://127.0.0.1:4723/wd/hub"
end
def selenium
@driver ||= Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)
end