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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -1
  3. data/bin/calabash-ios-setup.rb +2 -4
  4. data/bin/calabash-ios-sim.rb +10 -40
  5. data/calabash-cucumber.gemspec +25 -22
  6. data/features-skeleton/support/01_launch.rb +1 -1
  7. data/lib/calabash-cucumber.rb +13 -1
  8. data/lib/calabash-cucumber/actions/instruments_actions.rb +0 -4
  9. data/lib/calabash-cucumber/actions/playback_actions.rb +0 -4
  10. data/lib/calabash-cucumber/core.rb +9 -16
  11. data/lib/calabash-cucumber/device.rb +11 -2
  12. data/lib/calabash-cucumber/environment_helpers.rb +4 -56
  13. data/lib/calabash-cucumber/ios7_operations.rb +4 -2
  14. data/lib/calabash-cucumber/keyboard_helpers.rb +6 -3
  15. data/lib/calabash-cucumber/launch/simulator_helper.rb +40 -386
  16. data/lib/calabash-cucumber/launch/simulator_launcher.rb +534 -0
  17. data/lib/calabash-cucumber/launcher.rb +172 -36
  18. data/lib/calabash-cucumber/operations.rb +3 -4
  19. data/lib/calabash-cucumber/playback_helpers.rb +15 -29
  20. data/lib/calabash-cucumber/rotation_helpers.rb +14 -10
  21. data/lib/calabash-cucumber/status_bar_helpers.rb +5 -1
  22. data/lib/calabash-cucumber/uia.rb +6 -12
  23. data/lib/calabash-cucumber/utils/logging.rb +97 -0
  24. data/lib/calabash-cucumber/utils/plist_buddy.rb +178 -0
  25. data/lib/calabash-cucumber/utils/simulator_accessibility.rb +250 -0
  26. data/lib/calabash-cucumber/utils/xctools.rb +95 -0
  27. data/lib/calabash-cucumber/version.rb +197 -2
  28. data/lib/calabash-cucumber/wait_helpers.rb +16 -20
  29. data/scripts/.irbrc +11 -6
  30. data/scripts/com.example.plist +0 -0
  31. data/scripts/launch.rb +1 -1
  32. data/spec/bin/calabash_ios_sim_spec.rb +24 -0
  33. data/spec/launcher_spec.rb +76 -0
  34. data/spec/logging_spec.rb +38 -0
  35. data/spec/plist_buddy_spec.rb +99 -0
  36. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
  37. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
  38. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
  39. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +1 -0
  40. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
  41. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
  42. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
  43. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
  44. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
  45. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
  46. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
  47. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
  48. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
  49. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
  50. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
  51. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
  52. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
  53. data/spec/resources/plist_buddy/com.example.plist +0 -0
  54. data/spec/resources/plist_buddy/com.testing.plist +18 -0
  55. data/spec/simulator_accessibility_spec.rb +144 -0
  56. data/spec/spec_helper.rb +31 -0
  57. data/spec/xctools_spec.rb +58 -0
  58. metadata +120 -34
@@ -1,21 +1,32 @@
1
- require 'calabash-cucumber/launch/simulator_helper'
1
+ require 'calabash-cucumber/launch/simulator_launcher'
2
+ require 'calabash-cucumber/utils/simulator_accessibility'
2
3
  require 'sim_launcher'
3
4
  require 'calabash-cucumber/device'
4
5
  require 'calabash-cucumber/actions/instruments_actions'
5
6
  require 'calabash-cucumber/actions/playback_actions'
6
7
  require 'run_loop'
7
8
  require 'cfpropertylist'
9
+ require 'calabash-cucumber/version'
10
+ require 'calabash-cucumber/utils/logging'
11
+
8
12
 
9
13
  class Calabash::Cucumber::Launcher
10
14
 
15
+ include Calabash::Cucumber::Logging
16
+ include Calabash::Cucumber::SimulatorAccessibility
17
+
11
18
  KNOWN_PRIVACY_SETTINGS = {:photos => 'kTCCServicePhotos', :calendar => 'kTCCServiceCalendar', :address_book => 'kTCCServiceAddressBook'}
12
19
 
20
+ @@launcher = nil
21
+
22
+ SERVER_VERSION_NOT_AVAILABLE = '0.0.0'
23
+ @@server_version = nil
24
+
13
25
  attr_accessor :run_loop
14
26
  attr_accessor :device
15
27
  attr_accessor :actions
16
28
  attr_accessor :launch_args
17
-
18
- @@launcher = nil
29
+ attr_accessor :simulator_launcher
19
30
 
20
31
  class StartError < RuntimeError
21
32
  attr_accessor :error
@@ -33,6 +44,11 @@ class Calabash::Cucumber::Launcher
33
44
  end
34
45
 
35
46
 
47
+ def initialize
48
+ @simulator_launcher = Calabash::Cucumber::SimulatorLauncher.new
49
+ @@launcher = self
50
+ end
51
+
36
52
  def actions
37
53
  attach if @actions.nil?
38
54
  @actions
@@ -42,7 +58,6 @@ class Calabash::Cucumber::Launcher
42
58
  l = launcher
43
59
  return l if l && l.active?
44
60
  l.attach
45
-
46
61
  end
47
62
 
48
63
  def attach(max_retry=1, timeout=10)
@@ -94,11 +109,10 @@ class Calabash::Cucumber::Launcher
94
109
  @@launcher
95
110
  end
96
111
 
97
- def initialize
98
- @@launcher = self
99
- end
100
-
101
112
  def ios_major_version
113
+ # pinging the app will set self.device
114
+ ping_app if self.device.nil?
115
+ # guard against Runtime errors
102
116
  return nil if device.nil? or device.ios_version.nil?
103
117
  device.ios_major_version
104
118
  end
@@ -109,14 +123,14 @@ class Calabash::Cucumber::Launcher
109
123
  end
110
124
 
111
125
  def reset_app_jail(sdk=nil, path=nil)
112
- sdk ||= sdk_version || SimLauncher::SdkDetector.new().latest_sdk_version
113
- path ||= Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
126
+ sdk ||= sdk_version || self.simulator_launcher.sdk_detector.latest_sdk_version
127
+ path ||= self.simulator_launcher.app_bundle_or_raise(app_path)
114
128
 
115
129
  app = File.basename(path)
116
130
  directories_for_sdk_prefix(sdk).each do |dir|
117
131
  bundle = `find "#{dir}/Applications" -type d -depth 2 -name "#{app}" | head -n 1`
118
132
  next if bundle.empty? # Assuming we're already clean
119
- if ENV['DEBUG']=='1'
133
+ if debug_logging?
120
134
  puts "Reset app state for #{bundle}"
121
135
  end
122
136
  sandbox = File.dirname(bundle)
@@ -134,7 +148,7 @@ class Calabash::Cucumber::Launcher
134
148
 
135
149
  # Call as update_privacy_settings('com.my.app', {:photos => {:allow => true}})
136
150
  def update_privacy_settings(bundle_id, opts={})
137
- if ENV['DEBUG']=='1'
151
+ if debug_logging?
138
152
  puts "Update privacy settings #{bundle_id}, #{opts}"
139
153
  end
140
154
  unless File.exist?(`which sqlite3`.strip)
@@ -144,15 +158,15 @@ class Calabash::Cucumber::Launcher
144
158
 
145
159
  setting_name = KNOWN_PRIVACY_SETTINGS[setting_name] || setting_name
146
160
  allow = setting_options[:allow] == false ? false : true
147
- sdk = setting_options[:sdk] || SimLauncher::SdkDetector.new().latest_sdk_version
161
+ sdk = setting_options[:sdk] || self.simulator_launcher.sdk_detector.latest_sdk_version
148
162
 
149
163
  dirs = directories_for_sdk_prefix(sdk)
150
- if ENV['DEBUG']=='1'
164
+ if debug_logging?
151
165
  puts "About to update privacy setting #{setting_name} for #{bundle_id}, allow: #{allow} in sdk #{sdk}, #{dirs}"
152
166
  end
153
167
 
154
168
  dirs.each do |dir|
155
- if ENV['DEBUG']=='1'
169
+ if debug_logging?
156
170
  puts "Setting access for #{bundle_id} for permission #{setting_name} to allow: #{allow}"
157
171
  end
158
172
  path_to_tcc_db = tcc_database_for_sdk_dir(dir)
@@ -167,7 +181,7 @@ class Calabash::Cucumber::Launcher
167
181
  sql = %Q['UPDATE access SET allowed=#{allowed_as_i} where client="#{bundle_id}" AND service="#{setting_name}";']
168
182
  end
169
183
 
170
- if ENV['DEBUG']=='1'
184
+ if debug_logging?
171
185
  puts "Executing sql #{sql} on #{path_to_tcc_db}"
172
186
  end
173
187
 
@@ -211,7 +225,11 @@ class Calabash::Cucumber::Launcher
211
225
  :device => device_env,
212
226
  :no_stop => calabash_no_stop?,
213
227
  :no_launch => calabash_no_launch?,
214
- :sdk_version => sdk_version
228
+ :sdk_version => sdk_version,
229
+ # do not advertise this to users!
230
+ # for example, don't include documentation about this
231
+ # this is used to instrument internal testing
232
+ :launch_retries => 5
215
233
  }
216
234
 
217
235
  #:device_target will be set
@@ -260,7 +278,7 @@ class Calabash::Cucumber::Launcher
260
278
  begin
261
279
  major = major.to_i
262
280
  rescue
263
- warn("SDK_VERSION invalid #{sdk_version} - ignoring...")
281
+ calabash_warn("SDK_VERSION invalid #{sdk_version} - ignoring...")
264
282
  end
265
283
  end
266
284
  return :instruments if major && major >= 7 # Only instruments supported for iOS7+
@@ -270,8 +288,7 @@ class Calabash::Cucumber::Launcher
270
288
  return use_sim_launcher_env? ? :sim_launcher : :instruments
271
289
  end
272
290
 
273
- sim_detector = SimLauncher::SdkDetector.new()
274
- available = sim_detector.available_sdk_versions.reject { |v| v.start_with?('7') }
291
+ available = self.simulator_launcher.sdk_detector.available_sdk_versions.reject { |v| v.start_with?('7') }
275
292
  if available.include?(sdk_version)
276
293
  :sim_launcher
277
294
  else
@@ -304,7 +321,7 @@ class Calabash::Cucumber::Launcher
304
321
  else
305
322
  device_xamarin_build_dir = 'iPhone'
306
323
  end
307
- args[:app] = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path, device_xamarin_build_dir)
324
+ args[:app] = self.simulator_launcher.app_bundle_or_raise(app_path, device_xamarin_build_dir)
308
325
  end
309
326
 
310
327
  args[:bundle_id] ||= detect_bundle_id_from_app_bundle(args)
@@ -324,18 +341,22 @@ class Calabash::Cucumber::Launcher
324
341
  end
325
342
  end
326
343
 
344
+ if simulator_target?(args)
345
+ enable_accessibility_on_simulators
346
+ end
347
+
327
348
  if run_with_instruments?(args)
328
349
  self.run_loop = new_run_loop(args)
329
350
  self.actions= Calabash::Cucumber::InstrumentsActions.new
330
351
  else
331
352
  # run with sim launcher
332
- sdk = sdk_version || SimLauncher::SdkDetector.new().available_sdk_versions.reverse.find { |x| !x.start_with?('7') }
333
- path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
334
353
  self.actions= Calabash::Cucumber::PlaybackActions.new
335
- Calabash::Cucumber::SimulatorHelper.relaunch(path, sdk, args[:device].to_s, args)
354
+ # why not just pass args - AFAICT args[:app] == app_path?
355
+ self.simulator_launcher.relaunch(app_path, sdk_version(), args)
336
356
  end
337
357
  self.launch_args = args
338
358
  ensure_connectivity
359
+ check_server_gem_compatibility
339
360
  end
340
361
 
341
362
  def detect_device_from_args(args)
@@ -360,13 +381,15 @@ class Calabash::Cucumber::Launcher
360
381
 
361
382
  end
362
383
 
384
+ # todo this method should be migrated to the Simulator Launcher
363
385
  def detect_app_bundle_from_args(args)
364
386
  if args[:device_target]=='simulator'
365
387
  device_xamarin_build_dir = 'iPhoneSimulator'
366
388
  else
367
389
  device_xamarin_build_dir = 'iPhone'
368
390
  end
369
- Calabash::Cucumber::SimulatorHelper.detect_app_bundle(nil, device_xamarin_build_dir)
391
+ # is this really only applicable to the Xamarin IDE?
392
+ self.simulator_launcher.detect_app_bundle(nil, device_xamarin_build_dir)
370
393
  end
371
394
 
372
395
  def detect_bundle_id_from_app_bundle(args)
@@ -387,22 +410,31 @@ class Calabash::Cucumber::Launcher
387
410
  end
388
411
 
389
412
  def new_run_loop(args)
390
- if RunLoop::Core.above_or_eql_version?('5.1', RunLoop::Core.xcode_version)
391
- Calabash::Cucumber::SimulatorHelper.stop
413
+
414
+ # for stability, quit the simulator if Xcode version is > 5.1 and the
415
+ # target device is the simulator
416
+ target_is_sim = simulator_target?(args)
417
+ xcode_gte_51 = RunLoop::Core.above_or_eql_version?('5.1', RunLoop::Core.xcode_version)
418
+ if target_is_sim and xcode_gte_51
419
+ self.simulator_launcher.stop
392
420
  end
421
+
393
422
  last_err = nil
394
- 5.times do
423
+
424
+ num_retries = args[:launch_retries] || 5
425
+
426
+ num_retries.times do
395
427
  begin
396
428
  return RunLoop.run(args)
397
429
  rescue RunLoop::TimeoutError => e
398
430
  last_err = e
399
- if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
431
+ if full_console_logging?
400
432
  puts 'retrying run loop...'
401
433
  end
402
- Calabash::Cucumber::SimulatorHelper.stop
434
+ self.simulator_launcher.stop
403
435
  end
404
436
  end
405
- Calabash::Cucumber::SimulatorHelper.stop
437
+ self.simulator_launcher.stop
406
438
  puts "Unable to start. Make sure you've set APP_BUNDLE_PATH to a build supported by this simulator version"
407
439
  raise StartError.new(last_err)
408
440
  end
@@ -413,8 +445,8 @@ class Calabash::Cucumber::Launcher
413
445
  timeout = (ENV['CONNECT_TIMEOUT'] || timeout).to_i
414
446
  retry_count = 0
415
447
  connected = false
416
- if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
417
- puts "Waiting for App to be ready"
448
+ if full_console_logging?
449
+ puts 'Waiting for App to be ready'
418
450
  end
419
451
  until connected do
420
452
  raise "MAX_RETRIES" if retry_count == max_retry_count
@@ -488,7 +520,7 @@ class Calabash::Cucumber::Launcher
488
520
 
489
521
  def detect_bundle_id
490
522
  begin
491
- bundle_path = Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path)
523
+ bundle_path = self.simulator_launcher.app_bundle_or_raise(app_path)
492
524
  plist_path = File.join(bundle_path, 'Info.plist')
493
525
  info_plist_as_hash(plist_path)['CFBundleIdentifier']
494
526
  rescue => e
@@ -508,8 +540,10 @@ class Calabash::Cucumber::Launcher
508
540
  (ENV['DEVICE_TARGET'] != nil) && (not simulator_target?)
509
541
  end
510
542
 
511
- def simulator_target?
512
- ENV['DEVICE_TARGET'] == 'simulator'
543
+ def simulator_target?(launch_args={})
544
+ value = ENV['DEVICE_TARGET'] || launch_args[:device_target]
545
+ return false if value.nil?
546
+ value.downcase.include?('simulator')
513
547
  end
514
548
 
515
549
  def sdk_version
@@ -556,6 +590,108 @@ class Calabash::Cucumber::Launcher
556
590
  msg.join("\n")
557
591
  end
558
592
 
593
+ # extracts server version from the app binary at +app_bundle_path+ by
594
+ # inspecting the binary's strings table.
595
+ #
596
+ # SPECIAL: sets the +@@server_version+ class variable to cache the server
597
+ # version because the server version will never change during runtime.
598
+ #
599
+ # @return [String] the server version
600
+ # @param [String] app_bundle_path file path (usually) to the application bundle
601
+ # @raise [RuntimeError] if there is no executable at +app_bundle_path+
602
+ # @raise [RuntimeError] if the server version cannot be extracted from any
603
+ # binary at +app_bundle_path+
604
+ def server_version_from_bundle(app_bundle_path)
605
+ return @@server_version unless @@server_version.nil?
606
+ exe_paths = []
607
+ Dir.foreach(app_bundle_path) do |item|
608
+ next if item == '.' or item == '..'
609
+
610
+ full_path = File.join(app_bundle_path, item)
611
+ if File.executable?(full_path) and not File.directory?(full_path)
612
+ exe_paths << full_path
613
+ end
614
+ end
615
+
616
+ if exe_paths.empty?
617
+ calabash_warn "could not find executable in '#{app_bundle_path}'"
618
+
619
+ @@server_version = SERVER_VERSION_NOT_AVAILABLE
620
+ return @@server_version
621
+ end
622
+
623
+ server_version = nil
624
+ exe_paths.each do |path|
625
+ server_version_string = `strings #{path} | grep -E 'CALABASH VERSION'`.chomp!
626
+ if server_version_string
627
+ server_version = server_version_string.split(' ').last
628
+ break
629
+ end
630
+ end
631
+
632
+ unless server_version
633
+ calabash_warn('could not find server version by inspecting the binary strings table')
634
+
635
+ @@server_version = SERVER_VERSION_NOT_AVAILABLE
636
+ return @@server_version
637
+ end
638
+
639
+ @@server_version = server_version
640
+ end
641
+
642
+ # queries the server for its version.
643
+ #
644
+ # SPECIAL: sets the +@@server_version+ class variable to cache the server
645
+ # version because the server version will never change during runtime.
646
+ #
647
+ # @return [String] the server version
648
+ # @raise [RuntimeError] if the server cannot be reached
649
+ def server_version_from_server
650
+ return @@server_version unless @@server_version.nil?
651
+ ensure_connectivity if self.device == nil
652
+ @@server_version = self.device.server_version
653
+ end
654
+
655
+ # checks the server and gem version compatibility and generates a warning if
656
+ # the server and gem are not compatible.
657
+ #
658
+ # WIP: this is a proof-of-concept implementation and requires _strict_
659
+ # equality. in the future we should allow minimum framework compatibility.
660
+ #
661
+ # @return [nil] nothing to return
662
+ def check_server_gem_compatibility
663
+ app_bundle_path = self.launch_args[:app]
664
+ if File.directory?(app_bundle_path)
665
+ server_version = server_version_from_bundle(app_bundle_path)
666
+ else
667
+ server_version = server_version_from_server
668
+ end
669
+
670
+ if server_version == SERVER_VERSION_NOT_AVAILABLE
671
+ calabash_warn('server version could not be found - skipping compatibility check')
672
+ return nil
673
+ end
674
+
675
+ server_version = Calabash::Cucumber::Version.new(server_version)
676
+ gem_version = Calabash::Cucumber::Version.new(Calabash::Cucumber::VERSION)
677
+ min_server_version = Calabash::Cucumber::Version.new(Calabash::Cucumber::MIN_SERVER_VERSION)
678
+
679
+ if server_version < min_server_version
680
+ msgs = []
681
+ msgs << 'server version is not compatible with gem version'
682
+ msgs << 'please update your server and gem'
683
+ msgs << " gem version: '#{gem_version}'"
684
+ msgs << "min server version: '#{min_server_version}'"
685
+ msgs << " server version: '#{server_version}'"
686
+
687
+ calabash_warn("#{msgs.join("\n")}")
688
+ else
689
+ if full_console_logging?
690
+ calabash_info("gem #{gem_version} is compat with '#{server_version}'")
691
+ end
692
+ end
693
+ nil
694
+ end
559
695
 
560
696
  end
561
697
 
@@ -11,6 +11,7 @@ require 'set'
11
11
  require 'calabash-cucumber/version'
12
12
  require 'calabash-cucumber/date_picker'
13
13
  require 'calabash-cucumber/ipad_1x_2x'
14
+ require 'calabash-cucumber/utils/logging'
14
15
 
15
16
  if not Object.const_defined?(:CALABASH_COUNT)
16
17
  #compatability with IRB
@@ -21,7 +22,9 @@ end
21
22
  module Calabash
22
23
  module Cucumber
23
24
  module Operations
25
+
24
26
  include Test::Unit::Assertions
27
+ include Calabash::Cucumber::Logging
25
28
  include Calabash::Cucumber::Core
26
29
  include Calabash::Cucumber::TestsHelpers
27
30
  include Calabash::Cucumber::WaitHelpers
@@ -64,10 +67,6 @@ module Calabash
64
67
  simple_touch(label, *args)
65
68
  end
66
69
 
67
- def tap_mark(label, *args)
68
- simple_touch(label, *args)
69
- end
70
-
71
70
  def html(q)
