Module: Calabash::Cucumber::EnvironmentHelpers

Included in:
Core
Defined in:
lib/calabash-cucumber/environment_helpers.rb

Overview

Note:

The OS environmental variable has been deprecated. It should never be set.

Methods to expose the runtime environment and details about the device under test.

Instance Method Summary collapse

Instance Method Details

#default_deviceCalabash::Cucumber::Device

Returns the default Device that is connected the current launcher.

Returns:



48
49
50
51
52
# File 'lib/calabash-cucumber/environment_helpers.rb', line 48

def default_device
  require "calabash-cucumber/launcher"
  l = Calabash::Cucumber::Launcher.launcher_if_used
  l && l.device
end

#device_family_iphone?Boolean

Is the device under test an iPhone or iPod?

Returns:

  • (Boolean)

    true If device under test is an iPhone or iPod.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



90
91
92
# File 'lib/calabash-cucumber/environment_helpers.rb', line 90

def device_family_iphone?
  iphone? or ipod?
end

#ios10?Boolean

Is the device under test running iOS 10?

Returns:

  • (Boolean)

    true if device under test is running iOS 9

Raises:

  • (RuntimeError)

    if the server cannot be reached



199
200
201
# File 'lib/calabash-cucumber/environment_helpers.rb', line 199

def ios10?
 _default_device_or_create.ios10?
end

#ios5?Boolean

Is the device under test running iOS 5?

Returns:

  • (Boolean)

    true if device under test is running iOS 5

Raises:

  • (RuntimeError)

    if the server cannot be reached



159
160
161
# File 'lib/calabash-cucumber/environment_helpers.rb', line 159

def ios5?
   _default_device_or_create.ios5?
end

#ios6?Boolean

Is the device under test running iOS 6?

Returns:

  • (Boolean)

    true if device under test is running iOS 6

Raises:

  • (RuntimeError)

    if the server cannot be reached



167
168
169
# File 'lib/calabash-cucumber/environment_helpers.rb', line 167

def ios6?
  _default_device_or_create.ios6?
end

#ios7?Boolean

Is the device under test running iOS 7?

Returns:

  • (Boolean)

    true if device under test is running iOS 7

Raises:

  • (RuntimeError)

    if the server cannot be reached



175
176
177
# File 'lib/calabash-cucumber/environment_helpers.rb', line 175

def ios7?
  _default_device_or_create.ios7?
end

#ios8?Boolean

Is the device under test running iOS 8?

Returns:

  • (Boolean)

    true if device under test is running iOS 8

Raises:

  • (RuntimeError)

    if the server cannot be reached



183
184
185
# File 'lib/calabash-cucumber/environment_helpers.rb', line 183

def ios8?
 _default_device_or_create.ios8?
end

#ios9?Boolean

Is the device under test running iOS 9?

Returns:

  • (Boolean)

    true if device under test is running iOS 9

Raises:

  • (RuntimeError)

    if the server cannot be reached



191
192
193
# File 'lib/calabash-cucumber/environment_helpers.rb', line 191

def ios9?
 _default_device_or_create.ios9?
end

#ios_versionRunLoop::Version

The iOS version on the device under test.

Returns:

  • (RunLoop::Version)

    The version of the iOS running on the device.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



135
136
137
138
# File 'lib/calabash-cucumber/environment_helpers.rb', line 135

def ios_version
  require "run_loop/version"
  RunLoop::Version.new(_default_device_or_create.ios_version)
end

#ipad?Boolean

Is the device under test an iPad?

Returns:

  • (Boolean)

    true if device under test is an iPad.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



58
59
60
# File 'lib/calabash-cucumber/environment_helpers.rb', line 58

def ipad?
  _default_device_or_create.ipad?
end

#ipad_pro?Boolean

Is the device under test an iPad Pro

Returns:

  • (Boolean)

    true if device under test is an iPod.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



82
83
84
# File 'lib/calabash-cucumber/environment_helpers.rb', line 82

def ipad_pro?
  _default_device_or_create.ipad_pro?
end

#iphone?Boolean

Is the device under test an iPhone?

Returns:

  • (Boolean)

    true if device under test is an iPhone.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



66
67
68
# File 'lib/calabash-cucumber/environment_helpers.rb', line 66

