calabash 1.9.9.pre3 → 2.0.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -0
  3. data/bin/calabash +45 -36
  4. data/lib/calabash/android/build/builder.rb +1 -1
  5. data/lib/calabash/android/build/resigner.rb +19 -1
  6. data/lib/calabash/android/device.rb +13 -2
  7. data/lib/calabash/android/interactions.rb +104 -3
  8. data/lib/calabash/android/lib/TestServer.apk +0 -0
  9. data/lib/calabash/android/life_cycle.rb +5 -4
  10. data/lib/calabash/android/physical_buttons.rb +4 -1
  11. data/lib/calabash/android/scroll.rb +5 -0
  12. data/lib/calabash/android/text.rb +10 -25
  13. data/lib/calabash/android.rb +3 -0
  14. data/lib/calabash/cli/generate.rb +2 -0
  15. data/lib/calabash/console_helpers.rb +4 -2
  16. data/lib/calabash/device.rb +1 -9
  17. data/lib/calabash/environment.rb +4 -0
  18. data/lib/calabash/gestures.rb +159 -66
  19. data/lib/calabash/http/retriable_client.rb +1 -1
  20. data/lib/calabash/interactions.rb +67 -5
  21. data/lib/calabash/ios/conditions.rb +0 -1
  22. data/lib/calabash/ios/device/device_implementation.rb +17 -5
  23. data/lib/calabash/ios/device/gestures_mixin.rb +202 -48
  24. data/lib/calabash/ios/device/rotation_mixin.rb +10 -8
  25. data/lib/calabash/ios/device/routes/handle_route_mixin.rb +5 -1
  26. data/lib/calabash/ios/device/runtime_attributes.rb +4 -5
  27. data/lib/calabash/ios/gestures.rb +82 -8
  28. data/lib/calabash/ios/orientation.rb +21 -21
  29. data/lib/calabash/ios/runtime.rb +146 -2
  30. data/lib/calabash/ios/slider.rb +70 -0
  31. data/lib/calabash/ios/text.rb +6 -2
  32. data/lib/calabash/ios/uia.rb +24 -2
  33. data/lib/calabash/ios.rb +2 -0
  34. data/lib/calabash/lib/skeleton/features/support/dry_run.rb +8 -0
  35. data/lib/calabash/life_cycle.rb +59 -30
  36. data/lib/calabash/location.rb +0 -1
  37. data/lib/calabash/orientation.rb +0 -1
  38. data/lib/calabash/page.rb +38 -5
  39. data/lib/calabash/patch/array.rb +7 -7
  40. data/lib/calabash/query.rb +17 -2
  41. data/lib/calabash/query_result.rb +10 -0
  42. data/lib/calabash/screenshot.rb +28 -8
  43. data/lib/calabash/text.rb +52 -8
  44. data/lib/calabash/utility.rb +3 -3
  45. data/lib/calabash/version.rb +1 -1
  46. data/lib/calabash/wait.rb +33 -11
  47. data/lib/calabash.rb +124 -13
  48. metadata +114 -111
@@ -1,16 +1,160 @@
1
1
  module Calabash
2
2
  module IOS
3
- # @!visibility private
3
+
4
+ # Methods that describe the runtime attributes of the device under test.
5
+ #
6
+ # @note The key/value pairs in the Hash returned by #runtime_details are
7
+ # not stable and can change at any time. Don't write tests that rely on
8
+ # specific keys or values in this Hash. Instead, use the API methods
9
+ # defined in this class.
4
10
  module Runtime
5
11
 
6
- # @todo Complete and document the Runtime API
12
+ # Is the device under test a simulator?
7
13
  def simulator?
8
14
  Calabash::IOS::Device.default.simulator?
9
15
  end
10
16
 
17
+ # Is the device under test a physical device?
11
18
  def physical_device?
12
19
  Calabash::IOS::Device.default.physical_device?
13
20
  end
21
+
22
+ # Is the device under test an iPad?
23
+ def ipad?
24
+ Calabash::IOS::Device.default.device_family == 'iPad'
25
+ end
26
+
27
+ # Is the device under test an iPhone?
28
+ def iphone?
29
+ Calabash::IOS::Device.default.device_family == 'iPhone'
30
+ end
31
+
32
+ # Is the device under test an iPod?
33
+ def ipod?
34
+ Calabash::IOS::Device.default.device_family == 'iPod'
35
+ end
36
+
37
+ # Is the device under test an iPhone or iPod?
38
+ def device_family_iphone?
39
+ iphone? or ipod?
40
+ end
41
+
42
+ # Is the app that is being tested an iPhone app emulated on an iPad?
43
+ #
44
+ # An iPhone only app running on an iPad will be displayed in an emulated
45
+ # mode. Starting in iOS 7, such apps will always be launched in 2x mode.
46
+ def iphone_app_emulated_on_ipad?
47
+ Calabash::IOS::Device.default.iphone_app_emulated_on_ipad?
48
+ end
49
+
50
+ # Is the device under test have a 4 inch screen?
51
+ def iphone_4in?
52
+ Calabash::IOS::Device.default.form_factor == 'iphone 4in'
53
+ end
54
+
55
+ # Is the device under test an iPhone 6.
56
+ def iphone_6?
57
+ Calabash::IOS::Device.default.form_factor == 'iphone 6'
58
+ end
59
+
60
+ # Is the device under test an iPhone 6+?
61
+ def iphone_6_plus?
62
+ Calabash::IOS::Device.default.form_factor == 'iphone 6 +'
63
+ end
64
+
65
+ # Is the device under test an iPhone 3.5in?
66
+ def iphone_35in?
67
+ Calabash::IOS::Device.default.form_factor == 'iphone 3.5in'
68
+ end
69
+
70
+ # The screen dimensions and details about scale and sample rates.
71
+ #
72
+ # @example
73
+ # > app_screen_details
74
+ # => {
75
+ # :height => 1,
76
+ # :height => 1334,
77
+ # :width => 750,
78
+ # :scale => 2
79
+ # }
80
+ #
81
+ # @return [Hash] See the example.
82
+ def app_screen_details
83
+ Calabash::IOS::Device.default.screen_dimensions
84
+ end
85
+
86
+ # The version of iOS running on the test device.
87
+ #
88
+ # @example
89
+ # > ios_version.major
90
+ # > ios_version.minor
91
+ # > ios_version.patch
92
+ #
93
+ # @return [RunLoop::Version] A version object.
94
+ def ios_version
95
+ Calabash::IOS::Device.default.ios_version
96
+ end
97
+
98
+ # Is the device under test running iOS 6?
99
+ def ios6?
100
+ ios_version.major == 6
101
+ end
102
+
103
+ # Is the device under test running iOS 7?
104
+ def ios7?
105
+ ios_version.major == 7
106
+ end
107
+
108
+ # Is the device under test running iOS 8?
109
+ def ios8?
110
+ ios_version.major == 8
111
+ end
112
+
113
+ # Is the device under test running iOS 9?
114
+ def ios9?
115
+ ios_version.major == 9
116
+ end
117
+
118
+ # The version of the Calabash iOS Server running in the app.
119
+ #
120
+ # @example
121
+ # > server_version.major
122
+ # > server_version.minor
123
+ # > server_version.patch
124
+ #
125
+ # @return [RunLoop::Version] A version object.
126
+ def server_version
127
+ Calabash::IOS::Device.default.server_version
128
+ end
129
+
130
+ # Details about the version of the app under test.
131
+ #
132
+ # Will always contain these two keys:
133
+ #
134
+ # * :bundle_version => CFBundleVersion
135
+ # * :short_version => CFBundleShortVersionString
136
+ #
137
+ # It may contain other key/value pairs.
138
+ #
139
+ # @return [Hash] Key/value pairs that describe the version of the app
140
+ # under test.
141
+ def app_version_details
142
+ hash = runtime_details
143
+ {
144
+ :bundle_version => hash['app_version'],
145
+ :short_version => hash['short_version_string']
146
+ }
147
+ end
148
+
149
+ # A hash of all the details about the runtime environment.
150
+ #
151
+ # @note The key/value pairs in this Hash are subject to change. Don't
152
+ # write tests that rely on a specific key appearing in the Hash. Use
153
+ # the methods in the {Calabash::IOS::Runtime} module instead.
154
+ # @return[Hash] Key/value pairs that describe the runtime environment.
155
+ def runtime_details
156
+ Calabash::IOS::Device.default.runtime_details
157
+ end
14
158
  end
