Permalink
Browse files

Misc. cuke step enhancements from client work

  • Loading branch information...
1 parent 8f15981 commit 6f3c8de339ea09ac980351d74a3cf9d3a11706da @moredip committed Sep 11, 2010
Showing with 109 additions and 38 deletions.
  1. +109 −38 cucumber/frankly_steps.rb
@@ -1,71 +1,114 @@
-When /^I type "([^\"]*)" into the "([^\"]*)" text field$/ do |text_to_type, mark|
- # TODO: extend frankly_map to support sending method arguments
- text_fields_modified = frankly_map( "textField placeholder:'#{mark}'", "setText:", text_to_type )
- raise "could not find text fields marked '#{text_to_type}'" if text_fields_modified.empty?
- #TODO raise warning if text_fields_modified.count > 1
-end
-
-# alias
-When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |text_field, text_to_type|
- When %Q|I type "#{text_to_type}" into the "#{text_field}" text field|
-end
-
-When /^I fill in text fields as follows:$/ do |table|
- table.hashes.each do |row|
- When %Q|I type "#{row['text']}" into the "#{row['field']}" text field|
- end
-end
-
-And /^I rotate to the "([^\"]*)"$/ do |direction|
- if direction == "right"
- rotate_simulator_right
- else
- rotate_simulator_left
- end
- sleep 1
-end
+WAIT_TIMEOUT = 240
+# -- See -- #
Then /^I wait to see "([^\"]*)"$/ do |expected_mark|
- Timeout::timeout(30) do
+ Timeout::timeout(WAIT_TIMEOUT) do
until view_with_mark_exists( expected_mark )
sleep 0.1
end
end
end
Then /^I wait to not see "([^\"]*)"$/ do |expected_mark|
- Timeout::timeout(30) do
+ sleep 3
+ Timeout::timeout(WAIT_TIMEOUT) do
while element_exists( "view marked:'#{expected_mark}'" )
sleep 0.1
end
end
end
+Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
+ Timeout::timeout(30) do
+ values = frankly_map( 'navigationItemView', 'accessibilityLabel' )
+ until values.include(expected_mark)
+ values = frankly_map( 'navigationItemView', 'accessibilityLabel' )
+ sleep 0.1
+ end
+ end
+end
+
+Then /^I wait to not see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
+ Timeout::timeout(30) do
+ values = frankly_map( 'navigationItemView', 'accessibilityLabel' )
+ while values.include(expected_mark)
+ values = frankly_map( 'navigationItemView', 'accessibilityLabel' )
+ sleep 0.1
+ end
+ end
+end
+
+Then /^I should see a "([^\"]*)" button$/ do |expected_mark|
+ check_element_exists("button marked:'#{expected_mark}'")
+end
+
Then /^I should see "([^\"]*)"$/ do |expected_mark|
- values = frankly_map( 'view', 'accessibilityLabel' )
- values.should include(expected_mark)
+ check_element_exists("view marked:'#{expected_mark}'")
end
Then /^I should not see "([^\"]*)"$/ do |expected_mark|
- values = frankly_map( 'view', 'accessibilityLabel' )
- values.should_not include(expected_mark)
+ check_element_does_not_exist("view marked:'#{expected_mark}'")
end
-Then /^I should see the following:$/ do |table|
+Then /I should see the following:/ do |table|
values = frankly_map( 'view', 'accessibilityLabel' )
table.raw.each do |expected_mark|
values.should include( expected_mark.first )
end
end
-
Then /^I should see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
values = frankly_map( 'navigationItemView', 'accessibilityLabel' )
values.should include(expected_mark)
end
+# -- Type/Fill in -- #
+
+When /^I type "([^\"]*)" into the "([^\"]*)" text field$/ do |text_to_type, mark|
+ text_fields_modified = frankly_map( "textField marked:'#{mark}'", "setText:", text_to_type )
+ raise "could not find text fields marked '#{text_to_type}'" if text_fields_modified.empty?
+ #TODO raise warning if text_fields_modified.count > 1
+end
+
+# alias
+When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |text_field, text_to_type|
+ When %Q|I type "#{text_to_type}" into the "#{text_field}" text field|
+end
+
+When /^I fill in text fields as follows:$/ do |table|
+ table.hashes.each do |row|
+ When %Q|I type "#{row['text']}" into the "#{row['field']}" text field|
+ end
+end
+
+# -- Rotate -- #
+And /^I rotate to the "([^\"]*)"$/ do |direction|
+ if direction == "right"
+ rotate_simulator_right
+ elsif direction == "left"
+ rotate_simulator_left
+ else
+ puts "[" + red('ERROR') + "] Direction specified is INVALID!!"
+ end
+ sleep 1
+end
+
+# -- touch -- #
When /^I touch "([^\"]*)"$/ do |mark|
- touch( "view marked:'#{mark}'" )
+ if element_exists("view marked:'#{mark}'")
+ touch( "view marked:'#{mark}'" )
+ else
+ raise "[" + red('FAIL') + "] Can't touch. Element #{mark} does NOT exist!!"
+ end
+ sleep 1
+end
+
+Then /I touch the following:/ do |table|
+ values = frankly_map( 'view', 'accessibilityLabel' )
+ table.raw.each do |expected_mark|
+ touch( "view marked:'#{expected_mark}'" )
+ sleep 2
+ end
end
When /^I touch the button marked "([^\"]*)"$/ do |mark|
@@ -81,18 +124,46 @@
touch( "actionSheet threePartButton tag:#{ordinal}" )
end
+# -- switch -- #
When /^I flip switch "([^\"]*)"$/ do |mark|
touch("view:'UISwitch' marked:'#{mark}'")
end
-Then /^switch "([^\"]*)" should be (off|on)$/ do |mark,expected_state|
+Then /^switch "([^\"]*)" should be on$/ do |mark|
+# switch_states = frankly_map( "view:'Switch' marked:'#{mark}'", "isOn" )
+ switch_states = frankly_map( "view accesibilityLabel:'#{mark}'", "isOn" )
+ puts "test #{switch_states.inspect}"
+
+ if switch_states == 0
+ puts "Switch #{mark} is ON"
+ else
+ puts "Switch #{mark} is OFF, flim switch ON"
+ Then %Q|I flip switch "#{mark}"|
+ end
+end
+
+Then /^switch "([^\"]*)" should be off$/ do |mark|
switch_states = frankly_map( "view:'UISwitch' marked:'#{mark}'", "isOn" )
- puts switch_states
- pending # express the regexp above with the code you wish you had
+ puts "test #{switch_states.inspect}"
+
+ if switch_states == 0
+ puts "Switch #{mark} is ON, flip switch OFF"
+ Then %Q|I flip switch "#{mark}"|
+ else
+ puts "Switch #{mark} is OFF"
+ end
end
+# -- misc -- #
+Then /^a pop\-over menu is displayed with the following:$/ do |table|
+ sleep 1
+ table.raw.each do |expected_mark|
+ check_element_exists "actionSheet view marked:'#{expected_mark}'"
+ end
+end
+
Then /^I navigate back$/ do
touch( "navigationItemButtonView" )
end

0 comments on commit 6f3c8de

Please sign in to comment.