calabash-cucumber 0.10.0.pre1 → 0.10.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/features/step_definitions/calabash_steps.rb +1 -1
  3. data/lib/calabash-cucumber/actions/instruments_actions.rb +15 -4
  4. data/lib/calabash-cucumber/actions/playback_actions.rb +12 -3
  5. data/lib/calabash-cucumber/connection.rb +3 -0
  6. data/lib/calabash-cucumber/connection_helpers.rb +4 -0
  7. data/lib/calabash-cucumber/core.rb +637 -83
  8. data/lib/calabash-cucumber/date_picker.rb +148 -29
  9. data/lib/calabash-cucumber/device.rb +160 -3
  10. data/lib/calabash-cucumber/environment_helpers.rb +91 -46
  11. data/lib/calabash-cucumber/failure_helpers.rb +40 -0
  12. data/lib/calabash-cucumber/http_helpers.rb +9 -2
  13. data/lib/calabash-cucumber/ibase.rb +136 -17
  14. data/lib/calabash-cucumber/ios7_operations.rb +13 -9
  15. data/lib/calabash-cucumber/ipad_1x_2x.rb +103 -48
  16. data/lib/calabash-cucumber/keyboard_helpers.rb +253 -144
  17. data/lib/calabash-cucumber/keychain_helpers.rb +46 -32
  18. data/lib/calabash-cucumber/launch/simulator_helper.rb +13 -12
  19. data/lib/calabash-cucumber/launch/simulator_launcher.rb +111 -78
  20. data/lib/calabash-cucumber/launcher.rb +265 -25
  21. data/lib/calabash-cucumber/map.rb +24 -22
  22. data/lib/calabash-cucumber/operations.rb +4 -160
  23. data/lib/calabash-cucumber/playback_helpers.rb +26 -0
  24. data/lib/calabash-cucumber/query_helpers.rb +12 -0
  25. data/lib/calabash-cucumber/rotation_helpers.rb +64 -8
  26. data/lib/calabash-cucumber/status_bar_helpers.rb +40 -3
  27. data/lib/calabash-cucumber/tests_helpers.rb +43 -14
  28. data/lib/calabash-cucumber/uia.rb +93 -9
  29. data/lib/calabash-cucumber/utils/logging.rb +30 -16
  30. data/lib/calabash-cucumber/utils/plist_buddy.rb +18 -19
  31. data/lib/calabash-cucumber/utils/simulator_accessibility.rb +41 -30
  32. data/lib/calabash-cucumber/utils/xctools.rb +31 -21
  33. data/lib/calabash-cucumber/version.rb +98 -2
  34. data/lib/calabash-cucumber/wait_helpers.rb +257 -77
  35. data/staticlib/calabash.framework.zip +0 -0
  36. metadata +64 -231
  37. data/.gitignore +0 -17
  38. data/CHANGES.txt +0 -1
  39. data/Gemfile +0 -4
  40. data/Rakefile +0 -72
  41. data/calabash-cucumber.gemspec +0 -36
  42. data/epl-v10.html +0 -261
  43. data/lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64 +0 -51
  44. data/lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64 +0 -51
  45. data/lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64 +0 -74
  46. data/lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64 +0 -74
  47. data/lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64 +0 -15
  48. data/lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64 +0 -15
  49. data/lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64 +0 -22
  50. data/lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64 +0 -22
  51. data/lib/calabash-cucumber/resources/pan_ios5_ipad.base64 +0 -199
  52. data/lib/calabash-cucumber/resources/pan_ios5_iphone.base64 +0 -199
  53. data/lib/calabash-cucumber/resources/pan_ios6_ipad.base64 +0 -206
  54. data/lib/calabash-cucumber/resources/pan_ios6_iphone.base64 +0 -206
  55. data/lib/calabash-cucumber/resources/pinch_in_ios4_ipad.base64 +0 -104
  56. data/lib/calabash-cucumber/resources/pinch_in_ios4_iphone.base64 +0 -104
  57. data/lib/calabash-cucumber/resources/pinch_in_ios5_ipad.base64 +0 -144
  58. data/lib/calabash-cucumber/resources/pinch_in_ios5_iphone.base64 +0 -144
  59. data/lib/calabash-cucumber/resources/pinch_in_ios6_ipad.base64 +0 -70
  60. data/lib/calabash-cucumber/resources/pinch_in_ios6_iphone.base64 +0 -70
  61. data/lib/calabash-cucumber/resources/pinch_out_ios5_ipad.base64 +0 -207
  62. data/lib/calabash-cucumber/resources/pinch_out_ios5_iphone.base64 +0 -207
  63. data/lib/calabash-cucumber/resources/pinch_out_ios6_ipad.base64 +0 -96
  64. data/lib/calabash-cucumber/resources/pinch_out_ios6_iphone.base64 +0 -96
  65. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_ipad.base64 +0 -2
  66. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_iphone.base64 +0 -2
  67. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_ipad.base64 +0 -2
  68. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_iphone.base64 +0 -2
  69. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_ipad.base64 +0 -2
  70. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_iphone.base64 +0 -2
  71. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_ipad.base64 +0 -2
  72. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_iphone.base64 +0 -2
  73. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_ipad.base64 +0 -2
  74. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_iphone.base64 +0 -2
  75. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_ipad.base64 +0 -2
  76. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_iphone.base64 +0 -2
  77. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_ipad.base64 +0 -2
  78. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_iphone.base64 +0 -2
  79. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_ipad.base64 +0 -2
  80. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_iphone.base64 +0 -2
  81. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_ipad.base64 +0 -2
  82. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_iphone.base64 +0 -2
  83. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_ipad.base64 +0 -2
  84. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_iphone.base64 +0 -2
  85. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_ipad.base64 +0 -2
  86. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_iphone.base64 +0 -2
  87. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_ipad.base64 +0 -2
  88. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_iphone.base64 +0 -2
  89. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_ipad.base64 +0 -2
  90. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_iphone.base64 +0 -2
  91. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_ipad.base64 +0 -2
  92. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_iphone.base64 +0 -2
  93. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_ipad.base64 +0 -2
  94. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_iphone.base64 +0 -2
  95. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_ipad.base64 +0 -2
  96. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64 +0 -2
  97. data/lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64 +0 -18
  98. data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +0 -31
  99. data/lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64 +0 -25
  100. data/lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64 +0 -25
  101. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64 +0 -15
  102. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64 +0 -15
  103. data/lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64 +0 -18
  104. data/lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64 +0 -18
  105. data/lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64 +0 -17
  106. data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +0 -34
  107. data/lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64 +0 -28
  108. data/lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64 +0 -28
  109. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64 +0 -17
  110. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64 +0 -17
  111. data/lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64 +0 -13
  112. data/lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64 +0 -13
  113. data/lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64 +0 -17
  114. data/lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64 +0 -17
  115. data/lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64 +0 -25
  116. data/lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64 +0 -25
  117. data/lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64 +0 -34
  118. data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +0 -28
  119. data/lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64 +0 -25
  120. data/lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64 +0 -25
  121. data/lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64 +0 -7
  122. data/lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64 +0 -9
  123. data/lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64 +0 -7
  124. data/lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64 +0 -9
  125. data/lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64 +0 -9
  126. data/lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64 +0 -9
  127. data/lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64 +0 -9
  128. data/lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64 +0 -9
  129. data/lib/calabash-cucumber/resources/touch_ios4_ipad.base64 +0 -9
  130. data/lib/calabash-cucumber/resources/touch_ios4_iphone.base64 +0 -9
  131. data/lib/calabash-cucumber/resources/touch_ios5_ipad.base64 +0 -9
  132. data/lib/calabash-cucumber/resources/touch_ios5_iphone.base64 +0 -9
  133. data/lib/calabash-cucumber/resources/touch_ios7_ipad.base64 +0 -9
  134. data/lib/calabash-cucumber/resources/touch_ios7_iphone.base64 +0 -9
  135. data/lib/calabash-cucumber/resources/wheel_down_ios4_ipad.base64 +0 -159
  136. data/lib/calabash-cucumber/resources/wheel_down_ios4_iphone.base64 +0 -159
  137. data/lib/calabash-cucumber/resources/wheel_down_ios5_ipad.base64 +0 -156
  138. data/lib/calabash-cucumber/resources/wheel_down_ios5_iphone.base64 +0 -156
  139. data/lib/calabash-cucumber/resources/wheel_up_ios4_ipad.base64 +0 -166
  140. data/lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64 +0 -166
  141. data/lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64 +0 -156
  142. data/lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64 +0 -156
  143. data/scripts/EmptyAppHack.app/Default-568h@2x.png +0 -0
  144. data/scripts/EmptyAppHack.app/Default.png +0 -0
  145. data/scripts/EmptyAppHack.app/Default@2x.png +0 -0
  146. data/scripts/EmptyAppHack.app/EmptyAppHack +0 -0
  147. data/scripts/EmptyAppHack.app/Info.plist +0 -0
  148. data/scripts/EmptyAppHack.app/PkgInfo +0 -1
  149. data/scripts/EmptyAppHack.app/en.lproj/InfoPlist.strings +0 -0
  150. data/scripts/com.example.plist +0 -0
  151. data/scripts/data/.GlobalPreferences.plist +0 -0
  152. data/scripts/reset_simulator.scpt +0 -0
  153. data/spec/bin/calabash_ios_sim_spec.rb +0 -24
  154. data/spec/launcher_spec.rb +0 -166
  155. data/spec/logging_spec.rb +0 -38
  156. data/spec/plist_buddy_spec.rb +0 -99
  157. data/spec/resources/enable-accessibility/6.1/.gitkeep +0 -0
  158. data/spec/resources/enable-accessibility/7.0.3-64/.gitkeep +0 -0
  159. data/spec/resources/enable-accessibility/7.0.3/.gitkeep +0 -0
  160. data/spec/resources/enable-accessibility/7.1-64/.gitkeep +0 -0
  161. data/spec/resources/enable-accessibility/7.1/.gitkeep +0 -0
  162. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
  163. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
  164. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
  165. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +0 -1
  166. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
  167. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
  168. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
  169. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
  170. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
  171. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
  172. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
  173. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
  174. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
  175. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
  176. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
  177. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
  178. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
  179. data/spec/resources/plist_buddy/com.example.plist +0 -0
  180. data/spec/resources/plist_buddy/com.testing.plist +0 -18
  181. data/spec/simulator_accessibility_spec.rb +0 -206
  182. data/spec/spec_helper.rb +0 -31
  183. data/spec/version_spec.rb +0 -13
  184. data/spec/xctools_spec.rb +0 -58