15
159
  end
16
160
  end
@@ -0,0 +1,70 @@
1
+ module Calabash
2
+ module IOS
3
+
4
+ # An interface for interacting with UISliders.
5
+ module Slider
6
+
7
+ # Sets the value of the first UISliders matched by `query` to `value`.
8
+ #
9
+ # If `query` matches a view that is not a UISlider or UISlider subclass,
10
+ # an error will be raised.
11
+ #
12
+ # An error will be raised if more than on view is matched by `query`.
13
+ #
14
+ # To avoid matching more than one UISlider (or subclass):
15
+ # * Make the query more specific: "UISlider marked:'volume'"
16
+ # * Use the index language feature: "UISlider index:0"
17
+ #
18
+ # @example
19
+ # slider_set_value("UISlider marked:'office slider'", 2)
20
+ # slider_set_value("slider marked:'weather slider'", -1)
21
+ # slider_set_value("UISlider", 11)
22
+ #
23
+ # @param [String, Hash, Calabash::Query] query A query to that indicates
24
+ # in which slider to set the value.
25
+ # @param [Numeric] value The value to set the slider to. value.to_s should
26
+ # produce a String representation of a Number.
27
+ #
28
+ # @param [options] options Options to control the behavior of the gesture.
29
+ # @option options [Boolean] :animate (true) Animate the change.
30
+ # @option options [Boolean] :notify_targets (true) Simulate a UIEvent by
31
+ # calling every target/action pair defined on the UISlider matching
32
+ # `query`.
33
+ #
34
+ # @raise [RuntimeError] When `query` does not match exactly one slider.
35
+ # @raise [RuntimeError] When setting the value of the slider matched by
36
+ # `query` is not successful.
37
+ def slider_set_value(query, value, options={})
38
+ Query.ensure_valid_query(query)
39
+
40
+ default_options = {
41
+ :animate => true,
42
+ :notify_targets => true
43
+ }
44
+
45
+ merged_options = default_options.merge(options)
46
+
47
+ found_none = "Expected '#{query}' to match exactly one view, but found no matches."
48
+ query_object = Query.new(query)
49
+ wait_for(found_none) do
50
+ results = query(query_object)
51
+ if results.length > 1
52
+ message = [
53
+ "Expected '#{query}' to match exactly one view, but found '#{results.length}'",
54
+ results.join("\n")
55
+ ].join("\n")
56
+ fail(message)
57
+ else
58
+ results.length == 1
59
+ end
60
+ end
61
+
62
+ value_str = value.to_s
63
+
64
+ args = [merged_options[:animate], merged_options[:notify_targets]]
65
+
66
+ Device.default.map_route(query, :changeSlider, value_str, *args)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,7 +1,6 @@
1
1
  module Calabash
2
2
  module IOS
3
3
  # Methods for entering text and interacting with iOS keyboards.
4
- # @!visibility private
5
4
  module Text
6
5
  # @!visibility private
7
6
  def _enter_text(text)
@@ -128,7 +127,12 @@ module Calabash
128
127
  # @todo Refactor uia_route to a public API call
129
128
  # @todo Move this documentation to the public method
130
129
  # @!visibility private
131
- def _tap_current_keyboard_action_key
130
+ def _tap_keyboard_action_key(action_key)
131
+ unless action_key.nil?
132
+ raise ArgumentError,
133
+ "An iOS keyboard does not have multiple action keys"
134
+ end
135
+
132
136
  char_sequence = ESCAPED_KEYBOARD_CHARACTERS[:action]
133
137
  Device.default.uia_route("uia.keyboard().typeString('#{char_sequence}')")
134
138
  end
@@ -1,22 +1,44 @@
1
1
  module Calabash
2
2
  module IOS
3
- # @!visibility private
3
+
4
+ # Methods for interacting directly with Apple's UIAutomation API.
5
+ #
6
+ # https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html
7
+ # https://developer.apple.com/library/ios/documentation/DeveloperTools/Reference/UIAutomationRef/
8
+ #
9
+ # Calabash iOS uses this API to perform gestures. It is sometimes helpful
10
+ # to drop down into this API to explore your app.
4
11
  module UIA
5
12
 
6
- # Evaluates `script` with Apple's UIAutomation API.
13
+ # Evaluates `script` using Apples's UIAutomation API.
7
14
  #
15
+ # @example
16
+ # uia("UIATarget.localTarget().shake()")
17
+ # uia("UIATarget.localTarget().frontMostApp().keyboard().buttons()['Delete']")
18
+ # uia("UIATarget.localTarget().frontMostApp().mainWindow().elements()")
8
19
  def uia(script)
9
20
  Device.default.evaluate_uia(script)
10
21
  end
11
22
 
23
+ # Evaluates `script` after prefixing with "UIATarget.localTarget()"
24
+ #
25
+ # @example
26
+ # uia_with_target("shake()")
12
27
  def uia_with_target(script)
13
28
  uia("UIATarget.localTarget().#{script}")
14
29
  end
15
30
 
31
+ # Evaluates `script` after prefixing with
32
+ # "UIATarget.localTarget().frontMostApp()"
33
+ #
34
+ # @example
35
+ # uia_with_app("keyboard().buttons()['Delete'])
16
36
  def uia_with_app(script)
17
37
  uia("UIATarget.localTarget().frontMostApp().#{script}")
18
38
  end
19
39
 
40
+ # Evaluates `script` after prefixing with
41
+ # "UIATarget.localTarget().frontMostApp().mainWindow()"
20
42
  def uia_with_main_window(script)
21
43
  uia("UIATarget.localTarget().frontMostApp().mainWindow().#{script}")
22
44
  end
data/lib/calabash/ios.rb CHANGED
@@ -30,6 +30,7 @@ module Calabash
30
30
  require 'calabash/ios/scroll'
31
31
  require 'calabash/ios/runtime'
32
32
  require 'calabash/ios/gestures'
33
+ require 'calabash/ios/slider'
33
34
 
34
35
  include Calabash::IOS::Conditions
35
36
  include Calabash::IOS::Orientation
@@ -39,6 +40,7 @@ module Calabash
39
40
  include Calabash::IOS::Scroll
40
41
  include Calabash::IOS::Runtime
41
42
  include Calabash::IOS::Gestures
43
+ include Calabash::IOS::Slider
42
44
 
43
45
  end
44
46
  end
@@ -0,0 +1,8 @@
1
+ # Cucumber does not load env.rb when running a dry-run. As the pages inherit
2
+ # from Calabash::Page and assert that the scopes IOS and Android are defined,
3
+ # we should require calabash.
4
+
5
+ if ARGV.include?('--dry-run')
6
+ require 'calabash/android'
7
+ require 'calabash/ios'
8
+ end
@@ -1,58 +1,85 @@
1
1
  module Calabash
2
- # @!visibility private
3
2
  module LifeCycle
4
- def start_app(path_or_application = nil, **opt)
5
- path_or_application ||= Application.default
3
+ # Start the given application (and its test-server) on the port of
4
+ # {Calabash::Defaults#default_server Calabash.default_server}.
5
+ # This method will **not** install the application specified. If no
6
+ # application is given, it will start
7
+ # {Calabash::Defaults#default_application Calabash.default_application}
8
+ #
9
+ # @note This method will fail if the application (and test-server for
10
+ # Android) is not installed, or if the application installed is not the
11
+ # same as the one specified.
12
+ #
13
+ # @note On Android, if a test-server is already running on the port of
14
+ # {Calabash::Defaults#default_server Calabash.default_server} then that
15
+ # application will be shut down.
16
+ #
17
+ # @param [String, Calabash::Application] path_or_application A path to the
18
+ # application, or an instance of {Calabash::Application}.
19
+ # Defaults to
20
+ # {Calabash::Defaults#default_application Calabash.default_application}
21
+ # @param [Hash] options Options for specifying the details the app start
22
+ # @option options [Hash] :activity Android-only. Specify which activity
23
+ # to start. If none is given, launch the default launchable activity.
24
+ # @option options [Hash] :extras Android-only. Specify the extras for the
25
+ # startup intent.
26
+ def start_app(path_or_application = nil, **options)
27
+ path_or_application ||= Calabash.default_application
6
28
 
7
29
  unless path_or_application
8
- raise 'No application given, and Application.default is not set'
30
+ raise 'No application given, and Calabash.default_application is not set'
9
31
  end
10
32
 
11
- Device.default.start_app(path_or_application, opt.dup)
33
+ Device.default.start_app(path_or_application, options.dup)
12
34
  end
13
35
 
36
+ # Stop the app running on
37
+ # {Calabash::Defaults#default_server Calabash.default_server}
14
38
  def stop_app
15
39
  Device.default.stop_app
16
40
  end
17
41
 
18
42
  # Installs the given application. If the application is already installed,
19
43
  # the application will be uninstalled, and installed afterwards. If no
20
- # application is given, it will install `Application.default`.
44
+ # application is given, it will install
45
+ # {Calabash::Defaults#default_application Calabash.default_application}
21
46
  #
22
47
  # If the given application is an instance of
23
- # `Calabash::Android::Application`, the same procedure is executed for the
48
+ # {Calabash::Android::Application}, the same procedure is executed for the
24
49
  # test-server of the application, if it is set.
25
50
  #
26
51
  # @param [String, Calabash::Application] path_or_application A path to the
27
- # application, or an instance of `Calabash::Application`. Defaults to
28
- # `Application.default`
52
+ # application, or an instance of {Calabash::Application}.
53
+ # Defaults to
54
+ # {Calabash::Defaults#default_application Calabash.default_application}
29
55
  def install_app(path_or_application = nil)
30
- path_or_application ||= Application.default
56
+ path_or_application ||= Calabash.default_application
31
57
 
32
58
  unless path_or_application
33
- raise 'No application given, and Application.default is not set'
59
+ raise 'No application given, and Calabash.default_application is not set'
34
60
  end
35
61
 
36
62
  Device.default.install_app(path_or_application)
37
63
  end
38
64
 
39
65
  # Installs the given application *if it is not already installed*. If no
40
- # application is given, it will ensure `Application.default` is installed.
66
+ # application is given, it will ensure `Calabash.default_application` is installed.
41
67
  # If the application has changed, it will be installed using the same
42
- # approach as #{Calabash::LifeCycle#install_app}.
68
+ # approach as {#install_app}.
43
69
  #
44
70
  # If the given application is an instance of
45
- # `Calabash::Android::Application`, the same procedure is executed for the
71
+ # {Calabash::Android::Application}, the same procedure is executed for the
46
72
  # test-server of the application, if it is set.
47
73
  #
48
74
  # @param [String, Calabash::Application] path_or_application A path to the
49
- # application, or an instance of `Calabash::Application`. Defaults to
50
- # `Application.default`
75
+ # application, or an instance of {Calabash::Application}.
76
+ # Defaults to
77
+ # {Calabash::Defaults#default_application Calabash.default_application}
51
78
  def ensure_app_installed(path_or_application = nil)
52
- path_or_application ||= Application.default
79
+ path_or_application ||= Calabash.default_application
53
80
 
54
81
  unless path_or_application
55
- raise 'No application given, and Application.default is not set'
82
+ raise 'No application given, and Calabash.default_application is not set'
56
83
  end
57
84
 
58
85
  Device.default.ensure_app_installed(path_or_application)
