Skip to content

Instantly share code, notes, and snippets.

@jmoody
Last active January 4, 2016 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmoody/8595943 to your computer and use it in GitHub Desktop.
Save jmoody/8595943 to your computer and use it in GitHub Desktop.
# tag your Scenario or you feature
# @authenticated
# Scenario: buy a bunch of stuff on ebay with mom's credit card
# Then I instant buy the "Star Wars Action Figure Deluxe Set"
#
# @authenticated
# Feature: favorite cat videos
# this will not work, because calabash does not have control of your app
# so do _not_ do this!
Before('@authenticated') do
login_page = page(LoginPage).await()
content_page = login_page.authenticate(:default_credentials)
@cp = content_page
end
# however, if want to reinstall before some Scenarios/Features you _can_ use
# this kind of Before('@tag') hook
# here is an example using rake task
Before('@reinstall') do
app_path = ENV['APP_BUNDLE_PATH']
udid = ENV['DEVICE_TARGET']
system "rake remove_app[#{udid}]"
system "rake deploy_app[#{udid},#{app_path}]"
end
Before do |scenario|
# if you want to reinstall before every Scenario
app_path = ENV['APP_BUNDLE_PATH']
udid = ENV['DEVICE_TARGET']
system "rake remove_app[#{udid}]"
system "rake deploy_app[#{udid},#{app_path}]"
@calabash_launcher = Calabash::Cucumber::Launcher.new
unless @calabash_launcher.calabash_no_launch?
@calabash_launcher.relaunch
@calabash_launcher.calabash_notify(self)
end
login_page = page(LoginPage).await()
if scenario.source_tag_names.include?('@authenticated')
content_page = login_page.authenticate(:default_credentials)
@cp = content_page
else
@cp = login_page
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment