Module: Calabash::Cucumber::EnvironmentHelpers
- Included in:
- Core, IOS7Operations
- Defined in:
- lib/calabash-cucumber/environment_helpers.rb
Instance Method Summary collapse
-
#_deprecated(version, msg, type) ⇒ Object
prints a deprecated message that includes the line number
version
string indicating when the feature was deprecatedmsg
deprecation message (possibly suggesting alternatives)type
{ :warn | :pending }
-:pending
will raise a cucumber pending exception. -
#debug_logging? ⇒ Boolean
returns
true
if theDEBUG
is set to1
. -
#default_device ⇒ Object
returns the default Device.
-
#device_family_iphone? ⇒ Boolean
returns
true
if the target device is an iphone or ipod. -
#full_console_logging? ⇒ Boolean
returns
true
if theCALABASH_FULL_CONSOLE_OUTPUT
is set to1
. -
#ios5? ⇒ Boolean
returns
true
if the OS major version is 5. -
#ios6? ⇒ Boolean
returns
true
if the OS major version is 6. -
#ios7? ⇒ Boolean
returns
true
if the OS major version is 7. -
#ipad? ⇒ Boolean
returns
true
if the target device is an ipad. -
#iphone? ⇒ Boolean
returns
true
if the target device is an iphone. -
#iphone_4in? ⇒ Boolean
returns
true
if the target device or simulator is a 4in model. -
#iphone_5? ⇒ Boolean
returns
true
if the target device or simulator is a 4in model. -
#iphone_app_emulated_on_ipad? ⇒ Boolean
returns
true
if the app is an iphone app emulated on an ipad. -
#ipod? ⇒ Boolean
returns
true
if the target device is an ipod. -
#no_deprecation_warnings? ⇒ Boolean
returns
true
if theCALABASH_NO_DEPRECATION
variable is set to1
. -
#simulator? ⇒ Boolean
returns
true
if the target device is a simulator (not a physical device). -
#uia_available? ⇒ Boolean
returns
true
if UIAutomation functions are available. -
#uia_not_available? ⇒ Boolean
returns
true
if UIAutomation functions are not available. -
#xamarin_test_cloud? ⇒ Boolean
returns
true
if cucumber is running in the test cloud.
Instance Method Details
#_deprecated(version, msg, type) ⇒ Object
prints a deprecated message that includes the line number
+version+ string indicating when the feature was deprecated
+msg+ deprecation message (possibly suggesting alternatives)
+type+ <tt>{ :warn | :pending }</tt> - <tt>:pending</tt> will raise a
cucumber pending exception
if ENV == ‘1’ then this method is a nop
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 149 def _deprecated(version, msg, type) allowed = [:pending, :warn] unless allowed.include?(type) screenshot_and_raise "type '#{type}' must be on of '#{allowed}'" end unless no_deprecation_warnings? stack = Kernel.caller(0, 6)[1..-1].join("\n") msg = "deprecated '#{version}' - '#{msg}'\n#{stack}" if type.eql?(:pending) pending(msg) else # todo deprecated function does not output on a new line when called within cucumber begin warn "\033[34m\nWARN: #{msg}\033[0m" rescue warn "\nWARN: #{msg}" end end end end |
#debug_logging? ⇒ Boolean
returns true
if the DEBUG
is set to 1
136 137 138 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 136 def debug_logging? ENV['DEBUG'] == '1' end |
#default_device ⇒ Object
returns the default Device
31 32 33 34 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 31 def default_device l = Calabash::Cucumber::Launcher.launcher_if_used l && l.device end |
#device_family_iphone? ⇒ Boolean
returns true
if the target device is an iphone or ipod
raises an error if the server cannot be reached
60 61 62 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 60 def device_family_iphone? iphone? or ipod? end |
#full_console_logging? ⇒ Boolean
returns true
if the CALABASH_FULL_CONSOLE_OUTPUT
is set to 1
131 132 133 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 131 def full_console_logging? ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' end |
#ios5? ⇒ Boolean
returns true
if the OS major version is 5
raises an error if the server cannot be reached
WARNING: setting the OS
env variable will override the value returned
by the device
91 92 93 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 91 def ios5? _OS_ENV.eql?(_canonical_os_version(:ios5)) || _default_device_or_create().ios5? end |
#ios6? ⇒ Boolean
returns true
if the OS major version is 6
raises an error if the server cannot be reached
WARNING: setting the OS
env variable will override the value returned
by the device
101 102 103 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 101 def ios6? _OS_ENV.eql?(_canonical_os_version(:ios6)) || _default_device_or_create().ios6? end |
#ios7? ⇒ Boolean
returns true
if the OS major version is 7
raises an error if the server cannot be reached
WARNING: setting the OS
env variable will override the value returned
by the device
112 113 114 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 112 def ios7? _OS_ENV.eql?(_canonical_os_version(:ios7)) || _default_device_or_create().ios7? end |
#ipad? ⇒ Boolean
returns true
if the target device is an ipad
raises an error if the server cannot be reached
39 40 41 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 39 def ipad? _default_device_or_create().ipad? end |
#iphone? ⇒ Boolean
returns true
if the target device is an iphone
raises an error if the server cannot be reached
46 47 48 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 46 def iphone? _default_device_or_create().iphone? end |
#iphone_4in? ⇒ Boolean
returns true
if the target device or simulator is a 4in model
raises an error if the server cannot be reached
81 82 83 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 81 def iphone_4in? iphone_5? end |
#iphone_5? ⇒ Boolean
returns true
if the target device or simulator is a 4in model
raises an error if the server cannot be reached
74 75 76 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 74 def iphone_5? _default_device_or_create().iphone_5? end |
#iphone_app_emulated_on_ipad? ⇒ Boolean
returns true
if the app is an iphone app emulated on an ipad
raises an error if the server cannot be reached
119 120 121 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 119 def iphone_app_emulated_on_ipad? _default_device_or_create().iphone_app_emulated_on_ipad? end |
#ipod? ⇒ Boolean
returns true
if the target device is an ipod
raises an error if the server cannot be reached
53 54 55 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 53 def ipod? _default_device_or_create().ipod? end |
#no_deprecation_warnings? ⇒ Boolean
returns true
if the CALABASH_NO_DEPRECATION
variable is set to 1
125 126 127 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 125 def no_deprecation_warnings? ENV['CALABASH_NO_DEPRECATION'] == '1' end |
#simulator? ⇒ Boolean
returns true
if the target device is a simulator (not a physical device)
raises an error if the server cannot be reached
67 68 69 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 67 def simulator? _default_device_or_create().simulator? end |
#uia_available? ⇒ Boolean
returns true
if UIAutomation functions are available
UIAutomation is only available if the app has been launched with Instruments
13 14 15 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 13 def uia_available? Calabash::Cucumber::Launcher.instruments? end |
#uia_not_available? ⇒ Boolean
returns true
if UIAutomation functions are not available
UIAutomation is only available if the app has been launched with Instruments
21 22 23 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 21 def uia_not_available? not uia_available? end |
#xamarin_test_cloud? ⇒ Boolean
returns true
if cucumber is running in the test cloud
26 27 28 |
# File 'lib/calabash-cucumber/environment_helpers.rb', line 26 def xamarin_test_cloud? ENV['XAMARIN_TEST_CLOUD'] == '1' end |