@@ -2,29 +2,36 @@
2
2
  module Calabash
3
3
  module Cucumber
4
4
 
5
- # internal logging methods for calabash-ios gem
5
+ # Internal logging methods for the calabash-ios gem.
6
6
  module Logging
7
7
 
8
- # controls the the kind of information calabash logs
8
+ # @!visibility private
9
+ # Has full console logging been enabled?
9
10
  #
10
- # this is considered one level above debug logging - maybe we should call
11
+ # The return value is controlled by the `CALABASH_FULL_CONSOLE_OUTPUT`
12
+ # environment variable.
13
+ #
14
+ # This is considered one level above debug logging - maybe we should call
11
15
  # the info log level.
12
16
  #
13
- # @return [Boolean] +true+ if the <tt>CALABASH_FULL_CONSOLE_OUTPUT</tt> is set to
14
- # '1'
17
+ # @return [Boolean] Returns `true` if full logging has been enabled.
15
18
  def full_console_logging?
16
19
  ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
17
20
  end
18
21
 
19
- # controls whether or not calabash logs debug information
22
+ # @!visibility private
23
+ # Has debug logging been enabled?
24
+ #
25
+ # The return value is controlled by the `DEBUG` environment variable.
20
26
  #
21
- # @return [Boolean] +true+ if the <tt>DEBUG</tt> is set to '1'
27
+ # @return [Boolean] Returns `true` if debug logging has been enabled.
22
28
  def debug_logging?
