lib/ilesspainfulclient-cucumber/lesspainful_steps.rb in ilesspainfulclient-cucumber-0.0.1 vs lib/ilesspainfulclient-cucumber/lesspainful_steps.rb in ilesspainfulclient-cucumber-0.0.2
- old
+ new
@@ -1,17 +1,17 @@
WAIT_TIMEOUT = ENV['WAIT_TIMEOUT'] || 60
STEP_PAUSE = ENV['STEP_PAUSE'].to_f || 0.3
require 'rspec/expectations'
-Given /^(my|the) app is running$/ do
+Given /^(my|the) app is running$/ do |_|
#no-op on iOS
end
# -- Touch --#
-Then /^I (press|touch) on screen (\d+)% from the left and (\d+)% from the top$/ do |x, y|
+Then /^I (press|touch) on screen (\d+) from the left and (\d+) from the top$/ do |_, x, y|
touch(nil, {:x => x, :y => y})
sleep(STEP_PAUSE)
end
Then /^I (press|touch) "([^\"]*)"$/ do |_,name|
@@ -22,10 +22,11 @@
#Then /^I (press|touch) (\d+)% right and (\d+)% down from "([^\"]*)" $/ do |_,x,y,name|
# touch({:query => "view marked:'#{name}'", :offset => {:x => x, :y => y}})
#end
Then /^I (press|touch) button number (\d+)$/ do |_,index|
+ index = index.to_i
raise "Index should be positive (was: #{index})" if (index<=0)
touch("button index:#{index-1}")
sleep(STEP_PAUSE)
end
@@ -39,16 +40,17 @@
# /^I press image button number (\d+)$/
# iOS doesn't have image buttons'
##TODO note in tables views: this means visible cell index!
Then /^I (press|touch) list item number (\d+)$/ do |_,index|
+ index = index.to_i
raise "Index should be positive (was: #{index})" if (index<=0)
touch("tableViewCell index:#{index-1}")
sleep(STEP_PAUSE)
end
-Then /^I toggle the switch$/ do |name|
+Then /^I toggle the switch$/ do
touch("view:'UISwitch'")
sleep(STEP_PAUSE)
end
Then /^I toggle the "([^\"]*)" switch$/ do |name|
@@ -63,11 +65,10 @@
sleep(STEP_PAUSE)
end
# alias
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |text_field, text_to_type|
- puts %Q|I type "#{text_to_type}" into the "#{text_field}" text field|
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|
@@ -80,11 +81,10 @@
# text_fields_modified = frankly_map( "textField placeholder:'#{field_name}'", "setText:", text_to_type )
# raise "could not find text fields with placeholder '#{field_name}'" if text_fields_modified.empty?
#end
When /^I clear "([^\"]*)"$/ do |name|
- puts %Q|I type "" into the "#{name}" text field|
When %Q|I type "" into the "#{name}" text field|
end
##Then /^I clear input field number (\d+)$/ do |index|
# raise "Index should be positive (was: #{index})" if (index<=0)
@@ -96,20 +96,20 @@
# -- See -- #
Then /^I wait to see "([^\"]*)"$/ do |expected_mark|
Timeout::timeout(WAIT_TIMEOUT) do
until view_with_mark_exists( expected_mark )
- sleep 0.1
+ sleep 0.3
end
end
end
Then /^I wait to not see "([^\"]*)"$/ do |expected_mark|
sleep 2
Timeout::timeout(WAIT_TIMEOUT) do
while element_exists( "view marked:'#{expected_mark}'" )
- sleep 0.1
+ sleep 0.3
end
end
end
Then /^I wait for "([^\"]*)" to appear$/ do |name|
@@ -124,21 +124,21 @@
#/^I wait for progress$/
Then /^I wait for the "([^\"]*)" button to appear$/ do |name|
Timeout::timeout(WAIT_TIMEOUT) do
until element_exists( "button marked:'#{name}'" )
- sleep 0.1
+ sleep 0.3
end
end
end
Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
Timeout::timeout(30) do
values = query('navigationItemView', :accessibilityLabel)
until values.include?(expected_mark)
values = query('navigationItemView', :accessibilityLabel)
- sleep 0.1
+ sleep 0.3
end
end
end
Then /^I wait$/ do
@@ -161,12 +161,13 @@
Then /^I swipe (left|right)$/ do |dir|
swipe(dir)
sleep(STEP_PAUSE)
end
-Then /^I swipe (left|right) on cell number (\+d)$/ do |dir,index|
+Then /^I swipe on cell number (\d+)$/ do |index|
+ index = index.to_i
raise "Index should be positive (was: #{index})" if (index<=0)
- swipe(dir,{:query => "tableViewCell index:#{index-1}"})
+ cell_swipe({:query => "tableViewCell index:#{index-1}"})
sleep(STEP_PAUSE)
end
##pinch##