Last active
January 4, 2016 08:29
-
-
Save jmoody/8595943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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