23
29
  ENV['DEBUG'] == '1'
24
30
  end
25
31
 
26
- # prints a blue/cyan warning message
32
+ # Prints a blue warning message.
27
33
  # @param [String] msg the message to print
34
+ # @return [void]
28
35
  def calabash_warn(msg)
29
36
  begin
30
37
  warn "\033[34m\nWARN: #{msg}\033[0m"
@@ -33,8 +40,9 @@ module Calabash
33
40
  end
34
41
  end
35
42
 
36
- # prints a green info message
43
+ # Prints a green info message.
37
44
  # @param [String] msg the message to print
45
+ # @return [void]
38
46
  def calabash_info(msg)
39
47
  begin
40
48
  puts "\033[32m\nINFO: #{msg}\033[0m"
@@ -43,27 +51,33 @@ module Calabash
43
51
  end
44
52
  end
45
53
 
46
- # controls printing of deprecation warnings
54
+ # @!visibility private
55
+ # Controls printing of deprecation warnings.
47
56
  #
48
- # to inhibit deprecation message set this to '1'
57
+ # To inhibit deprecation message set this to '1'
49
58
  #
50
- # inhibiting deprecation messages is not recommend
59
+ # Inhibiting deprecation messages is not recommend.
51
60
  CALABASH_NO_DEPRECATION = ENV['CALABASH_NO_DEPRECATION'] || '0'