@@ -60,16 +87,17 @@ module Calabash
60
87
 
61
88
  # Uninstalls the given application. Does nothing if the application is
62
89
  # already uninstalled. If no application is given, it will uninstall
63
- # `Application.default`.
90
+ # {Calabash::Defaults#default_application Calabash.default_application}
64
91
  #
65
92
  # @param [String, Calabash::Application] path_or_application A path to the
66
- # application, or an instance of `Calabash::Application`. Defaults to
67
- # `Application.default`
93
+ # application, or an instance of {Calabash::Application}.
94
+ # Defaults to
95
+ # {Calabash::Defaults#default_application Calabash.default_application}
68
96
  def uninstall_app(path_or_application = nil)
69
- path_or_application ||= Application.default
97
+ path_or_application ||= Calabash.default_application
70
98
 
71
99
  unless path_or_application
72
- raise 'No application given, and Application.default is not set'
100
+ raise 'No application given, and Calabash.default_application is not set'
73
101
  end
74
102
 
75
103
  Device.default.uninstall_app(path_or_application)
@@ -77,16 +105,17 @@ module Calabash
77
105
 
78
106
  # Clears the contents of the given application. This is roughly equivalent to
79
107
  # reinstalling the application. If no application is given, it will clear
80
- # `Application.default`.
108
+ # {Calabash::Defaults#default_application Calabash.default_application}.
81
109
  #
82
110
  # @param [String, Calabash::Application] path_or_application A path to the
83
- # application, or an instance of `Calabash::Application`. Defaults to
84
- # `Application.default`
111
+ # application, or an instance of {Calabash::Application}.
112
+ # Defaults to
113
+ # {Calabash::Defaults#default_application Calabash.default_application}
85
114
  def clear_app_data(path_or_application = nil)
86
- path_or_application ||= Application.default
115
+ path_or_application ||= Calabash.default_application
87
116
 
88
117
  unless path_or_application
89
- raise 'No application given, and Application.default is not set'
118
+ raise 'No application given, and Calabash.default_application is not set'
90
119
  end
91
120
 
92
121
  Device.default.clear_app_data(path_or_application)
@@ -96,8 +125,8 @@ module Calabash
96
125
  # `for_seconds`. This should not exceed 60 seconds for iOS.
97
126
  #
98
127
  # On Android you can control the app lifecycle more granularly using
99
- # #{Calabash::Android::Interactions#go_home} and
100
- # #{Calabash::Android::LifeCycle#resume_app}.
128
+ # {Calabash::Android::Interactions#go_home \#go_home} and
129
+ # {Calabash::Android::LifeCycle#resume_app \#resume_app}.
101
130
  def send_current_app_to_background(for_seconds = 10)
102
131
  _send_current_app_to_background(for_seconds)
103
132
 
@@ -1,7 +1,6 @@
1
1
  require 'geocoder'
2
2
 
3
3
  module Calabash
4
- # @!visibility private
5
4
  module Location
6
5
  # Simulates gps location of the device/simulator.
7
6
  # @note Seems UIAutomation is broken here on physical devices on iOS 7.1
@@ -2,7 +2,6 @@ module Calabash
2
2
 
3
3
  # Methods for querying an app's orientation and for rotating the app into
4
4
  # different orientations.
5
- # @!visibility private
6
5
  module Orientation
7
6
  # Is the device in the portrait orientation?
8
7
  #
data/lib/calabash/page.rb CHANGED
@@ -5,12 +5,45 @@ module Calabash
5
5
 
6
6
  def self.inherited(subclass)
7
7
  # Define the page into global scope
8
- name = subclass.to_s.split('::').last
8
+ full_name = subclass.name
9
9
 
