features-skeleton/support/launch.rb in calabash-cucumber-0.9.47 vs features-skeleton/support/launch.rb in calabash-cucumber-0.9.48
- old
+ new
@@ -20,36 +20,52 @@
# Uncomment APP_BUNDLE_PATH =.. #
# #
########################################
require 'calabash-cucumber/launch/simulator_helper'
+require 'sim_launcher'
# Uncomment and replace ?? appropriately
# This should point to your Simulator build
# which includes calabash framework
# this is usually the Calabash build configuration
# of your production target.
-#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app""
+#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
#
+def reset_app_jail(sdk, app_path)
+ app = File.basename(app_path)
+ bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name #{app} | head -n 1`
+ return if bundle.empty? # Assuming we're already clean
+
+ sandbox = File.dirname(bundle)
+ ['Library', 'Documents', 'tmp'].each do |dir|
+ FileUtils.rm_rf(File.join(sandbox, dir))
+ end
+end
+
def relaunch
- if ENV['NO_LAUNCH'].nil?
- Calabash::Cucumber::SimulatorHelper.relaunch(app_path,ENV['SDK_VERSION'],ENV['DEVICE'] || 'iphone')
+ if ENV['NO_LAUNCH']!="1"
+ sdk = ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version
+ path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
+ if ENV['RESET_BETWEEN_SCENARIOS']=="1"
+ reset_app_jail(sdk, path)
+ end
+
+ Calabash::Cucumber::SimulatorHelper.relaunch(path,sdk,ENV['DEVICE'] || 'iphone')
end
end
def app_path
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
end
-##TODO Reset simulator between features!
-
Before do |scenario|
relaunch
end
at_exit do
- if ENV['NO_LAUNCH'].nil? and ENV['NO_STOP'].nil?
+ if ENV['NO_LAUNCH']!="1" and ENV['NO_STOP']!="1"
Calabash::Cucumber::SimulatorHelper.stop
end
-end
\ No newline at end of file
+end