72
71
  query(q).map { |e| e['html'] }
73
72
  end
@@ -1,8 +1,12 @@
1
+ require 'calabash-cucumber/utils/logging'
2
+ require 'calabash-cucumber/device'
1
3
 
2
4
  module Calabash
3
5
  module Cucumber
4
6
  module PlaybackHelpers
5
7
 
8
+ include Calabash::Cucumber::Logging
9
+
6
10
  DATA_PATH = File.expand_path(File.dirname(__FILE__))
7
11
 
8
12
  def recording_name_for(recording_name, os, device)
@@ -19,11 +23,6 @@ module Calabash
19
23
  directories.each { |dir|
20
24
  path = "#{dir}/#{recording}"
21
25
  if File.exists?(path)
22
- # useful for debugging recordings, but too verbose for release
23
- # suggest (yet) another variable CALABASH_DEBUG_PLAYBACK ?
24
- #if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
25
- # puts "found compatible playback: '#{path}'"
26
- #end
27
26
  return File.read(path)
28
27
  end
29
28
  }
@@ -40,18 +39,12 @@ module Calabash
40
39
  end
41
40
 
42
41
  def load_playback_data(recording_name, options={})
43
- os = options['OS'] || ENV['OS']
44
42
  device = options['DEVICE'] || ENV['DEVICE'] || 'iphone'
45
43
 
46
- unless os
47
- if @calabash_launcher && @calabash_launcher.active?
48
- major = @calabash_launcher.ios_major_version
49
- else
50
- major = Calabash::Cucumber::SimulatorHelper.ios_major_version
51
- end
44
+ major = Calabash::Cucumber::Launcher.launcher.ios_major_version
52
45
 
53
- unless major
54
- raise <<EOF
46
+ unless major
47
+ raise <<EOF
55
48
  Unable to determine iOS major version
56
49
  Most likely you have updated your calabash-cucumber client
57
50
  but not your server. Please follow closely:
@@ -60,9 +53,8 @@ https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-vers
60
53
 
61
54
  If you are running version 0.9.120+ then please report this message as a bug.
62
55
  EOF
63
- end
64
- os = "ios#{major}"
65
56
  end
57
+ os = "ios#{major}"
66
58
 
67
59
  rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/features/playback"
68
60
 
@@ -70,7 +62,7 @@ EOF
70
62
  data = find_compatible_recording(recording_name, os, rec_dir, device, candidates)
71
63
 
72
64
  if data.nil? and device=='ipad'
73
- if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
65
+ if full_console_logging?
74
66
  puts "Unable to find recording for #{os} and #{device}. Trying with #{os} iphone"
75
67
  end
76
68
  data = find_compatible_recording(recording_name, os, rec_dir, 'iphone', candidates)
@@ -157,17 +149,11 @@ EOF
157
149
  end
158
150
 
159
151
  device = ENV['DEVICE'] || 'iphone'
160
- os = ENV['OS']
161
152
 
162
- unless os
163
- if @calabash_launcher && @calabash_launcher.active?
164
- major = @calabash_launcher.ios_major_version
165
- else
166
- major = Calabash::Cucumber::SimulatorHelper.ios_major_version
167
- end
153
+ major = Calabash::Cucumber::Launcher.launcher.ios_major_version
168
154
 
169
- unless major
170
- raise <<EOF
155
+ unless major
156
+ raise <<EOF
171
157
  Unable to determine iOS major version
172
158
  Most likely you have updated your calabash-cucumber client
173
159
  but not your server. Please follow closely:
@@ -176,9 +162,9 @@ https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-vers
176
162
 
177
163
  If you are running version 0.9.120+ then please report this message as a bug.
178
164
  EOF
179
- end
180
- os = "ios#{major}"
165
+
181
166
  end
167
+ os = "ios#{major}"
182
168
 
183
169
  file_name = "#{file_name}_#{os}_#{device}.base64"
184
170
  system('/usr/bin/plutil -convert binary1 -o _recording_binary.plist _recording.plist')
@@ -187,7 +173,7 @@ EOF
187
173
 
188
174
  rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/features/playback"
189
175
  unless File.directory?(rec_dir)
190
- if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
176
+ if full_console_logging?
191
177
  puts "creating playback directory at '#{rec_dir}'"
192
178
  end
193
179
  system("mkdir -p #{rec_dir}")