52
61
 
53
- # returns +true+ if the <tt>CALABASH_NO_DEPRECATION</tt> variable is set
54
- # to +1+
62
+ # @!visibility private
63
+ # Have deprecation warnings been turned off?
64
+ #
65
+ # The return value is controlled but the `CALABASH_NO_DEPRECATION`
66
+ # environment variable.
55
67
  def no_deprecation_warnings?
56
68
  ENV['CALABASH_NO_DEPRECATION'] == '1'
57
69
  end
58
70
 
59
- # prints a deprecated message that includes the line number
71
+ # @!visibility private
72
+ # Prints a deprecated message that includes the line number.
60
73
  #
61
- # if ENV['CALABASH_NO_DEPRECATION'] == '1' then this method is a nop
74
+ # If deprecation warns have been turned off this method does nothing.
62
75
  #
63
76
  # @param [String] version indicates when the feature was deprecated
64
77
  # @param [String] msg deprecation message (possibly suggesting alternatives)
65
78
  # @param [Symbol] type { :warn | :pending } - :pending will raise a
66
79
  # cucumber pending exception
80
+ # @return [void]
67
81
  def _deprecated(version, msg, type)
68
82
  allowed = [:pending, :warn]
69
83
  unless allowed.include?(type)
@@ -5,17 +5,17 @@ module Calabash
5
5
 
6
6
  include Calabash::Cucumber::Logging
7
7
 
8
- # module for reading and writing property list values
8
+ # @!visibility private
9
+ # A module for reading and writing property list values.
9
10
  module PlistBuddy
10
11
 
11
- # reads +key+ from +file+ and returns the result
12
+ # Reads key from file and returns the result.
12
13
  # @param [String] key the key to inspect (may not be nil or empty)
13
14
  # @param [String] file the plist to read
14
15
  # @param [Hash] opts options for controlling execution
15
16
  # @option opts [Boolean] :verbose (false) controls log level
16
- # @return [nil] if +key+ does not exist
17
- # @return [String] if the +key+ exists then the value of +key+ (error)
18
- # @raise [ArgumentError] if nil or empty +key+
17
+ # @return [String] the value of the key
18
+ # @raise [ArgumentError] if nil or empty key
19
19
  def plist_read(key, file, opts={})
20
20
  if key.nil? or key.length == 0
21
21
  raise(ArgumentError, "key '#{key}' must not be nil or empty")
@@ -29,18 +29,17 @@ module Calabash
29
29
  end