def iphone?
  _default_device_or_create.iphone?
end

#iphone_35in?Boolean

Is the device under test an iPhone 3.5in?

Returns:

  • (Boolean)

    true if this device is an iPhone 3.5in?

Raises:

  • (RuntimeError)

    If the server cannot be reached.



127
128
129
# File 'lib/calabash-cucumber/environment_helpers.rb', line 127

def iphone_35in?
  _default_device_or_create.iphone_35in?
end

#iphone_4in?Boolean

Is the device under test have a 4 inch screen?

Returns:

  • (Boolean)

    true if device under test has a 4in screen.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



106
107
108
# File 'lib/calabash-cucumber/environment_helpers.rb', line 106

def iphone_4in?
  _default_device_or_create.iphone_4in?
end

#iphone_6?Boolean

Is the device under test an iPhone 6.

Returns:

  • (Boolean)

    true if this device is an iPhone 6

Raises:

  • (RuntimeError)

    If the server cannot be reached.



113
114
115
# File 'lib/calabash-cucumber/environment_helpers.rb', line 113

def iphone_6?
  _default_device_or_create.iphone_6?
end

#iphone_6_plus?Boolean

Is the device under test an iPhone 6+?

Returns:

  • (Boolean)

    true if this device is an iPhone 6+

Raises:

  • (RuntimeError)

    If the server cannot be reached.



120
121
122
# File 'lib/calabash-cucumber/environment_helpers.rb', line 120

def iphone_6_plus?
  _default_device_or_create.iphone_6_plus?
end

#iphone_app_emulated_on_ipad?Boolean

Is the app that is being tested an iPhone app emulated on an iPad?

Returns:

  • (Boolean)

    true if app is being emulated on an iPad.

Raises:

  • (RuntimeError)

    If the server cannot be reached.

See Also:



209
210
211
# File 'lib/calabash-cucumber/environment_helpers.rb', line 209

def iphone_app_emulated_on_ipad?
  _default_device_or_create.iphone_app_emulated_on_ipad?
end

#ipod?Boolean

Is the device under test an iPod?

Returns:

  • (Boolean)

    true if device under test is an iPod.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



74
75
76
# File 'lib/calabash-cucumber/environment_helpers.rb', line 74

def ipod?
  _default_device_or_create.ipod?
end

#screen_dimensionsRunLoop::Version

The screen dimensions of the device under test.

This is a hash of form: { :sample => 1, :height => 1334, :width => 750, :scaleā€œ => 2 }

Returns:

  • (RunLoop::Version)

    The version of the iOS running on the device.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



151
152
153
# File 'lib/calabash-cucumber/environment_helpers.rb', line 151

def screen_dimensions
  _default_device_or_create.screen_dimensions
end

#simulator?Boolean

Is the device under test a simulator?

Returns:

  • (Boolean)

    true if device under test is a simulator.

Raises:

  • (RuntimeError)

    If the server cannot be reached.



98
99
100
# File 'lib/calabash-cucumber/environment_helpers.rb', line 98

def simulator?
  _default_device_or_create.simulator?
end

#uia_available?Boolean

Note:

UIAutomation is only available if the app has been launched with instruments.

Are the uia* methods available?

Returns:

  • (Boolean)

    Returns true if the app has been launched with instruments.



22
23
24
# File 'lib/calabash-cucumber/environment_helpers.rb', line 22

def uia_available?
  Calabash::Cucumber::Launcher.instruments?
end

#uia_not_available?Boolean

Note:

UIAutomation is only available if the app has been launched with instruments.

Are the uia* methods un-available?

Returns:

  • (Boolean)

    Returns true if the app has been not been launched with instruments.



34
35
36
# File 'lib/calabash-cucumber/environment_helpers.rb', line 34

def uia_not_available?
  not uia_available?
end

#xamarin_test_cloud?Boolean

Are we running in the Xamarin Test Cloud?

Returns:

  • (Boolean)

    Returns true if cucumber is running in the test cloud.



41
42
43
# File 'lib/calabash-cucumber/environment_helpers.rb', line 41

def xamarin_test_cloud?
  ENV['XAMARIN_TEST_CLOUD'] == '1'
end