calabash-cucumber 0.9.169.pre2 → 0.9.169.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +14 -1
- data/bin/calabash-ios-setup.rb +2 -4
- data/bin/calabash-ios-sim.rb +10 -40
- data/calabash-cucumber.gemspec +25 -22
- data/features-skeleton/support/01_launch.rb +1 -1
- data/lib/calabash-cucumber.rb +13 -1
- data/lib/calabash-cucumber/actions/instruments_actions.rb +0 -4
- data/lib/calabash-cucumber/actions/playback_actions.rb +0 -4
- data/lib/calabash-cucumber/core.rb +9 -16
- data/lib/calabash-cucumber/device.rb +11 -2
- data/lib/calabash-cucumber/environment_helpers.rb +4 -56
- data/lib/calabash-cucumber/ios7_operations.rb +4 -2
- data/lib/calabash-cucumber/keyboard_helpers.rb +6 -3
- data/lib/calabash-cucumber/launch/simulator_helper.rb +40 -386
- data/lib/calabash-cucumber/launch/simulator_launcher.rb +534 -0
- data/lib/calabash-cucumber/launcher.rb +172 -36
- data/lib/calabash-cucumber/operations.rb +3 -4
- data/lib/calabash-cucumber/playback_helpers.rb +15 -29
- data/lib/calabash-cucumber/rotation_helpers.rb +14 -10
- data/lib/calabash-cucumber/status_bar_helpers.rb +5 -1
- data/lib/calabash-cucumber/uia.rb +6 -12
- data/lib/calabash-cucumber/utils/logging.rb +97 -0
- data/lib/calabash-cucumber/utils/plist_buddy.rb +178 -0
- data/lib/calabash-cucumber/utils/simulator_accessibility.rb +250 -0
- data/lib/calabash-cucumber/utils/xctools.rb +95 -0
- data/lib/calabash-cucumber/version.rb +197 -2
- data/lib/calabash-cucumber/wait_helpers.rb +16 -20
- data/scripts/.irbrc +11 -6
- data/scripts/com.example.plist +0 -0
- data/scripts/launch.rb +1 -1
- data/spec/bin/calabash_ios_sim_spec.rb +24 -0
- data/spec/launcher_spec.rb +76 -0
- data/spec/logging_spec.rb +38 -0
- data/spec/plist_buddy_spec.rb +99 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +1 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
- data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
- data/spec/resources/plist_buddy/com.example.plist +0 -0
- data/spec/resources/plist_buddy/com.testing.plist +18 -0
- data/spec/simulator_accessibility_spec.rb +144 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/xctools_spec.rb +58 -0
- metadata +120 -34
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
module Cucumber
|
5
|
+
|
6
|
+
# methods for interacting with the xcode tools
|
7
|
+
module XcodeTools
|
8
|
+
|
9
|
+
# returns the path to the current developer directory
|
10
|
+
#
|
11
|
+
# $ man xcode-select
|
12
|
+
# DEVELOPER_DIR
|
13
|
+
# Overrides the active developer directory. When DEVELOPER_DIR is set, its value
|
14
|
+
# will be used instead of the system-wide active developer directory.
|
15
|
+
#
|
16
|
+
# @return [String] path to current developer directory
|
17
|
+
def xcode_developer_dir
|
18
|
+
# respect DEVELOPER_DIR
|
19
|
+
return ENV['DEVELOPER_DIR'] if ENV['DEVELOPER_DIR']
|
20
|
+
# fall back to xcode-select
|
21
|
+
`xcode-select --print-path`.chomp
|
22
|
+
end
|
23
|
+
|
24
|
+
# returns the path to the current developer usr/bin directory
|
25
|
+
# @return [String] path to the current xcode binaries
|
26
|
+
def xcode_bin_dir
|
27
|
+
"#{xcode_developer_dir}/usr/bin"
|
28
|
+
end
|
29
|
+
|
30
|
+
# method for interacting with instruments
|
31
|
+
#
|
32
|
+
# instruments #=> /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
|
33
|
+
# instruments(:version) #=> 5.1.1
|
34
|
+
# instruments(:sims) #=> < list of known simulators >
|
35
|
+
#
|
36
|
+
# @param [String] cmd controls the return value. currently accepts nil,
|
37
|
+
# :sims, and :version as valid parameters
|
38
|
+
# @return [String] based on the value of +cmd+ version, a list known
|
39
|
+
# simulators, or the path to the instruments binary
|
40
|
+
# @raise [ArgumentError] if invalid +cmd+ is passed
|
41
|
+
def instruments(cmd=nil)
|
42
|
+
instruments = "#{xcode_bin_dir}/instruments"
|
43
|
+
return instruments if cmd == nil
|
44
|
+
|
45
|
+
case cmd
|
46
|
+
when :version
|
47
|
+
# instruments, version 5.1.1 (55045)
|
48
|
+
# noinspection RubyUnusedLocalVariable
|
49
|
+
Open3.popen3("#{instruments}") do |stdin, stdout, stderr, wait_thr|
|
50
|
+
stderr.read.chomp.split(' ')[2]
|
51
|
+
end
|
52
|
+
when :sims
|
53
|
+
devices = `#{instruments} -s devices`.chomp.split("\n")
|
54
|
+
devices.select { |device| device.downcase.include?('simulator') }
|
55
|
+
else
|
56
|
+
candidates = [:version, :sims]
|
57
|
+
raise(ArgumentError, "expected '#{cmd}' to be one of '#{candidates}'")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# does the instruments +version+ accept the -s (devices) flag?
|
62
|
+
#
|
63
|
+
# instruments_supports_hyphen_s?('4.6.3') #=> false
|
64
|
+
# instruments_supports_hyphen_s?('5.0.2') #=> true
|
65
|
+
# instruments_supports_hyphen_s?('5.1') #=> true
|
66
|
+
#
|
67
|
+
# @param [String] version a major.minor.{patch} version string - defaults
|
68
|
+
# to the currently active instruments binary
|
69
|
+
# @return [Boolean] true iff the version is >= 5.*
|
70
|
+
def instruments_supports_hyphen_s?(version=instruments(:version))
|
71
|
+
tokens = version.split('.')
|
72
|
+
return false if tokens[0].to_i < 5
|
73
|
+
return false if tokens[1].to_i < 1
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# returns a list of installed simulators by calling:
|
78
|
+
#
|
79
|
+
# $ instruments -s devices
|
80
|
+
#
|
81
|
+
# and parsing the output
|
82
|
+
# @return [Array<String>] an array of simulator names suitable for passing
|
83
|
+
# to instruments or xcodebuild
|
84
|
+
# @raise [RuntimeError] if the currently active instruments version does
|
85
|
+
# not support the -s flag
|
86
|
+
def installed_simulators
|
87
|
+
unless instruments_supports_hyphen_s?
|
88
|
+
raise(RuntimeError, "instruments '#{instruments(:version)}' does not support '-s devices' arguments")
|
89
|
+
end
|
90
|
+
instruments(:sims)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -1,6 +1,201 @@
|
|
1
1
|
module Calabash
|
2
2
|
module Cucumber
|
3
|
-
VERSION = '0.9.169.
|
4
|
-
|
3
|
+
VERSION = '0.9.169.pre5'
|
4
|
+
MIN_SERVER_VERSION = '0.9.169.pre2'
|
5
|
+
|
6
|
+
class Version
|
7
|
+
|
8
|
+
attr_accessor :major
|
9
|
+
attr_accessor :minor
|
10
|
+
attr_accessor :patch
|
11
|
+
attr_accessor :pre
|
12
|
+
attr_accessor :pre_version
|
13
|
+
|
14
|
+
def initialize(version)
|
15
|
+
tokens = version.split('.')
|
16
|
+
count = tokens.count
|
17
|
+
if count == 4
|
18
|
+
@pre = tokens[3]
|
19
|
+
pre_tokens = @pre.scan(/\D+|\d+/)
|
20
|
+
@pre_version = pre_tokens[1].to_i if pre_tokens.count == 2
|
21
|
+
end
|
22
|
+
|
23
|
+
@major, @minor, @patch = version.split('.').map(&:to_i)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
str = [@major, @minor, @patch].join('.')
|
28
|
+
str = "#{str}.#{@pre}" if @pre
|
29
|
+
str
|
30
|
+
end
|
31
|
+
|
32
|
+
def == (other)
|
33
|
+
compare(self, other) == 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def != (other)
|
37
|
+
compare(self, other) != 0
|
38
|
+
end
|
39
|
+
|
40
|
+
def < (other)
|
41
|
+
compare(self, other) < 0
|
42
|
+
end
|
43
|
+
|
44
|
+
def > (other)
|
45
|
+
compare(self, other) > 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def <= (other)
|
49
|
+
compare(self, other) <= 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def >= (other)
|
53
|
+
compare(self, other) >= 0
|
54
|
+
end
|
55
|
+
|
56
|
+
def compare(a, b)
|
57
|
+
|
58
|
+
if a.major != b.major
|
59
|
+
return a.major > b.major ? 1 : -1
|
60
|
+
end
|
61
|
+
|
62
|
+
if a.minor != b.minor
|
63
|
+
return a.minor > b.minor ? 1 : -1
|
64
|
+
end
|
65
|
+
|
66
|
+
if a.patch != b.patch
|
67
|
+
return a.patch > b.patch ? 1 : -1
|
68
|
+
end
|
69
|
+
|
70
|
+
return 1 if a.pre and (not b.pre)
|
71
|
+
return -1 if (not a.pre) and b.pre
|
72
|
+
|
73
|
+
return 1 if a.pre_version and (not b.pre_version)
|
74
|
+
return -1 if (not a.pre_version) and b.pre_version
|
75
|
+
|
76
|
+
if a.pre_version != b.pre_version
|
77
|
+
return a.pre_version > b.pre_version ? 1 : -1
|
78
|
+
end
|
79
|
+
|
80
|
+
0
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
5
84
|
end
|
6
85
|
end
|
86
|
+
|
87
|
+
if __FILE__ == $0
|
88
|
+
require 'test/unit'
|
89
|
+
|
90
|
+
class LocalTest < Test::Unit::TestCase
|
91
|
+
include Calabash::Cucumber
|
92
|
+
|
93
|
+
def test_version
|
94
|
+
a = Version.new('0.9.169')
|
95
|
+
assert_equal(0, a.major)
|
96
|
+
assert_equal(9, a.minor)
|
97
|
+
assert_equal(169, a.patch)
|
98
|
+
assert_nil(a.pre)
|
99
|
+
assert_nil(a.pre_version)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_unnumbered_prerelease
|
103
|
+
a = Version.new('0.9.169.pre')
|
104
|
+
assert_equal('pre', a.pre)
|
105
|
+
assert_nil(a.pre_version)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_numbered_prerelease
|
109
|
+
a = Version.new('0.9.169.pre1')
|
110
|
+
assert_equal('pre1', a.pre)
|
111
|
+
assert_equal(1, a.pre_version)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_compare_equal
|
115
|
+
a = Version.new('0.9.169')
|
116
|
+
b = Version.new('0.9.169')
|
117
|
+
assert(a == b)
|
118
|
+
|
119
|
+
a = Version.new('0.9.169.pre')
|
120
|
+
b = Version.new('0.9.169.pre')
|
121
|
+
assert(a == b)
|
122
|
+
|
123
|
+
a = Version.new('0.9.169.pre2')
|
124
|
+
b = Version.new('0.9.169.pre2')
|
125
|
+
assert(a == b)
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_compare_not_equal
|
130
|
+
a = Version.new('0.9.168')
|
131
|
+
b = Version.new('0.9.169')
|
132
|
+
assert(a != b)
|
133
|
+
|
134
|
+
|
135
|
+
a = Version.new('0.9.169')
|
136
|
+
b = Version.new('0.9.169.pre1')
|
137
|
+
assert(a != b)
|
138
|
+
|
139
|
+
a = Version.new('0.9.169.pre')
|
140
|
+
b = Version.new('0.9.169.pre1')
|
141
|
+
assert(a != b)
|
142
|
+
|
143
|
+
a = Version.new('0.9.169.pre1')
|
144
|
+
b = Version.new('0.9.169.pre2')
|
145
|
+
assert(a != b)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_compare_lt
|
149
|
+
a = Version.new('0.9.168')
|
150
|
+
b = Version.new('0.9.169')
|
151
|
+
assert(a < b)
|
152
|
+
|
153
|
+
a = Version.new('0.9.169')
|
154
|
+
b = Version.new('0.9.169.pre')
|
155
|
+
assert(a < b)
|
156
|
+
|
157
|
+
a = Version.new('0.9.169.pre')
|
158
|
+
b = Version.new('0.9.169.pre1')
|
159
|
+
assert(a < b)
|
160
|
+
|
161
|
+
a = Version.new('0.9.169.pre1')
|
162
|
+
b = Version.new('0.9.169.pre2')
|
163
|
+
assert(a < b)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_compare_gt
|
167
|
+
a = Version.new('0.9.169')
|
168
|
+
b = Version.new('0.9.168')
|
169
|
+
assert(a > b)
|
170
|
+
|
171
|
+
a = Version.new('0.9.169.pre')
|
172
|
+
b = Version.new('0.9.169')
|
173
|
+
assert(a > b)
|
174
|
+
|
175
|
+
a = Version.new('0.9.169.pre1')
|
176
|
+
b = Version.new('0.9.169.pre')
|
177
|
+
assert(a > b)
|
178
|
+
|
179
|
+
a = Version.new('0.9.169.pre2')
|
180
|
+
b = Version.new('0.9.169.pre1')
|
181
|
+
assert(a > b)
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_compare_lte
|
185
|
+
a = Version.new('0.9.168')
|
186
|
+
b = Version.new('0.9.169')
|
187
|
+
assert(a <= b)
|
188
|
+
a = Version.new('0.9.169')
|
189
|
+
assert(a <= b)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_compare_gte
|
193
|
+
a = Version.new('0.9.169')
|
194
|
+
b = Version.new('0.9.168')
|
195
|
+
assert(a >= b)
|
196
|
+
b = Version.new('0.9.169')
|
197
|
+
assert(a >= b)
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'calabash-cucumber/core'
|
2
2
|
require 'calabash-cucumber/tests_helpers'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'calabash-cucumber/utils/logging'
|
4
5
|
|
5
6
|
module Calabash
|
6
7
|
module Cucumber
|
7
8
|
module WaitHelpers
|
9
|
+
include Calabash::Cucumber::Logging
|
8
10
|
include Calabash::Cucumber::Core
|
9
11
|
include Calabash::Cucumber::TestsHelpers
|
10
12
|
|
11
|
-
CLIENT_TIMEOUT_ADDITION = 5
|
12
|
-
|
13
13
|
class WaitError < RuntimeError
|
14
14
|
end
|
15
15
|
|
@@ -114,11 +114,8 @@ module Calabash
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def wait_for_condition(options = {})
|
117
|
-
timeout = options[:timeout]
|
118
|
-
|
119
|
-
timeout = 30
|
120
|
-
end
|
121
|
-
options[:query] = options[:query] || '*'
|
117
|
+
options[:timeout] = options[:timeout] || 30
|
118
|
+
options[:query] = options[:query] || "view"
|
122
119
|
if options.has_key?(:condition)
|
123
120
|
opt_condition = options[:condition]
|
124
121
|
if opt_condition.is_a?(Symbol)
|
@@ -130,23 +127,22 @@ module Calabash
|
|
130
127
|
end
|
131
128
|
options[:condition] = options[:condition] || CALABASH_CONDITIONS[:none_animating]
|
132
129
|
options[:post_timeout] = options[:post_timeout] || 0
|
133
|
-
|
134
|
-
retry_frequency = options[:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
screenshot_on_error = options[:screenshot_on_error]
|
139
|
-
end
|
130
|
+
options[:frequency] = options[:frequency] || 0.3
|
131
|
+
retry_frequency = options[:retry_frequency] = options[:retry_frequency] || 0.3
|
132
|
+
options[:count] = options[:count] || 2
|
133
|
+
timeout_message = options[:timeout_message] = options[:timeout_message] || "Timeout waiting for condition (#{options[:condition]})"
|
134
|
+
screenshot_on_error = options[:screenshot_on_error] = options[:screenshot_on_error] || true
|
140
135
|
|
141
136
|
begin
|
142
|
-
Timeout::timeout(timeout
|
137
|
+
Timeout::timeout(options[:timeout],WaitError) do
|
138
|
+
loop do
|
143
139
|
res = http({:method => :post, :path => 'condition'},
|
144
140
|
options)
|
145
141
|
res = JSON.parse(res)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
142
|
+
break if res['outcome'] == 'SUCCESS'
|
143
|
+
sleep(options[:retry_frequency]) if options[:retry_frequency] > 0
|
144
|
+
end
|
145
|
+
sleep(options[:post_timeout]) if options[:post_timeout] > 0
|
150
146
|
end
|
151
147
|
rescue WaitError => e
|
152
148
|
msg = timeout_message || e
|
@@ -162,7 +158,7 @@ module Calabash
|
|
162
158
|
raise wait_error(msg)
|
163
159
|
end
|
164
160
|
rescue Exception => e
|
165
|
-
handle_error_with_options(e,nil, screenshot_on_error)
|
161
|
+
handle_error_with_options(e,nil, options[:screenshot_on_error])
|
166
162
|
end
|
167
163
|
end
|
168
164
|
|
data/scripts/.irbrc
CHANGED
@@ -4,22 +4,27 @@ require 'irb/ext/save-history'
|
|
4
4
|
require 'awesome_print'
|
5
5
|
AwesomePrint.irb!
|
6
6
|
|
7
|
-
ARGV.concat [
|
8
|
-
|
9
|
-
|
7
|
+
ARGV.concat [ '--readline',
|
8
|
+
'--prompt-mode',
|
9
|
+
'simple']
|
10
10
|
|
11
11
|
# 25 entries in the list
|
12
12
|
IRB.conf[:SAVE_HISTORY] = 50
|
13
13
|
|
14
14
|
# Store results in home directory with specified file name
|
15
|
-
IRB.conf[:HISTORY_FILE] =
|
15
|
+
IRB.conf[:HISTORY_FILE] = '.irb-history'
|
16
16
|
|
17
17
|
require 'calabash-cucumber/operations'
|
18
|
+
|
19
|
+
# legacy support - module was deprecated 0.9.169
|
20
|
+
# and replaced with simulator_launcher
|
18
21
|
require 'calabash-cucumber/launch/simulator_helper'
|
19
|
-
|
22
|
+
|
23
|
+
require 'calabash-cucumber/launch/simulator_launcher'
|
24
|
+
SIM=Calabash::Cucumber::SimulatorLauncher.new()
|
20
25
|
|
21
26
|
extend Calabash::Cucumber::Operations
|
22
27
|
|
23
28
|
def embed(x,y=nil,z=nil)
|
24
|
-
|
29
|
+
puts "Screenshot at #{x}"
|
25
30
|
end
|
Binary file
|
data/scripts/launch.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.join(__FILE__, '..', '..', 'spec_helper'))
|
2
|
+
require File.expand_path(File.join(__FILE__, '..', '..', '..', 'bin', 'calabash-ios-sim'))
|
3
|
+
require 'calabash-cucumber/utils/simulator_accessibility'
|
4
|
+
require 'calabash-cucumber/wait_helpers'
|
5
|
+
|
6
|
+
include Calabash::Cucumber::WaitHelpers
|
7
|
+
|
8
|
+
describe 'calabash ios sim cli' do
|
9
|
+
|
10
|
+
it 'should deprecate the sim_quit method' do
|
11
|
+
out = capture_stderr do
|
12
|
+
quit_sim
|
13
|
+
end
|
14
|
+
tokens = out.string.split("\n")
|
15
|
+
puts tokens
|
16
|
+
expect(tokens[1]).to be == "WARN: deprecated '0.9.169' - 'use Calabash::Cucumber::SimulatorAccessibility.quit_simulator'"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should be able to reset the content and settings of the simulator' do
|
20
|
+
calabash_sim_reset
|
21
|
+
expect(simulator_support_sdk_dirs.count).to be == 1
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'calabash-cucumber/launcher'
|
3
|
+
|
4
|
+
describe 'Calabash Launcher' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@launcher = Calabash::Cucumber::Launcher.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'simulator_target? should respond correctly to DEVICE_TARGET' do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
ENV['DEVICE_TARGET'] = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_device_target(val)
|
17
|
+
ENV['DEVICE_TARGET'] = val
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return true if DEVICE_TARGET is nil' do
|
21
|
+
expect(@launcher.simulator_target?).to be == false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return true if DEVICE_TARGET is simulator' do
|
25
|
+
set_device_target('simulator')
|
26
|
+
expect(@launcher.simulator_target?).to be == true
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return false if DEVICE_TARGET is device' do
|
30
|
+
set_device_target('device')
|
31
|
+
expect(@launcher.simulator_target?).to be == false
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should return false if DEVICE_TARGET is udid' do
|
35
|
+
# noinspection SpellCheckingInspection
|
36
|
+
set_device_target('66h3hfgc466836ehcg72738eh8f322842855d2fd')
|
37
|
+
expect(@launcher.simulator_target?).to be == false
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should return true for Xcode 5.1 style simulator names' do
|
41
|
+
set_device_target('iPhone Retina (4-inch) - Simulator - iOS 7.1')
|
42
|
+
expect(@launcher.simulator_target?).to be == true
|
43
|
+
|
44
|
+
set_device_target('iPhone - Simulator - iOS 6.1')
|
45
|
+
expect(@launcher.simulator_target?).to be == true
|
46
|
+
|
47
|
+
set_device_target('iPad Retina (64-bit) - Simulator - iOS 7.0')
|
48
|
+
expect(@launcher.simulator_target?).to be == true
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return true when passed a hash with :device_target => a simulator' do
|
52
|
+
hash = {:device_target => 'simulator'}
|
53
|
+
expect(@launcher.simulator_target?(hash)).to be == true
|
54
|
+
|
55
|
+
hash = {:device_target => 'iPhone Retina (4-inch) - Simulator - iOS 7.1'}
|
56
|
+
expect(@launcher.simulator_target?(hash)).to be == true
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return false when passed a hash with :device_target != a simulator' do
|
60
|
+
hash = {:device_target => 'device'}
|
61
|
+
expect(@launcher.simulator_target?(hash)).to be == false
|
62
|
+
|
63
|
+
hash = {:device_target => '66h3hfgc466836ehcg72738eh8f322842855d2fd'}
|
64
|
+
expect(@launcher.simulator_target?(hash)).to be == false
|
65
|
+
|
66
|
+
hash = {:device_target => 'foobar'}
|
67
|
+
expect(@launcher.simulator_target?(hash)).to be == false
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should return false when passed a hash with no :device_target key' do
|
71
|
+
hash = {:foobar => 'foobar'}
|
72
|
+
expect(@launcher.simulator_target?(hash)).to be == false
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|