30
30
  end
31
31
 
32
- # checks if the key exists in plist
32
+ # Checks if the key exists in plist.
33
33
  # @param [String] key the key to inspect (may not be nil or empty)
34
34
  # @param [String] file the plist to read
35
35
  # @param [Hash] opts options for controlling execution
36
36
  # @option opts [Boolean] :verbose (false) controls log level
37
- # @return [Boolean] true iff the +key+ exists in plist +file+
37
+ # @return [Boolean] true if the key exists in plist file
38
38
  def plist_key_exists?(key, file, opts={})
39
39
  plist_read(key, file, opts) != nil
40
-
41
40
  end
42
41
 
43
- # replaces or creates the +value+ of +key+ in the +file+
42
+ # Replaces or creates the value of key in the file.
44
43
  #
45
44
  # @param [String] key the key to set (may not be nil or empty)
46
45
  # @param [String] type the plist type (used only when adding a value)
@@ -48,8 +47,8 @@ module Calabash
48
47
  # @param [String] file the plist to read
49
48
  # @param [Hash] opts options for controlling execution
50
49
  # @option opts [Boolean] :verbose (false) controls log level
51
- # @return [Boolean] true iff the operation was successful
52
- # @raise [ArgumentError] if nil or empty +key+
50
+ # @return [Boolean] true if the operation was successful
51
+ # @raise [ArgumentError] if nil or empty key
53
52
  def plist_set(key, type, value, file, opts={})
54
53
  default_opts = {:verbose => false}
55
54
  merged = default_opts.merge(opts)
@@ -72,7 +71,7 @@ module Calabash
72
71
  res == ''
73
72
  end
74
73
 
75
- @private
74
+ private
76
75
 
77
76
  # returns the path to the PlistBuddy executable
78
77
  # @return [String] path to PlistBuddy
@@ -80,14 +79,14 @@ module Calabash
80
79
  '/usr/libexec/PlistBuddy'
81
80
  end
82
81
 
83
- # executes +cmd+ as a shell command and returns the result
82
+ # Executes cmd as a shell command and returns the result.
84
83
  #
85
84
  # @param [String] cmd shell command to execute
86
85
  # @param [Hash] opts options for controlling execution
87
86
  # @option opts [Boolean] :verbose (false) controls log level
88
87
  # @return [Boolean] if command was successful
89
- # @return [String] if :print'ing result, the value of the key
90
- # @return [String] if there is an error, the output from stderr
88
+ # @return [String] if :print'ing result, the value of the key - if there
89
+ # is an error, the output from stderr
91
90
  def execute_plist_cmd(cmd, opts={})
92
91
  default_opts = {:verbose => false}
93
92
  merged = default_opts.merge(opts)
@@ -108,7 +107,7 @@ module Calabash
108
107
  res
109
108
  end
110
109
 
111
- # composes a PlistBuddy command that can be executed as a shell command
110
+ # Composes a PlistBuddy command that can be executed as a shell command.
112
111
  #
113
112
  # @param [Symbol] type should be one of [:print, :set, :add]
114
113
  #
@@ -119,9 +118,9 @@ module Calabash
119
118
  #
120
119
  # @param [String] file the plist file to interact with (must exist)
121
120
  #
122
- # @raise [RuntimeError] if +file+ does not exist
123
- # @raise [ArgumentError] when invalid +type+ is passed
124
- # @raise [ArgumentError] when +args_hash+ does not include required key/value pairs
121
+ # @raise [RuntimeError] if file does not exist
122
+ # @raise [ArgumentError] when invalid type is passed
123
+ # @raise [ArgumentError] when args_hash does not include required key/value pairs
125
124
  #
126
125
  # @return [String] a shell-ready PlistBuddy command
127
126
  def build_plist_cmd(type, args_hash, file)
@@ -6,39 +6,42 @@ require 'cfpropertylist'
6
6
  module Calabash
7
7
  module Cucumber
8
8
 
9
- # methods for checking and setting simulator accessibility
9
+ # Public methods for common simulator tasks and private methods for
10
+ # enabling accessibility on the simulator.
10
11
  module SimulatorAccessibility
11
12
 
12
13
  include Calabash::Cucumber::XcodeTools
13
14
  include Calabash::Cucumber::PlistBuddy
14
15
 
15
- # quits the iOS Simulator
16
+ # Quits the iOS Simulator.
16
17
  #
17
18
  # ATM there can only be only simulator open at a time, so simply doing
18
19
  # what the sim_launcher gem does:
19
20
  #
20
- # def quit_simulator
21
- # `echo 'application "iPhone Simulator" quit' | osascript`
22
- # end
21
+ # ```
22
+ # def quit_simulator
23
+ # `echo 'application "iPhone Simulator" quit' | osascript`
24
+ # end
25
+ # ```
23
26
  #
24
27
  # works. I am not sure if we will ever be able to launch more than one
25
28
  # simulator, but in case we can, this method will quit the simulator
26
- # that is indicated by +xcode-select+ or +DEVELOPER_DIR+.
29
+ # that is indicated by `xcode-select` or `DEVELOPER_DIR`.
27
30
  def quit_simulator
28
31
  dev_dir = xcode_developer_dir
29
32
  system "/usr/bin/osascript -e 'tell application \"#{dev_dir}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\" to quit'"
30
33
  end
31
34
 
32
- # launches the iOS Simulator indicated by +xcode-select+ or +DEVELOPER_DIR+
35
+ # Launches the iOS Simulator indicated by `xcode-select` or `DEVELOPER_DIR`.
33
36
  def launch_simulator
34
37
  dev_dir = xcode_developer_dir
35
38
  system "open -a \"#{dev_dir}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\""
36
39
  end
37
40
 
38
- # resets the simulator content and settings. it is analogous to touching
41
+ # Resets the simulator content and settings. It is analogous to touching
39
42
  # the menu item.
40
43
  #
41
- # it works by deleting the following directories:
44
+ # It works by deleting the following directories:
42
45
  #
43
46
  # * ~/Library/Application Support/iPhone Simulator/Library
44
47
  # * ~/Library/Application Support/iPhone Simulator/Library/<sdk>[-64]
@@ -78,10 +81,11 @@ module Calabash
78
81
  end
79
82
  end
80
83
 
81
- # enables accessibility on any existing iOS Simulator by adjusting the
84
+ # @!visibility private
85
+ # Enables accessibility on any existing iOS Simulator by adjusting the
82
86
  # simulator's Library/Preferences/com.apple.Accessibility.plist contents.
83
87
  #
84
- # a simulator 'exists' if has an Application Support directory. for
88
+ # A simulator 'exists' if has an Application Support directory. for
85
89
  # example, the 6.1, 7.0.3-64, and 7.1 simulators exist if the following
86
90
  # directories are present:
87
91
  #
@@ -89,15 +93,15 @@ module Calabash
89
93
  # ~/Library/Application Support/iPhone Simulator/Library/7.0.3-64
90
94
  # ~/Library/Application Support/iPhone Simulator/Library/7.1
91
95
  #
92
- # a simulator is 'possible' if the SDK is available in the Xcode version.
96
+ # A simulator is 'possible' if the SDK is available in the Xcode version.
93
97
  #
94
- # this method merges (uniquely) the possible and existing SDKs.
98
+ # This method merges (uniquely) the possible and existing SDKs.
95
99
  #
96
- # this method also hides the AXInspector.
100
+ # This method also hides the AXInspector.
97
101
  #
98
102
  # @param [Hash] opts controls the behavior of the method
99
103
  # @option opts [Boolean] :verbose controls logging output
100
- # @return [Boolean] true iff enabling accessibility worked on all sdk
104
+ # @return [Boolean] true if enabling accessibility worked on all sdk
101
105
  # directories
102
106
  def enable_accessibility_on_simulators(opts={})
103
107
  possible = possible_simulator_support_sdk_dirs
@@ -111,17 +115,18 @@ module Calabash
111
115
 
112
116
  @private
113
117
 
114
- # enables accessibility on the simulator indicated by
115
- # +sim_app_support_sdk_dir+.
118
+ # @!visibility private
119
+ # Enables accessibility on the simulator indicated by `sim_app_support_sdk_dir.`
116
120
  #
117
- # WARNING: this will quit the simulator
121
+ # @note This will quit the simulator.
118
122
  #
123
+ # @example
119
124
  # path = '/6.1'
120
125
  # enable_accessibility_in_sdk_dir(path)
121
126
  #
122
- # this method also hides the AXInspector.
127
+ # This method also hides the AXInspector.
123
128
  #
124
- # if the Library/Preferences/com.apple.Accessibility.plist does not exist
129
+ # If the Library/Preferences/com.apple.Accessibility.plist does not exist
125
130
  # this method will create a Library/Preferences/com.apple.Accessibility.plist
126
131
  # that (oddly) the Simulator will _not_ overwrite.
127
132
  #
@@ -132,7 +137,7 @@ module Calabash
132
137
  #
133
138
  # @param [Hash] opts controls the behavior of the method
134
139
  # @option opts [Boolean] :verbose controls logging output
135
- # @return [Boolean] iff the plist exists and the plist was successfully
140
+ # @return [Boolean] if the plist exists and the plist was successfully
136
141
  # updated.
137
142
  def enable_accessibility_in_sdk_dir(sim_app_support_sdk_dir, opts={})
138
143
  default_opts = {:verbose => false}
@@ -182,7 +187,8 @@ module Calabash
182
187
  end
183
188
 
184
189
 
185
- # a hash table of the accessibility properties that control whether or not
190
+ # @!visibility private
191
+ # A hash table of the accessibility properties that control whether or not
186
192
  # accessibility is enabled and whether the AXInspector is visible.
187
193
  # @return [Hash] table of accessibility properties found in the
188
194
  # Library/Preferences/com.apple.Accessibility.plist
@@ -220,22 +226,25 @@ module Calabash
220
226
  }
221
227
  end
222
228
 
223
- # the absolute path to the iPhone Simulator Application Support directory
229
+ # @!visibility private
230
+ # The absolute path to the iPhone Simulator Application Support directory.
224
231
  # @return [String] absolute path
225
232
  def simulator_app_support_dir
226
233
  File.expand_path('~/Library/Application Support/iPhone Simulator')
227
234
  end
228
235
 
229
- # the absolute path to the SDK's com.apple.Accessibility.plist file
236
+ # @!visibility private
237
+ # The absolute path to the SDK's com.apple.Accessibility.plist file.
230
238
  # @param [String] sdk_dir base path the SDK directory
231
239
  # @return [String] an absolute path
232
240
  def plist_path_with_sdk_dir(sdk_dir)
233
241
  File.expand_path("#{sdk_dir}/Library/Preferences/com.apple.Accessibility.plist")
234
242
  end
235
243
 
236
- # returns a list of absolute paths the existing simulator directories.
244
+ # @!visibility private
245
+ # Returns a list of absolute paths the existing simulator directories.
237
246
  #
238
- # a simulator 'exists' if has an Application Support directory. for
247
+ # A simulator 'exists' if has an Application Support directory. for
239
248
  # example, the 6.1, 7.0.3-64, and 7.1 simulators exist if the following
240
249
  # directories are present:
241
250
  #
@@ -251,13 +260,14 @@ module Calabash
251
260
  }
252
261
  end
253
262
 
254
- # returns a list of possible SDKs per Xcode version
263
+ # @!visibility private
264
+ # Returns a list of possible SDKs per Xcode version.
255
265
  #
256
- # it is not enough to ask for the available sdks because of the new 64-bit
266
+ # It is not enough to ask for the available sdks because of the new 64-bit
257
267
  # variants that started to appear Xcode 5 and the potential for patch level
258
268
  # versions.
259
269
  #
260
- # unfortunately, this method will need be maintained per Xcode version.
270
+ # Unfortunately, this method will need be maintained per Xcode version.
261
271
  #
262
272
  # @return [Array<String>] ex. ['6.1', '7.1', '7.0.3', '7.0.3-64']
263
273
  def possible_simulator_sdks
@@ -290,7 +300,8 @@ module Calabash
290
300
  (available - ['7.0']).uniq.sort
291
301
  end
292
302
 
293
- # return absolute paths to possible simulator support sdk dirs
303
+ # @!visibility private
304
+ # Return absolute paths to possible simulator support sdk dirs.
294
305
  #
295
306
  # these directories may or may not exist
296
307
  # @return [Array<String>] an array of absolute paths
@@ -3,15 +3,21 @@ require 'open3'
3
3
  module Calabash
4
4
  module Cucumber
5
5
 
6
- # methods for interacting with the xcode tools
6
+ # @!visibility private
7
+ # Methods for interacting with the xcode tools.
7
8
  module XcodeTools
8
9
 
9
- # returns the path to the current developer directory
10
+ # Returns the path to the current developer directory.
10
11
  #
12
+ # From the man pages:
13
+ #
14
+ # ```
11
15
  # $ man xcode-select
12
16
  # 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.
17
+ # Overrides the active developer directory. When DEVELOPER_DIR is set,
18
+ # its value will be used instead of the system-wide active developer
19
+ # directory.
20
+ #```
15
21
  #
16
22
  # @return [String] path to current developer directory
17
23
  def xcode_developer_dir
@@ -21,17 +27,22 @@ module Calabash
21
27
  `xcode-select --print-path`.chomp
22
28
  end
23
29
 
24
- # returns the path to the current developer usr/bin directory
30
+ # Returns the path to the current developer `usr/bin` directory.
25
31
  # @return [String] path to the current xcode binaries
26
32
  def xcode_bin_dir
27
- "#{xcode_developer_dir}/usr/bin"
33
+ File.expand_path("#{xcode_developer_dir}/usr/bin")
28
34
  end
29
35
 
30
- # method for interacting with instruments
36
+ # Method for interacting with instruments.
37
+ #
38
+ # @example Getting the path to instruments.
39
+ # instruments #=> /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
40
+ #
41
+ # @example Getting a the version of instruments.
42
+ # instruments(:version) #=> 5.1.1
31
43
  #
32
- # instruments #=> /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
33
- # instruments(:version) #=> 5.1.1
34
- # instruments(:sims) #=> < list of known simulators >
44
+ # @example Getting list of known simulators.
45
+ # instruments(:sims) #=> < list of known simulators >
35
46
  #
36
47
  # @param [String] cmd controls the return value. currently accepts nil,
37
48
  # :sims, and :version as valid parameters
@@ -58,15 +69,17 @@ module Calabash
58
69
  end
59
70
  end
60
71
 
61
- # does the instruments +version+ accept the -s (devices) flag?
72
+ # Does the instruments `version` accept the -s flag?
62
73
  #
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
74
+ # @example
75
+ # instruments_supports_hyphen_s?('4.6.3') => false
76
+ # instruments_supports_hyphen_s?('5.0.2') => true
77
+ # instruments_supports_hyphen_s?('5.1') => true
66
78
  #
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.*
79
+ # @param [String] version (instruments(:version))
80
+ # a major.minor[.patch] version string
81
+ #
82
+ # @return [Boolean] true if the version is >= 5.*
70
83
  def instruments_supports_hyphen_s?(version=instruments(:version))
71
84
  tokens = version.split('.')
72
85
  return false if tokens[0].to_i < 5
@@ -74,10 +87,7 @@ module Calabash
74
87
  true
75
88
  end
76
89
 
77
- # returns a list of installed simulators by calling:
78
- #
79
- # $ instruments -s devices
80
- #
90
+ # Returns a list of installed simulators by calling `$ instruments -s devices`.
81
91
  # and parsing the output
82
92
  # @return [Array<String>] an array of simulator names suitable for passing
83
93
  # to instruments or xcodebuild