calabash-cucumber 0.9.141 → 0.9.144
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/calabash-ios-setup.rb +16 -9
- data/calabash-cucumber.gemspec +1 -1
- data/features-skeleton/support/01_launch.rb +46 -0
- data/features-skeleton/support/{hooks.rb → 02_pre_stop_hooks.rb} +0 -0
- data/features/step_definitions/calabash_steps.rb +12 -3
- data/lib/calabash-cucumber/core.rb +9 -1
- data/lib/calabash-cucumber/device.rb +84 -0
- data/lib/calabash-cucumber/launch/simulator_helper.rb +8 -9
- data/lib/calabash-cucumber/launcher.rb +20 -9
- data/lib/calabash-cucumber/version.rb +2 -2
- data/lib/calabash-cucumber/wait_helpers.rb +17 -9
- data/scripts/launch.rb +11 -20
- metadata +7 -7
- data/features-skeleton/support/launch.rb +0 -77
data/bin/calabash-ios-setup.rb
CHANGED
@@ -297,7 +297,7 @@ def update(args)
|
|
297
297
|
if args.length > 0
|
298
298
|
target = args[0]
|
299
299
|
unless UPDATE_TARGETS.include?(target)
|
300
|
-
msg(
|
300
|
+
msg('Error') do
|
301
301
|
puts "Invalid target #{target}. Must be one of: #{UPDATE_TARGETS.join(' ')}"
|
302
302
|
end
|
303
303
|
exit 1
|
@@ -305,8 +305,8 @@ def update(args)
|
|
305
305
|
|
306
306
|
|
307
307
|
|
308
|
-
target_file =
|
309
|
-
msg(
|
308
|
+
target_file = 'features/support/launch.rb'
|
309
|
+
msg('Question') do
|
310
310
|
puts "I'm about to update the #{target_file} file."
|
311
311
|
puts "Please hit return to confirm that's what you want."
|
312
312
|
end
|
@@ -314,22 +314,29 @@ def update(args)
|
|
314
314
|
|
315
315
|
|
316
316
|
unless File.exist?(target_file)
|
317
|
-
msg(
|
317
|
+
msg('Error') do
|
318
318
|
puts "Unable to find file #{target_file}"
|
319
319
|
puts "Please change directory so that #{target_file} exists."
|
320
320
|
end
|
321
321
|
exit 1
|
322
322
|
end
|
323
|
-
new_launch_script = File.join(@script_dir,
|
323
|
+
new_launch_script = File.join(@script_dir, 'launch.rb')
|
324
324
|
|
325
|
-
FileUtils.cp(new_launch_script,
|
325
|
+
FileUtils.cp(new_launch_script, 'features/support/01_launch.rb', :verbose => true)
|
326
|
+
FileUtils.rm(target_file, :force => true, :verbose => true)
|
326
327
|
|
327
|
-
|
328
|
+
hooks_file = 'features/support/hooks.rb'
|
329
|
+
if File.exist?(hooks_file)
|
330
|
+
FileUtils.mv(hooks_file, 'features/support/02_pre_stop_hooks.rb', :verbose => true)
|
331
|
+
end
|
332
|
+
|
333
|
+
msg('Info') do
|
328
334
|
puts "File copied.\n"
|
329
|
-
puts
|
335
|
+
puts 'Launch on device using environment variable DEVICE_TARGET=device.'
|
336
|
+
puts 'Launch on simulator by default or using environment variable DEVICE_TARGET=simulator.'
|
330
337
|
end
|
331
338
|
else
|
332
|
-
msg(
|
339
|
+
msg('Error') do
|
333
340
|
puts "update must take one of the following targets: #{UPDATE_TARGETS.join(' ')}"
|
334
341
|
end
|
335
342
|
exit 1
|
data/calabash-cucumber.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency( "location-one", "~>0.0.9")
|
25
25
|
s.add_dependency( "httpclient","2.3.2")
|
26
26
|
s.add_dependency( "bundler", "~> 1.1")
|
27
|
-
s.add_dependency( "run_loop", "0.0.
|
27
|
+
s.add_dependency( "run_loop", "0.0.9" )
|
28
28
|
s.add_dependency( "awesome_print")
|
29
29
|
|
30
30
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
########################################
|
2
|
+
# #
|
3
|
+
# Important Note #
|
4
|
+
# #
|
5
|
+
# When running calabash-ios tests at #
|
6
|
+
# www.xamarin.com/test-cloud #
|
7
|
+
# this file will be overwritten by #
|
8
|
+
# a file which automates #
|
9
|
+
# app launch on devices. #
|
10
|
+
# #
|
11
|
+
# Don't rely on this file being #
|
12
|
+
# present when running at #
|
13
|
+
# Xamarin Test Cloud #
|
14
|
+
# #
|
15
|
+
########################################
|
16
|
+
|
17
|
+
require 'calabash-cucumber/launcher'
|
18
|
+
|
19
|
+
|
20
|
+
# APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
21
|
+
# You may uncomment the above to overwrite the APP_BUNDLE_PATH
|
22
|
+
# However the recommended approach is to let Calabash find the app itself
|
23
|
+
# or set the environment variable APP_BUNDLE_PATH
|
24
|
+
|
25
|
+
|
26
|
+
Before do |scenario|
|
27
|
+
@calabash_launcher = Calabash::Cucumber::Launcher.new
|
28
|
+
unless @calabash_launcher.calabash_no_launch?
|
29
|
+
@calabash_launcher.relaunch
|
30
|
+
@calabash_launcher.calabash_notify(self)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
After do |scenario|
|
35
|
+
unless @calabash_launcher.calabash_no_stop?
|
36
|
+
calabash_exit
|
37
|
+
if @calabash_launcher.active?
|
38
|
+
@calabash_launcher.stop
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
at_exit do
|
44
|
+
launcher = Calabash::Cucumber::Launcher.new
|
45
|
+
Calabash::Cucumber::SimulatorHelper.stop unless launcher.calabash_no_stop?
|
46
|
+
end
|
File without changes
|
@@ -40,8 +40,17 @@ Then /^I (?:press|touch) (?:input|text) field number (\d+)$/ do |index|
|
|
40
40
|
sleep(STEP_PAUSE)
|
41
41
|
end
|
42
42
|
|
43
|
+
|
43
44
|
Then /^I (?:press|touch) the "([^\"]*)" (?:input|text) field$/ do |name|
|
44
|
-
|
45
|
+
placeholder_query = "textField placeholder:'#{name}'"
|
46
|
+
marked_query = "textField marked:'#{name}'"
|
47
|
+
if !query(placeholder_query).empty?
|
48
|
+
touch(placeholder_query)
|
49
|
+
elsif !query(marked_query).empty?
|
50
|
+
touch(marked_query)
|
51
|
+
else
|
52
|
+
screenshot_and_raise "could not find text field with placeholder '#{name}' or marked as '#{name}'"
|
53
|
+
end
|
45
54
|
sleep(STEP_PAUSE)
|
46
55
|
end
|
47
56
|
|
@@ -375,7 +384,7 @@ Then /^I should see a "([^\"]*)" (?:input|text) field$/ do |expected_mark|
|
|
375
384
|
res = element_exists("textField placeholder:'#{expected_mark}'") or
|
376
385
|
element_exists("textField marked:'#{expected_mark}'")
|
377
386
|
unless res
|
378
|
-
screenshot_and_raise "Expected textfield with placeholder or accessibilityLabel: #{
|
387
|
+
screenshot_and_raise "Expected textfield with placeholder or accessibilityLabel: #{expected_mark}"
|
379
388
|
end
|
380
389
|
end
|
381
390
|
|
@@ -383,7 +392,7 @@ Then /^I should not see a "([^\"]*)" (?:input|text) field$/ do |expected_mark|
|
|
383
392
|
res = query("textField placeholder:'#{expected_mark}'")
|
384
393
|
res.concat query("textField marked:'#{expected_mark}'")
|
385
394
|
unless res.empty?
|
386
|
-
screenshot_and_raise "Expected no textfield with placeholder nor accessibilityLabel: #{
|
395
|
+
screenshot_and_raise "Expected no textfield with placeholder nor accessibilityLabel: #{expected_mark}, found #{res}"
|
387
396
|
end
|
388
397
|
end
|
389
398
|
|
@@ -21,6 +21,10 @@ module Calabash
|
|
21
21
|
map(uiquery, :query, *args)
|
22
22
|
end
|
23
23
|
|
24
|
+
def flash(uiquery, *args)
|
25
|
+
map(uiquery, :flash, *args)
|
26
|
+
end
|
27
|
+
|
24
28
|
def server_version
|
25
29
|
JSON.parse(http(:path => 'version'))
|
26
30
|
end
|
@@ -454,7 +458,7 @@ EOF
|
|
454
458
|
# Exiting the app shuts down the HTTP connection and generates ECONNREFUSED,
|
455
459
|
# which needs to be suppressed.
|
456
460
|
begin
|
457
|
-
http(:path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED])
|
461
|
+
http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED]})
|
458
462
|
rescue Errno::ECONNREFUSED
|
459
463
|
[]
|
460
464
|
end
|
@@ -492,6 +496,10 @@ EOF
|
|
492
496
|
end
|
493
497
|
end
|
494
498
|
|
499
|
+
def default_device
|
500
|
+
@calabash_launcher && @calabash_launcher.device
|
501
|
+
end
|
502
|
+
|
495
503
|
def send_uia_command(opts ={})
|
496
504
|
run_loop = opts[:run_loop] || (@calabash_launcher && @calabash_launcher.active? && @calabash_launcher.run_loop)
|
497
505
|
command = opts[:command]
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
module Cucumber
|
5
|
+
# Class device encapsulates information about the device or devices
|
6
|
+
# we are interacting with during a test.
|
7
|
+
# Credit: Due to jmoody's briar: https://github.com/jmoody/briar/blob/master/lib/briar/gestalt.rb
|
8
|
+
|
9
|
+
class Device
|
10
|
+
|
11
|
+
GESTALT_IPHONE = 'iPhone'
|
12
|
+
GESTALT_IPAD = 'iPad'
|
13
|
+
GESTALT_IPHONE5 = 'Retina 4-inch'
|
14
|
+
GESTALT_SIM_SYS = 'x86_64'
|
15
|
+
GESTALT_IPOD = 'iPod'
|
16
|
+
|
17
|
+
|
18
|
+
attr_reader :endpoint
|
19
|
+
attr_reader :device_family
|
20
|
+
attr_reader :simulator_details, :ios_version
|
21
|
+
attr_reader :system
|
22
|
+
attr_reader :framework_version
|
23
|
+
|
24
|
+
attr_accessor :udid
|
25
|
+
|
26
|
+
def initialize (endpoint, version_data)
|
27
|
+
simulator_device = version_data['simulator_device']
|
28
|
+
@endpoint = endpoint
|
29
|
+
@system = version_data['system']
|
30
|
+
@device_family = @system.eql?(GESTALT_SIM_SYS) ? simulator_device : @system.split(/[\d,.]/).first
|
31
|
+
@simulator_details = version_data['simulator']
|
32
|
+
@ios_version = version_data['iOS_version']
|
33
|
+
@framework_version = version_data['version']
|
34
|
+
end
|
35
|
+
|
36
|
+
def simulator?
|
37
|
+
system.eql?(GESTALT_SIM_SYS)
|
38
|
+
end
|
39
|
+
|
40
|
+
def device?
|
41
|
+
not simulator?
|
42
|
+
end
|
43
|
+
|
44
|
+
def iphone?
|
45
|
+
device_family.eql? GESTALT_IPHONE
|
46
|
+
end
|
47
|
+
|
48
|
+
def ipod?
|
49
|
+
device_family.eql? GESTALT_IPOD
|
50
|
+
end
|
51
|
+
|
52
|
+
def ipad?
|
53
|
+
device_family.eql? GESTALT_IPAD
|
54
|
+
end
|
55
|
+
|
56
|
+
def iphone_5?
|
57
|
+
if simulator?
|
58
|
+
simulator_details.split(/[(),]/)[3].eql? GESTALT_IPHONE5
|
59
|
+
else
|
60
|
+
system.split(/[\D]/).delete_if { |x| x.eql?('') }.first.eql?('5')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def version_hash (version_str)
|
65
|
+
tokens = version_str.split(/[,.]/)
|
66
|
+
{:major_version => tokens[0],
|
67
|
+
:minor_version => tokens[1],
|
68
|
+
:bug_version => tokens[2]}
|
69
|
+
end
|
70
|
+
|
71
|
+
def ios_major_version
|
72
|
+
version_hash(ios_version)[:major_version]
|
73
|
+
end
|
74
|
+
|
75
|
+
def ios6?
|
76
|
+
ios_major_version.eql?('6')
|
77
|
+
end
|
78
|
+
|
79
|
+
def ios5?
|
80
|
+
ios_major_version.eql?('5')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -21,7 +21,7 @@ module Calabash
|
|
21
21
|
|
22
22
|
# Load environment variable for showing full console output
|
23
23
|
# If not env var set then we use true; i.e. output to console in full
|
24
|
-
FULL_CONSOLE_OUTPUT = ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '
|
24
|
+
FULL_CONSOLE_OUTPUT = ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' ? true : false
|
25
25
|
|
26
26
|
def self.relaunch(path, sdk = nil, version = 'iphone', args = nil)
|
27
27
|
|
@@ -89,7 +89,7 @@ module Calabash
|
|
89
89
|
msg << "i.e., the directory containing your .xcodeproj file."
|
90
90
|
msg << "In Xcode, build your calabash target for simulator."
|
91
91
|
msg << "Check that your app can be found in\n #{File.expand_path("~/Library/Developer/Xcode/DerivedData")}"
|
92
|
-
msg << "\n\nOption 2). In features/support/
|
92
|
+
msg << "\n\nOption 2). In features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
93
93
|
msg << "the path where Xcode has built your Calabash target."
|
94
94
|
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
95
95
|
raise msg.join("\n")
|
@@ -101,7 +101,7 @@ module Calabash
|
|
101
101
|
|
102
102
|
msg << "\nThis means that Calabash can't automatically launch iOS simulator."
|
103
103
|
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}"
|
104
|
-
msg << "\nIn features/support/
|
104
|
+
msg << "\nIn features/support/01_launch.rb set APP_BUNDLE_PATH to"
|
105
105
|
msg << "the path where Xcode has built your Calabash target."
|
106
106
|
msg << "Alternatively you can use the environment variable APP_BUNDLE_PATH.\n"
|
107
107
|
raise msg.join("\n")
|
@@ -125,7 +125,7 @@ module Calabash
|
|
125
125
|
puts "Unable to find .app bundle at #{path}. It should be an .app directory."
|
126
126
|
dd_dir = derived_data_dir_for_project
|
127
127
|
app_bundles = Dir.glob(File.join(dd_dir, "Build", "Products", "*", "*.app"))
|
128
|
-
msg = "Try setting APP_BUNDLE_PATH in features/support/
|
128
|
+
msg = "Try setting APP_BUNDLE_PATH in features/support/01_launch.rb to one of:\n\n"
|
129
129
|
msg << app_bundles.join("\n")
|
130
130
|
raise msg
|
131
131
|
elsif path
|
@@ -140,7 +140,7 @@ module Calabash
|
|
140
140
|
msg << "Please build your app from Xcode"
|
141
141
|
msg << "You should build the -cal target."
|
142
142
|
msg << ""
|
143
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/
|
143
|
+
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
144
144
|
msg << "This should point to the location of your built app linked with calabash.\n"
|
145
145
|
raise msg.join("\n")
|
146
146
|
end
|
@@ -151,7 +151,7 @@ module Calabash
|
|
151
151
|
msg << "Please build your app from Xcode"
|
152
152
|
msg << "You should build your calabash target."
|
153
153
|
msg << ""
|
154
|
-
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/
|
154
|
+
msg << "Alternatively, specify APP_BUNDLE_PATH in features/support/01_launch.rb"
|
155
155
|
msg << "This should point to the location of your built app linked with calabash.\n"
|
156
156
|
raise msg.join("\n")
|
157
157
|
end
|
@@ -160,7 +160,7 @@ module Calabash
|
|
160
160
|
|
161
161
|
puts "APP_BUNDLE_PATH=#{preferred_dir || sim_dirs[0]}\n\n"
|
162
162
|
puts "Please verify!"
|
163
|
-
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/
|
163
|
+
puts "If this is wrong please set it as APP_BUNDLE_PATH in features/support/01_launch.rb\n"
|
164
164
|
puts("-"*37)
|
165
165
|
bundle_path = sim_dirs[0]
|
166
166
|
end
|
@@ -246,8 +246,7 @@ module Calabash
|
|
246
246
|
|
247
247
|
def self.launch(app_bundle_path, sdk, version, args = nil)
|
248
248
|
simulator = SimLauncher::Simulator.new
|
249
|
-
simulator.
|
250
|
-
simulator.launch_ios_app(app_bundle_path, sdk, version) #, args wait for update to sim launcher
|
249
|
+
simulator.launch_ios_app(app_bundle_path, sdk, version)
|
251
250
|
simulator
|
252
251
|
end
|
253
252
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'calabash-cucumber/launch/simulator_helper'
|
2
2
|
require 'sim_launcher'
|
3
|
+
require 'calabash-cucumber/device'
|
3
4
|
require 'run_loop'
|
4
5
|
|
5
6
|
|
6
7
|
class Calabash::Cucumber::Launcher
|
7
8
|
attr_accessor :run_loop
|
8
9
|
attr_accessor :device_target
|
9
|
-
attr_accessor :
|
10
|
+
attr_accessor :device
|
10
11
|
|
11
12
|
def initialize(device_target=:simulator)
|
12
13
|
self.device_target = device_target
|
@@ -16,7 +17,11 @@ class Calabash::Cucumber::Launcher
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def calabash_no_stop?
|
19
|
-
|
20
|
+
calabash_no_launch? or ENV['NO_STOP']=="1"
|
21
|
+
end
|
22
|
+
|
23
|
+
def calabash_no_launch?
|
24
|
+
ENV['NO_LAUNCH']=='1'
|
20
25
|
end
|
21
26
|
|
22
27
|
def device_target?
|
@@ -32,15 +37,23 @@ class Calabash::Cucumber::Launcher
|
|
32
37
|
end
|
33
38
|
|
34
39
|
def ios_major_version
|
35
|
-
|
36
|
-
|
40
|
+
return nil if device.nil? or device.ios_version.nil?
|
41
|
+
device.ios_major_version
|
42
|
+
end
|
43
|
+
|
44
|
+
def ios_version
|
45
|
+
return nil if device.nil?
|
46
|
+
device.ios_version
|
37
47
|
end
|
38
48
|
|
39
49
|
|
40
|
-
def reset_app_jail(sdk,
|
50
|
+
def reset_app_jail(sdk=nil, path=nil)
|
41
51
|
return if device_target?
|
42
52
|
|
43
|
-
|
53
|
+
sdk = sdk || ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version
|
54
|
+
path = path || Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
55
|
+
|
56
|
+
app = File.basename(path)
|
44
57
|
bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
|
45
58
|
return if bundle.empty? # Assuming we're already clean
|
46
59
|
|
@@ -130,9 +143,7 @@ class Calabash::Cucumber::Launcher
|
|
130
143
|
|
131
144
|
if status=='200'
|
132
145
|
version_body = JSON.parse(res.body)
|
133
|
-
|
134
|
-
self.ios_version = version_body['iOS_version']
|
135
|
-
end
|
146
|
+
self.device = Calabash::Cucumber::Device.new(url, version_body)
|
136
147
|
end
|
137
148
|
|
138
149
|
status
|
@@ -82,21 +82,25 @@ module Calabash
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def wait_for_condition(options = {})
|
85
|
-
options[:timeout] = options[:timeout] ||
|
85
|
+
options[:timeout] = options[:timeout] || 30
|
86
86
|
options[:query] = options[:query] || "view"
|
87
|
+
if options.has_key?(:condition)
|
88
|
+
opt_condition = options[:condition]
|
89
|
+
if opt_condition.is_a?(Symbol)
|
90
|
+
target_condition = CALABASH_CONDITIONS[opt_condition]
|
91
|
+
elsif opt_condition.is_a?(String)
|
92
|
+
target_condition = options[:condition]
|
93
|
+
end
|
94
|
+
options[:condition] = target_condition
|
95
|
+
end
|
87
96
|
options[:condition] = options[:condition] || CALABASH_CONDITIONS[:none_animating]
|
88
97
|
options[:post_timeout] = options[:post_timeout] || 0.1
|
89
|
-
options[:frequency] = options[:frequency] || 0.
|
90
|
-
options[:retry_frequency] = options[:retry_frequency] || 0.
|
98
|
+
options[:frequency] = options[:frequency] || 0.3
|
99
|
+
options[:retry_frequency] = options[:retry_frequency] || 0.3
|
91
100
|
options[:count] = options[:count] || 2
|
92
101
|
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for condition (#{options[:condition]})"
|
93
102
|
options[:screenshot_on_error] = options[:screenshot_on_error] || true
|
94
103
|
|
95
|
-
if options[:condition] == CALABASH_CONDITIONS[:none_animating]
|
96
|
-
#puts "Waiting for none-animating has been found unreliable."
|
97
|
-
#puts "You are advised not to use it until this is resolved."
|
98
|
-
#puts "Test will continue..."
|
99
|
-
end
|
100
104
|
begin
|
101
105
|
Timeout::timeout(options[:timeout],WaitError) do
|
102
106
|
loop do
|
@@ -116,11 +120,15 @@ module Calabash
|
|
116
120
|
end
|
117
121
|
|
118
122
|
def wait_for_none_animating(options = {})
|
119
|
-
#sleep(0.3)
|
120
123
|
options[:condition] = CALABASH_CONDITIONS[:none_animating]
|
121
124
|
wait_for_condition(options)
|
122
125
|
end
|
123
126
|
|
127
|
+
def wait_for_no_network_indicator(options = {})
|
128
|
+
options[:condition] = CALABASH_CONDITIONS[:no_network_indicator]
|
129
|
+
wait_for_condition(options)
|
130
|
+
end
|
131
|
+
|
124
132
|
#may be called with a string (query) or an array of strings
|
125
133
|
def wait_for_transition(done_queries, check_options={},animation_options={})
|
126
134
|
done_queries = [*done_queries]
|
data/scripts/launch.rb
CHANGED
@@ -3,47 +3,38 @@
|
|
3
3
|
# Important Note #
|
4
4
|
# #
|
5
5
|
# When running calabash-ios tests at #
|
6
|
-
# www.
|
6
|
+
# www.xamarin.com/test-cloud #
|
7
7
|
# this file will be overwritten by #
|
8
8
|
# a file which automates #
|
9
9
|
# app launch on devices. #
|
10
10
|
# #
|
11
11
|
# Don't rely on this file being #
|
12
12
|
# present when running at #
|
13
|
-
#
|
14
|
-
# #
|
15
|
-
# Only put stuff here to automate #
|
16
|
-
# iOS Simulator. #
|
17
|
-
# #
|
18
|
-
# You can put your app bundle path #
|
19
|
-
# for automating simulator app start: #
|
20
|
-
# Uncomment APP_BUNDLE_PATH =.. #
|
13
|
+
# Xamarin Test Cloud #
|
21
14
|
# #
|
22
15
|
########################################
|
23
16
|
|
24
17
|
require 'calabash-cucumber/launcher'
|
25
18
|
|
26
|
-
# Uncomment and replace ?? appropriately
|
27
|
-
# This should point to your Simulator build
|
28
|
-
# which includes calabash framework
|
29
|
-
# this is usually the Calabash build configuration
|
30
|
-
# of your production target.
|
31
|
-
#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
32
|
-
#
|
33
19
|
|
20
|
+
# APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
21
|
+
# You may uncomment the above to overwrite the APP_BUNDLE_PATH
|
22
|
+
# However the recommended approach is to let Calabash find the app itself
|
23
|
+
# or set the environment variable APP_BUNDLE_PATH
|
34
24
|
|
35
25
|
Before do |scenario|
|
36
26
|
@calabash_launcher = Calabash::Cucumber::Launcher.new
|
37
|
-
@calabash_launcher.
|
38
|
-
|
27
|
+
unless @calabash_launcher.calabash_no_launch?
|
28
|
+
@calabash_launcher.relaunch
|
29
|
+
@calabash_launcher.calabash_notify(self)
|
30
|
+
end
|
39
31
|
end
|
40
32
|
|
41
33
|
After do |scenario|
|
42
34
|
unless @calabash_launcher.calabash_no_stop?
|
35
|
+
calabash_exit
|
43
36
|
if @calabash_launcher.active?
|
44
37
|
@calabash_launcher.stop
|
45
|
-
else
|
46
|
-
Calabash::Cucumber::SimulatorHelper.stop
|
47
38
|
end
|
48
39
|
end
|
49
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.144
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - '='
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.0.
|
149
|
+
version: 0.0.9
|
150
150
|
type: :runtime
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - '='
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0.0.
|
157
|
+
version: 0.0.9
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: awesome_print
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,14 +200,15 @@ files:
|
|
200
200
|
- features-skeleton/my_first.feature
|
201
201
|
- features-skeleton/step_definitions/calabash_steps.rb
|
202
202
|
- features-skeleton/step_definitions/my_first_steps.rb
|
203
|
+
- features-skeleton/support/01_launch.rb
|
204
|
+
- features-skeleton/support/02_pre_stop_hooks.rb
|
203
205
|
- features-skeleton/support/env.rb
|
204
|
-
- features-skeleton/support/hooks.rb
|
205
|
-
- features-skeleton/support/launch.rb
|
206
206
|
- features/step_definitions/calabash_steps.rb
|
207
207
|
- lib/calabash-cucumber.rb
|
208
208
|
- lib/calabash-cucumber/calabash_steps.rb
|
209
209
|
- lib/calabash-cucumber/core.rb
|
210
210
|
- lib/calabash-cucumber/cucumber.rb
|
211
|
+
- lib/calabash-cucumber/device.rb
|
211
212
|
- lib/calabash-cucumber/ibase.rb
|
212
213
|
- lib/calabash-cucumber/keyboard_helpers.rb
|
213
214
|
- lib/calabash-cucumber/launch/simulator_helper.rb
|
@@ -328,4 +329,3 @@ specification_version: 3
|
|
328
329
|
summary: Client for calabash-ios-server for automated functional testing on iOS
|
329
330
|
test_files:
|
330
331
|
- features/step_definitions/calabash_steps.rb
|
331
|
-
has_rdoc:
|
@@ -1,77 +0,0 @@
|
|
1
|
-
########################################
|
2
|
-
# #
|
3
|
-
# Important Note #
|
4
|
-
# #
|
5
|
-
# When running calabash-ios tests at #
|
6
|
-
# www.lesspainful.com #
|
7
|
-
# this file will be overwritten by #
|
8
|
-
# a file which automates #
|
9
|
-
# app launch on devices. #
|
10
|
-
# #
|
11
|
-
# Don't rely on this file being #
|
12
|
-
# present when running at #
|
13
|
-
# www.lesspainful.com. #
|
14
|
-
# #
|
15
|
-
# Only put stuff here to automate #
|
16
|
-
# iOS Simulator. #
|
17
|
-
# #
|
18
|
-
# You can put your app bundle path #
|
19
|
-
# for automating simulator app start: #
|
20
|
-
# Uncomment APP_BUNDLE_PATH =.. #
|
21
|
-
# #
|
22
|
-
########################################
|
23
|
-
|
24
|
-
require 'calabash-cucumber/launch/simulator_helper'
|
25
|
-
require 'sim_launcher'
|
26
|
-
|
27
|
-
# Uncomment and replace ?? appropriately
|
28
|
-
# This should point to your Simulator build
|
29
|
-
# which includes calabash framework
|
30
|
-
# this is usually the Calabash build configuration
|
31
|
-
# of your production target.
|
32
|
-
#APP_BUNDLE_PATH = "~/Library/Developer/Xcode/DerivedData/??/Build/Products/Calabash-iphonesimulator/??.app"
|
33
|
-
#
|
34
|
-
|
35
|
-
def reset_app_jail(sdk, app_path)
|
36
|
-
app = File.basename(app_path)
|
37
|
-
bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1`
|
38
|
-
return if bundle.empty? # Assuming we're already clean
|
39
|
-
|
40
|
-
sandbox = File.dirname(bundle)
|
41
|
-
['Library', 'Documents', 'tmp'].each do |dir|
|
42
|
-
FileUtils.rm_rf(File.join(sandbox, dir))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def relaunch(args=nil)
|
47
|
-
if ENV['NO_LAUNCH']!="1"
|
48
|
-
sdk = ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version
|
49
|
-
path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
|
50
|
-
if ENV['RESET_BETWEEN_SCENARIOS']=="1"
|
51
|
-
reset_app_jail(sdk, path)
|
52
|
-
end
|
53
|
-
|
54
|
-
Calabash::Cucumber::SimulatorHelper.relaunch(path,sdk,ENV['DEVICE'] || 'iphone', args)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def app_path
|
59
|
-
ENV['APP_BUNDLE_PATH'] || (defined?(APP_BUNDLE_PATH) && APP_BUNDLE_PATH)
|
60
|
-
end
|
61
|
-
|
62
|
-
def calabash_notify
|
63
|
-
if self.respond_to?(:on_launch)
|
64
|
-
self.on_launch
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
Before do |scenario|
|
69
|
-
relaunch
|
70
|
-
calabash_notify
|
71
|
-
end
|
72
|
-
|
73
|
-
at_exit do
|
74
|
-
if ENV['NO_LAUNCH']!="1" and ENV['NO_STOP']!="1"
|
75
|
-
Calabash::Cucumber::SimulatorHelper.stop
|
76
|
-
end
|
77
|
-
end
|