10
- unless Object.const_defined?(name.to_sym)
11
- # We need a unique type for this constant
12
- clz = Class.new(StubPage)
13
- Object.const_set(name.to_sym, clz)
10
+ if full_name == 'IOS' || full_name == 'Android'
11
+ raise "Invalid page name '#{full_name}'"
12
+ end
13
+
14
+ os_scope = full_name.split('::').first
15
+
16
+ if os_scope == 'IOS' || os_scope == 'Android'
17
+ page_name = full_name.split('::', 2).last
18
+
19
+ unless Calabash.is_defined?(page_name)
20
+ scopes = page_name.split('::')
21
+
22
+ previous_scope = ''
23
+
24
+ scopes[0..-2].each do |scope|
25
+ old_scope = Calabash.recursive_const_get("Object::#{os_scope}#{previous_scope}")
26
+ new_scope = Calabash.recursive_const_get("Object#{previous_scope}")
27
+
28
+ old_const = old_scope.const_get(scope.to_sym)
29
+
30
+ if new_scope.const_defined?(scope.to_sym)
31
+ new_scope.send(:remove_const, scope.to_sym)
32
+ end
33
+
34
+ new_scope.const_set(scope.to_sym, old_const.class.allocate)
35
+
36
+ previous_scope << "::#{scope}"
37
+ end
38
+
39
+ simple_page_name = page_name.split('::').last.to_sym
40
+ new_scope = Calabash.recursive_const_get("Object#{previous_scope}")
41
+
42
+ unless new_scope.const_defined?(simple_page_name, false)
43
+ clz = Class.new(StubPage)
44
+ new_scope.const_set(simple_page_name, clz)
45
+ end
46
+ end
14
47
  end
15
48
  end
16
49
 
@@ -4,13 +4,13 @@ module Calabash
4
4
 
5
5
  # @!visibility private
6
6
  module Array
7
- def to_pct
8
- if length != 2
9
- raise RangeError, "Cannot convert #{self} to {:x, :y} hash"
10
- end
11
-
12
- {x: self.[](0), y: self.[](1)}
13
- end
7
+ # def to_pct
8
+ # if length != 2
9
+ # raise RangeError, "Cannot convert #{self} to {:x, :y} hash"
10
+ # end
11
+ #
12
+ # {x: self.[](0), y: self.[](1)}
13
+ # end
14
14
  end
15
15
  end
16
16
  end
@@ -1,8 +1,6 @@
1
1
  module Calabash
2
2
 
3
3
  # A representation of a Calabash query.
4
- # @todo Query needs more documentation.
5
- # @todo Query needs some methods moved to private or doc'd private.
6
4
  class Query
7
5
  # @!visibility private
8
6
  def self.web_query?(query_string)
@@ -110,6 +108,13 @@ module Calabash
110
108
  result
111
109
  end
112
110
 
111
+ # Create a new query. The returned instance will be frozen (immutable).
112
+ #
113
+ # @example
114
+ # Calabash::Query.new({marked: 'mark'})
115
+ # Calabash::Query.new("myview")
116
+ #
117
+ # @param [String, Hash, Calabash::Query] query The query to create
113
118
  def initialize(query)
114
119
  unless query.is_a?(Query) || query.is_a?(Hash) || query.is_a?(String)
115
120
  raise ArgumentError, "Invalid argument for query: '#{query}' (#{query.class})"
@@ -120,6 +125,13 @@ module Calabash
120
125
  freeze
121
126
  end
122
127
 
128
+ # Parse the query to it's string representation.
129
+ #
130
+ # @example
131
+ # puts Calabash::Query.new({marked: 'foo'})
132
+ # # => "* marked:'foo'"
133
+ #
134
+ # @!visibility private
123
135
  def to_s
124
136
  if @query.is_a?(Query)
125
137
  @query.to_s
@@ -130,14 +142,17 @@ module Calabash
130
142
  end
131
143
  end
132
144
 
145
+ # @!visibility private
133
146
  def inspect
134
147
  "<Calabash::Query #{@query.inspect}>"
135
148
  end
136
149
 
150
+ # @!visibility private
137
151
  def web_query?
138
152
  Query.web_query?(to_s)
139
153
  end
140
154
 
155
+ # @!visibility private
141
156
  WEB_QUERY_INDICATORS =
142
157
  [
143
158
  {