Module: Calabash::Cucumber::EnvironmentHelpers

Includes:
Logging
Included in:
Core, IOS7Operations
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

Methods included from Logging

#calabash_info, #calabash_warn

Instance Method Details

#default_deviceCalabash::Cucumber::Device

Returns the default Device that is connected the current launcher.

Returns:



52
53
54
55
# File 'lib/calabash-cucumber/environment_helpers.rb', line 52

def default_device
  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



85
86
87
# File 'lib/calabash-cucumber/environment_helpers.rb', line 85

def device_family_iphone?
  iphone? or ipod?
end

#ios5?Boolean

Note:

WARNING: The ‘OS` env variable has been deprecated and should never be set.

Note:

*WARNING: Setting the ‘OS` env variable will override the value returned by querying the device.

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



123
124
125
# File 'lib/calabash-cucumber/environment_helpers.rb', line 123

def ios5?
  _OS_ENV.eql?(_canonical_os_version(:ios5)) || _default_device_or_create().ios5?
end

#ios6?Boolean

Note:

WARNING: The ‘OS` env variable has been deprecated and should never be set.

Note:

*WARNING: Setting the ‘OS` env variable will override the value returned by querying the device.

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



138
139
140
# File 'lib/calabash-cucumber/environment_helpers.rb', line 138

def ios6?
  _OS_ENV.eql?(_canonical_os_version(:ios6)) || _default_device_or_create().ios6?
end

#ios7?Boolean

Note:

WARNING: The ‘OS` env variable has been deprecated and should never be set.

Note:

*WARNING: Setting the ‘OS` env variable will override the value returned by querying the device.

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



154
155
156
# File 'lib/calabash-cucumber/environment_helpers.rb', line 154

def ios7?
  _OS_ENV.eql?(_canonical_os_version(:ios7)) || _default_device_or_create().ios7?
end

#ios8?Boolean

Note:

WARNING: The ‘OS` env variable has been deprecated and should never be set.

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



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

def ios8?
 _default_device_or_create.ios8?
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



61
62
63
# File 'lib/calabash-cucumber/environment_helpers.rb', line 61

def ipad?
  _default_device_or_create().ipad?
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



69
70
71
# File 'lib/calabash-cucumber/environment_helpers.rb', line 69

def iphone?
  _default_device_or_create().iphone?
end

#iphone_4in?Boolean

Does the device under test have 4in screen?

Returns:

  • (Boolean)

    true if device under test has a 4in screen.

Raises:

  • (RuntimeError)

    if the server cannot be reached



108
109
110
# File 'lib/calabash-cucumber/environment_helpers.rb', line 108

def iphone_4in?
  _default_device_or_create().iphone_4in?
end

#iphone_5?Boolean

Deprecated.

0.9.168 replaced with ‘iphone_4in?`

Returns:

  • (Boolean)

See Also:



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

def iphone_5?
  _deprecated('0.9.168', "use 'iphone_4in?' instead", :warn)
  iphone_4in?
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:



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

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



77
78
79
# File 'lib/calabash-cucumber/environment_helpers.rb', line 77

def ipod?
  _default_device_or_create().ipod?
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



93
94
95
# File 'lib/calabash-cucumber/environment_helpers.rb', line 93

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.



26
27
28
# File 'lib/calabash-cucumber/environment_helpers.rb', line 26

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.



38
39
40
# File 'lib/calabash-cucumber/environment_helpers.rb', line 38

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.



45
46
47
# File 'lib/calabash-cucumber/environment_helpers.rb', line 45

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