Skip to content

Instantly share code, notes, and snippets.

@bgerstle
Created November 22, 2013 04:07
Show Gist options
  • Save bgerstle/7594711 to your computer and use it in GitHub Desktop.
Save bgerstle/7594711 to your computer and use it in GitHub Desktop.
Example cucumber step definitions
Given /^I am on the Login Screen$/ do
# login becomes visible
wait_for_elements_exist(["view marked:'login view'"])
# fields fade in
wait_for_elements_exist(["textField marked:'username field'"])
check_element_exists("textField marked:'password field'")
# TODO: add checks to make sure loading indicator and error box aren't visible
sleep(STEP_PAUSE)
end
Then /^I relaunch the app$/ do
# the reset method might be different depending on the API version
if self.respond_to?(:start_test_server_in_background)
start_test_server_in_background
elsif self.respond_to?(:start_app_in_background)
start_app_in_background
else
fail("can't find the method which causes calabash to restart the app!")
end
sleep(STEP_PAUSE)
end
# TODO: substitute this with [non-]faceboook account
Then /^I login as boris$/ do
wait_for_elements_exist(["view marked:'login view'"])
touch("textField marked:'username field'")
keyboard_enter_text("[email protected]")
touch("textField marked:'password field'")
keyboard_enter_text("boristest2")
done
macro %Q[I wait to not see "login view"]
sleep(STEP_PAUSE)
end
Then /^I should see empty login fields$/ do
check_element_exists("textField marked:'username field' text:''")
check_element_exists("textField marked:'password field' text:''")
end
Given /^the app is clean$/ do
backdoor("cbd_resetApp:", "calabash")
# TODO: refactor relaunching into a helper ruby function
macro "I relaunch the app"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment