simctl 1.6.7 → 1.6.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9e9a83d7edd52e86d76568513d830437266845ea90eb8ecea4a709ad0deea6d
4
- data.tar.gz: 7f0b6f86ad29a264d7a95950ab63789a454673328c127ad3b8595f02ff46c911
3
+ metadata.gz: 01f3ce681b28771f0952bf633fa33fed96b06e009331fdcb1ba40452e6480dd9
4
+ data.tar.gz: eb15732f51c9ed7dc17a61d6439f5a185cdd7cd9aecdcabecc55fb221cb4d451
5
5
  SHA512:
6
- metadata.gz: a21a7c730e4e166b4c3e607015d204296167d0534c2dbf06becc2dc7a2895fc1be80c789f2e3424be2a8569d1524b572d37f7827aa53660d9657bb2cd9477997
7
- data.tar.gz: b55a02c3f3666316a1382358f7a83be30675c45aa08dd3e38da27ec01da00a6835d3f5e2eb1c6110c5772143601ffc7c73afa8e3bb3b8512f90965256230ce86
6
+ metadata.gz: 665c06b9d2a31c17b0b614dcbb792476d2f1a519483c85834391736a148beaec615efd4361cc48af0ac0287e283842d5b73b5147f22a3568b17050711ef895cc
7
+ data.tar.gz: 9a9134735dee1ce4bb3eca2b1eb3c6f5d325f982dfe83c2b3c1f4ea63a4c002ff023c0721bb9bf8f062192b805b93ee7feac8a1a7e4237014a4f7a98d5b2ca37
@@ -0,0 +1,13 @@
1
+ name: Test
2
+ on: [push]
3
+ jobs:
4
+ build:
5
+ env:
6
+ LANG: en_US.UTF-8
7
+ runs-on: macos-11
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Install dependencies
11
+ run: gem install bundler:1.17.3 && bundle install
12
+ - name: Run tests
13
+ run: bundle exec rake
data/.travis.yml CHANGED
@@ -8,10 +8,10 @@ matrix:
8
8
  osx_image: xcode10.3
9
9
  env: CUSTOM_DEVICE_SET_PATH=false
10
10
  - os: osx
11
- osx_image: xcode11.2
11
+ osx_image: xcode11.3
12
12
  env: CUSTOM_DEVICE_SET_PATH=true
13
13
  - os: osx
14
- osx_image: xcode11.2
14
+ osx_image: xcode11.3
15
15
  env: CUSTOM_DEVICE_SET_PATH=false
16
16
  before_script:
17
17
  - export LANG=en_US.UTF-8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # 1.7.0
2
+
3
+ * Fix issue with Ruby >= 3.2
4
+
5
+ # 1.6.9
6
+
7
+ * Add `keychain_reset` command
8
+
9
+ # 1.6.8
10
+
11
+ * Add `upgrade` command
12
+ * Add `status_bar_clear` command (requires Xcode 11.4 or newer)
13
+ * Add `status_bar_override` command (requires Xcode 11.4 or newer)
14
+ * Add `privacy` command (requires Xcode 11.4 or newer)
15
+ * Add `push` command (requires Xcode 11.4 or newer)
16
+
1
17
  # 1.6.7
2
18
 
3
19
  * Turn off sliding hint on keyboard
data/Gemfile.lock CHANGED
@@ -1,45 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simctl (1.6.7)
4
+ simctl (1.6.10)
5
5
  CFPropertyList
6
6
  naturally
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- CFPropertyList (3.0.2)
12
- ast (2.4.0)
11
+ CFPropertyList (3.0.6)
12
+ rexml
13
+ ast (2.4.2)
13
14
  coveralls (0.8.23)
14
15
  json (>= 1.8, < 3)
15
16
  simplecov (~> 0.16.1)
16
17
  term-ansicolor (~> 1.3)
17
18
  thor (>= 0.19.4, < 2.0)
18
19
  tins (~> 1.6)
19
- diff-lcs (1.3)
20
- docile (1.3.2)
21
- json (2.2.0)
22
- naturally (2.2.0)
23
- parallel (1.17.0)
24
- parser (2.6.3.0)
25
- ast (~> 2.4.0)
26
- powerpack (0.1.2)
20
+ diff-lcs (1.5.0)
21
+ docile (1.4.0)
22
+ io-console (0.6.0)
23
+ irb (1.6.2)
24
+ reline (>= 0.3.0)
25
+ json (2.6.3)
26
+ naturally (2.2.1)
27
+ parallel (1.22.1)
28
+ parser (2.7.2.0)
29
+ ast (~> 2.4.1)
30
+ powerpack (0.1.3)
27
31
  rainbow (2.2.2)
28
32
  rake
29
- rake (12.3.3)
30
- rspec (3.8.0)
31
- rspec-core (~> 3.8.0)
32
- rspec-expectations (~> 3.8.0)
33
- rspec-mocks (~> 3.8.0)
34
- rspec-core (3.8.2)
35
- rspec-support (~> 3.8.0)
36
- rspec-expectations (3.8.4)
33
+ rake (13.0.6)
34
+ reline (0.3.2)
35
+ io-console (~> 0.5)
36
+ rexml (3.2.5)
37
+ rspec (3.12.0)
38
+ rspec-core (~> 3.12.0)
39
+ rspec-expectations (~> 3.12.0)
40
+ rspec-mocks (~> 3.12.0)
41
+ rspec-core (3.12.0)
42
+ rspec-support (~> 3.12.0)
43
+ rspec-expectations (3.12.2)
37
44
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.8.0)
39
- rspec-mocks (3.8.1)
45
+ rspec-support (~> 3.12.0)
46
+ rspec-mocks (3.12.3)
40
47
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.8.0)
42
- rspec-support (3.8.2)
48
+ rspec-support (~> 3.12.0)
49
+ rspec-support (3.12.0)
43
50
  rubocop (0.49.1)
44
51
  parallel (~> 1.10)
45
52
  parser (>= 2.3.3.1, < 3.0)
@@ -47,27 +54,31 @@ GEM
47
54
  rainbow (>= 1.99.1, < 3.0)
48
55
  ruby-progressbar (~> 1.7)
49
56
  unicode-display_width (~> 1.0, >= 1.0.1)
50
- ruby-progressbar (1.10.1)
57
+ ruby-progressbar (1.11.0)
51
58
  simplecov (0.16.1)
52
59
  docile (~> 1.1)
53
60
  json (>= 1.8, < 3)
54
61
  simplecov-html (~> 0.10.0)
55
62
  simplecov-html (0.10.2)
63
+ sync (0.5.0)
56
64
  term-ansicolor (1.7.1)
57
65
  tins (~> 1.0)
58
- thor (0.20.3)
59
- tins (1.21.1)
60
- unicode-display_width (1.6.0)
66
+ thor (1.2.1)
67
+ tins (1.32.1)
68
+ sync
69
+ unicode-display_width (1.8.0)
61
70
 
62
71
  PLATFORMS
63
- ruby
72
+ arm64-darwin-21
73
+ arm64-darwin-22
64
74
 
65
75
  DEPENDENCIES
66
76
  coveralls
77
+ irb
67
78
  rake
68
79
  rspec
69
80
  rubocop (= 0.49.1)
70
81
  simctl!
71
82
 
72
83
  BUNDLED WITH
73
- 1.17.3
84
+ 2.4.1
data/README.md CHANGED
@@ -9,14 +9,14 @@ Ruby interface to xcrun simctl. Manage your iOS Simulators directly from a ruby
9
9
  ```ruby
10
10
  require 'simctl'
11
11
 
12
- # Select the iOS 12.1 runtime
13
- runtime = SimCtl.runtime(name: 'iOS 12.1')
12
+ # Select the iOS 14.5 runtime
13
+ runtime = SimCtl.runtime(name: 'iOS 14.5')
14
14
 
15
- # Select the iPhone 6 device type
16
- devicetype = SimCtl.devicetype(name: 'iPhone 6')
15
+ # Select the iPhone 8 device type
16
+ devicetype = SimCtl.devicetype(name: 'iPhone 8')
17
17
 
18
18
  # Create a new device
19
- device = SimCtl.create_device 'Unit Tests @ iPhone 6 - 12.1', devicetype, runtime
19
+ device = SimCtl.create_device 'Unit Tests @ iPhone 8 - 14.5', devicetype, runtime
20
20
 
21
21
  # Boot the device
22
22
  device.boot
@@ -34,7 +34,7 @@ module Fastlane
34
34
  description: "iOS device type used to create the simulator",
35
35
  optional: true,
36
36
  type: String,
37
- default_value: 'iPhone 6'),
37
+ default_value: 'iPhone 8'),
38
38
  FastlaneCore::ConfigItem.new(key: :name,
39
39
  description: "String used to set the name to the simulator",
40
40
  optional: true,
@@ -0,0 +1,18 @@
1
+ require 'ostruct'
2
+
3
+ module SimCtl
4
+ class Command
5
+ module Keychain
6
+ # Reset the keychain
7
+ #
8
+ # @param device [SimCtl::Device] the device
9
+ # @return [void]
10
+ def keychain_reset(device)
11
+ unless Xcode::Version.gte? '11.4'
12
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
13
+ end
14
+ Executor.execute(command_for('keychain', device.udid, 'reset'))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module SimCtl
2
+ class Command
3
+ module Privacy
4
+ # Change privacy settings
5
+ #
6
+ # @param device [SimCtl::Device] the device
7
+ # @param action [String] grant, revoke, reset
8
+ # @param service [String] all, calendar, contacts-limited, contacts, location,
9
+ # location-always, photos-add, photos, media-library, microphone,
10
+ # motion, reminders, siri
11
+ # @param bundle [String] bundle identifier
12
+ # @return [void]
13
+ def privacy(device, action, service, bundle)
14
+ unless Xcode::Version.gte? '11.4'
15
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
16
+ end
17
+ Executor.execute(command_for('privacy', device.udid, action, service, bundle))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ require 'fileutils'
2
+ require 'json'
3
+ require 'tempfile'
4
+
5
+ module SimCtl
6
+ class Command
7
+ module Push
8
+ # Send some push notification
9
+ #
10
+ # @param device [SimCtl::Device] the device
11
+ # @param bundle [String] bundle identifier
12
+ # @param payload the JSON payload. This can be a JSON [String], some [Hash] or
13
+ # just a [String] path to a local file containing a JSON payload
14
+ # @return [void]
15
+ def push(device, bundle, payload)
16
+ unless Xcode::Version.gte? '11.4'
17
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
18
+ end
19
+
20
+ file = Tempfile.new('push')
21
+
22
+ if payload.is_a?(Hash)
23
+ JSON.dump payload, file
24
+ file.close
25
+ elsif payload.is_a?(String) && File.exist?(payload)
26
+ file.close
27
+ FileUtils.cp payload, file.path
28
+ else
29
+ file.write payload
30
+ file.close
31
+ end
32
+
33
+ Executor.execute(command_for('push', device.udid, bundle, file.path))
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,52 @@
1
+ require 'ostruct'
2
+
3
+ module SimCtl
4
+ class Command
5
+ module StatusBar
6
+ # Clear all status bar overrides
7
+ #
8
+ # @param device [SimCtl::Device] the device
9
+ # @return [void]
10
+ def status_bar_clear(device)
11
+ unless Xcode::Version.gte? '11.4'
12
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
13
+ end
14
+ Executor.execute(command_for('status_bar', device.udid, 'clear'))
15
+ end
16
+
17
+ # Set some status bar overrides
18
+ #
19
+ # Refer to `xcrun simctl status_bar` for available options.
20
+ #
21
+ # Example:
22
+ #
23
+ # SimCtl.status_bar_override device, {
24
+ # time: '9:41',
25
+ # dataNetwork: 'lte+',
26
+ # wifiMode: 'active',
27
+ # cellularMode: 'active',
28
+ # batteryState: 'charging',
29
+ # batteryLevel: 50
30
+ # }
31
+ #
32
+ # @param device [SimCtl::Device] the device
33
+ # @param overrides [SimCtl::StatusBarOverrides] or [Hash] the overrides to apply
34
+ # @return [void]
35
+ def status_bar_override(device, overrides)
36
+ unless Xcode::Version.gte? '11.4'
37
+ raise UnsupportedCommandError, 'Needs at least Xcode 11.4'
38
+ end
39
+ overrides = SimCtl::StatusBarOverrides.new overrides unless overrides.is_a?(SimCtl::StatusBarOverrides)
40
+ Executor.execute(command_for('status_bar', device.udid, 'override', *overrides.to_args))
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ module SimCtl
47
+ class StatusBarOverrides < OpenStruct
48
+ def to_args
49
+ to_h.map { |k, v| ["--#{k}", v] }.flatten
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ module SimCtl
2
+ class Command
3
+ module Upgrade
4
+ # Upgrade a device to a newer runtime
5
+ #
6
+ # @param device [SimCtl::Device] the device the upgrade should be performed for
7
+ # @param runtime [SimCtl::Runtime] the runtime the device should be upgrade to
8
+ # @return [void]
9
+ def upgrade(device, runtime)
10
+ Executor.execute(command_for('upgrade', device.udid, runtime.identifier))
11
+ end
12
+ end
13
+ end
14
+ end
@@ -10,7 +10,7 @@ module SimCtl
10
10
  def warmup(devicetype, runtime, timeout = 120)
11
11
  devicetype = devicetype(name: devicetype) unless devicetype.is_a?(DeviceType)
12
12
  runtime = runtime(name: runtime) unless runtime.is_a?(Runtime)
13
- device = device(devicetype: devicetype, runtime: runtime)
13
+ device = device(runtime: runtime, devicetype: devicetype)
14
14
  raise DeviceNotFound, "Could not find device with type '#{devicetype.name}' and runtime '#{runtime.name}'" if device.nil?
15
15
  device.boot if device.state != :booted
16
16
  device.wait(timeout) { |d| d.state == :booted && d.ready? }
@@ -4,16 +4,21 @@ require 'simctl/command/delete'
4
4
  require 'simctl/command/erase'
5
5
  require 'simctl/command/install'
6
6
  require 'simctl/command/io'
7
+ require 'simctl/command/keychain'
7
8
  require 'simctl/command/kill'
8
9
  require 'simctl/command/launch'
10
+ require 'simctl/command/privacy'
9
11
  require 'simctl/command/terminate'
10
12
  require 'simctl/command/list'
11
13
  require 'simctl/command/openurl'
14
+ require 'simctl/command/push'
12
15
  require 'simctl/command/rename'
13
16
  require 'simctl/command/reset'
14
17
  require 'simctl/command/shutdown'
15
18
  require 'simctl/command/spawn'
19
+ require 'simctl/command/status_bar'
16
20
  require 'simctl/command/uninstall'
21
+ require 'simctl/command/upgrade'
17
22
  require 'simctl/command/warmup'
18
23
  require 'simctl/executor'
19
24
  require 'shellwords'
@@ -28,16 +33,21 @@ module SimCtl
28
33
  include SimCtl::Command::Erase
29
34
  include SimCtl::Command::IO
30
35
  include SimCtl::Command::Install
36
+ include SimCtl::Command::Keychain
31
37
  include SimCtl::Command::Kill
32
38
  include SimCtl::Command::Launch
33
- include SimCtl::Command::Terminate
34
39
  include SimCtl::Command::List
35
40
  include SimCtl::Command::OpenUrl
41
+ include SimCtl::Command::Privacy
42
+ include SimCtl::Command::Push
36
43
  include SimCtl::Command::Rename
37
44
  include SimCtl::Command::Reset
38
45
  include SimCtl::Command::Shutdown
39
46
  include SimCtl::Command::Spawn
47
+ include SimCtl::Command::StatusBar
48
+ include SimCtl::Command::Terminate
40
49
  include SimCtl::Command::Uninstall
50
+ include SimCtl::Command::Upgrade
41
51
  include SimCtl::Command::Warmup
42
52
 
43
53
  def device_set_path=(device_set_path)
data/lib/simctl/device.rb CHANGED
@@ -3,7 +3,9 @@ require 'ostruct'
3
3
  require 'simctl/device_launchctl'
4
4
  require 'simctl/device_path'
5
5
  require 'simctl/device_settings'
6
+ require 'simctl/keychain'
6
7
  require 'simctl/object'
8
+ require 'simctl/status_bar'
7
9
  require 'timeout'
8
10
 
9
11
  module SimCtl
@@ -26,7 +28,12 @@ module SimCtl
26
28
  #
27
29
  # @return [Bool]
28
30
  def available?
29
- is_available !~ /unavailable/i
31
+ case is_available
32
+ when String
33
+ is_available !~ /unavailable/i
34
+ else
35
+ is_available
36
+ end
30
37
  end
31
38
 
32
39
  # Boots the device
@@ -45,9 +52,11 @@ module SimCtl
45
52
 
46
53
  # Returns the device type
47
54
  #
48
- # @return [SimCtl::DeviceType]
55
+ # @return [SimCtl::DeviceType, String]
49
56
  def devicetype
50
57
  @devicetype ||= SimCtl.devicetype(identifier: plist.deviceType)
58
+ rescue
59
+ plist.deviceType
51
60
  end
52
61
 
53
62
  # Erases the device
@@ -94,6 +103,13 @@ module SimCtl
94
103
  @launchctl ||= DeviceLaunchctl.new(self)
95
104
  end
96
105
 
106
+ # Returns the keychain bar object
107
+ #
108
+ # @return [SimCtl::keychain]
109
+ def keychain
110
+ @keychain ||= SimCtl::Keychain.new(self)
111
+ end
112
+
97
113
  # Launches an app in the given device
98
114
  #
99
115
  # @param opts [Hash] options hash - `{ wait_for_debugger: true/false }`
@@ -125,6 +141,18 @@ module SimCtl
125
141
  @path ||= DevicePath.new(self)
126
142
  end
127
143
 
144
+ # Change privacy settings
145
+ #
146
+ # @param action [String] grant, revoke, reset
147
+ # @param service [String] all, calendar, contacts-limited, contacts, location,
148
+ # location-always, photos-add, photos, media-library, microphone,
149
+ # motion, reminders, siri
150
+ # @param bundle [String] bundle identifier
151
+ # @return [void]
152
+ def privacy(action, service, bundle)
153
+ SimCtl.privacy(self, action, service, bundle)
154
+ end
155
+
128
156
  # Returns true/false if the device is ready
129
157
  # Uses [SimCtl::DeviceLaunchctl] to look for certain services being running.
130
158
  #
@@ -162,11 +190,13 @@ module SimCtl
162
190
  SimCtl.reset_device name, devicetype, runtime
163
191
  end
164
192
 
165
- # Resets the runtime
193
+ # Returns the runtime object
166
194
  #
167
- # @return [SimCtl::Runtime]
195
+ # @return [SimCtl::Runtime, String]
168
196
  def runtime
169
197
  @runtime ||= SimCtl.runtime(identifier: plist.runtime)
198
+ rescue
199
+ plist.runtime
170
200
  end
171
201
 
172
202
  # Saves a screenshot to a file
@@ -210,6 +240,13 @@ module SimCtl
210
240
  @state.downcase.to_sym
211
241
  end
212
242
 
243
+ # Returns the status bar object
244
+ #
245
+ # @return [SimCtl::StatusBar]
246
+ def status_bar
247
+ @status_bar ||= SimCtl::StatusBar.new(self)
248
+ end
249
+
213
250
  # Reloads the device until the given block returns true
214
251
  #
215
252
  # @return [void]
@@ -0,0 +1,18 @@
1
+ module SimCtl
2
+ class Keychain
3
+ def initialize(device)
4
+ @device = device
5
+ end
6
+
7
+ # Reset the keychain
8
+ #
9
+ # @return [void]
10
+ def reset
11
+ SimCtl.keychain_reset(device)
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :device
17
+ end
18
+ end
@@ -32,7 +32,7 @@ module SimCtl
32
32
  # @param name [String] type (ios, watchos, tvos)
33
33
  # @return [SimCtl::Runtime] the latest available runtime
34
34
  def self.latest(type)
35
- Naturally.sort_by(SimCtl.list_runtimes.where(name: /#{type}/i), :version).last
35
+ Naturally.sort_by(SimCtl.list_runtimes.where(identifier: /#{type}/i), :version).last
36
36
  end
37
37
  end
38
38
  end
@@ -0,0 +1,26 @@
1
+ module SimCtl
2
+ class StatusBar
3
+ def initialize(device)
4
+ @device = device
5
+ end
6
+
7
+ # Clear all status bar overrides
8
+ #
9
+ # @return [void]
10
+ def clear
11
+ SimCtl.status_bar_clear(device)
12
+ end
13
+
14
+ # Set some status bar overrides
15
+ #
16
+ # @param overrides [SimCtl::StatusBarOverrides] or [Hash] the overrides to apply
17
+ # @return [void]
18
+ def override(overrides)
19
+ SimCtl.status_bar_override(device, overrides)
20
+ end
21
+
22
+ private
23
+
24
+ attr_reader :device
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module SimCtl
2
- VERSION = '1.6.7'.freeze
2
+ VERSION = '1.6.10'.freeze
3
3
  end
data/simctl.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.add_development_dependency 'coveralls'
23
+ s.add_development_dependency 'irb'
23
24
  s.add_development_dependency 'rake'
24
25
  s.add_development_dependency 'rspec'
25
26
  s.add_development_dependency 'rubocop', '=0.49.1'
@@ -169,6 +169,53 @@ RSpec.describe SimCtl, order: :defined do
169
169
  end
170
170
  end
171
171
 
172
+ describe 'keychain operations' do
173
+ if SimCtl::Xcode::Version.gte?('11.4')
174
+ it 'resets the keychain' do
175
+ @device.keychain.reset
176
+ end
177
+ else
178
+ it 'raises exception' do
179
+ expect { @device.keychain.reset }.to raise_error SimCtl::UnsupportedCommandError
180
+ end
181
+ end
182
+ end
183
+
184
+ describe 'overriding status bar values' do
185
+ if SimCtl::Xcode::Version.gte?('11.4')
186
+ it 'overrides the status bar values' do
187
+ @device.status_bar.override SimCtl::StatusBarOverrides.new(
188
+ time: '10:45',
189
+ dataNetwork: 'lte+',
190
+ wifiMode: 'active',
191
+ cellularMode: 'active',
192
+ batteryState: 'charging',
193
+ batteryLevel: 50
194
+ )
195
+ end
196
+
197
+ it 'overrides the status bar values with a hash' do
198
+ @device.status_bar.override(
199
+ time: '10:45',
200
+ dataNetwork: 'lte+',
201
+ wifiMode: 'active',
202
+ cellularMode: 'active',
203
+ batteryState: 'charging',
204
+ batteryLevel: 50
205
+ )
206
+ end
207
+
208
+ it 'clears the status bar' do
209
+ @device.status_bar.clear
210
+ end
211
+ else
212
+ it 'raises exception' do
213
+ expect { @device.status_bar.clear }.to raise_error SimCtl::UnsupportedCommandError
214
+ expect { @device.status_bar.override(time: '10:45') }.to raise_error SimCtl::UnsupportedCommandError
215
+ end
216
+ end
217
+ end
218
+
172
219
  describe 'launching a system app' do
173
220
  it 'launches Safari' do
174
221
  @device.launch_app('com.apple.mobilesafari')
@@ -224,6 +271,18 @@ RSpec.describe SimCtl, order: :defined do
224
271
  end
225
272
  end
226
273
 
274
+ describe 'changing privacy settings' do
275
+ if SimCtl::Xcode::Version.gte?('11.4')
276
+ it 'resets all privacy settings' do
277
+ @device.privacy('reset', 'all', 'com.github.plu.simctl.SampleApp')
278
+ end
279
+ else
280
+ it 'raises exception' do
281
+ expect { @device.privacy('reset', 'all', 'com.github.plu.simctl.SampleApp') }.to raise_error SimCtl::UnsupportedCommandError
282
+ end
283
+ end
284
+ end
285
+
227
286
  describe 'uninstall an app' do
228
287
  it 'uninstalls SampleApp' do
229
288
  @device.uninstall('com.github.plu.simctl.SampleApp')
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  RSpec.describe SimCtl do
4
4
  describe '#devicetype' do
5
5
  it 'find device type by name' do
6
- expect(SimCtl.devicetype(name: 'iPhone 6')).to be_kind_of SimCtl::DeviceType
6
+ expect(SimCtl.devicetype(name: 'iPhone 8')).to be_kind_of SimCtl::DeviceType
7
7
  end
8
8
 
9
9
  it 'raise exception if device type is not found' do
@@ -69,15 +69,23 @@ RSpec.describe SimCtl do
69
69
 
70
70
  describe '#runtime' do
71
71
  it 'find runtime by name' do
72
- expect(SimCtl.runtime(name: 'iOS 12.1')).to be_kind_of SimCtl::Runtime
72
+ expect(SimCtl.runtime(name: 'iOS 15.2')).to be_kind_of SimCtl::Runtime
73
73
  end
74
74
 
75
75
  it 'raise exception if runtime is not found' do
76
- expect { SimCtl.runtime(name: 'iOS 17.0') }.to raise_error SimCtl::RuntimeNotFound
76
+ expect { SimCtl.runtime(name: 'iOS 19.0') }.to raise_error SimCtl::RuntimeNotFound
77
77
  end
78
78
 
79
79
  it 'finds the latest runtime' do
80
- if SimCtl::Xcode::Version.gte?('11.2')
80
+ if SimCtl::Xcode::Version.gte?('13.2')
81
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '15.2'
82
+ elsif SimCtl::Xcode::Version.gte?('12.5')
83
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '14.5'
84
+ elsif SimCtl::Xcode::Version.gte?('11.4')
85
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '13.4'
86
+ elsif SimCtl::Xcode::Version.gte?('11.3')
87
+ expect(SimCtl::Runtime.latest(:ios).version).to be == '13.3'
88
+ elsif SimCtl::Xcode::Version.gte?('11.2')
81
89
  expect(SimCtl::Runtime.latest(:ios).version).to be == '13.2.2'
82
90
  elsif SimCtl::Xcode::Version.gte?('10.3')
83
91
  expect(SimCtl::Runtime.latest(:ios).version).to be == '12.4'
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe SimCtl do
4
4
  it 'executes example code from readme' do
5
- # Select the iOS 12.1 runtime
6
- runtime = SimCtl.runtime(name: 'iOS 12.1')
5
+ # Select the iOS 15.2 runtime
6
+ runtime = SimCtl.runtime(name: 'iOS 15.2')
7
7
 
8
- # Select the iPhone 6 device type
9
- devicetype = SimCtl.devicetype(name: 'iPhone 6')
8
+ # Select the iPhone 8 device type
9
+ devicetype = SimCtl.devicetype(name: 'iPhone 8')
10
10
 
11
11
  # Create a new device
12
- device = SimCtl.create_device 'Unit Tests @ iPhone 6 - 12.1', devicetype, runtime
12
+ device = SimCtl.create_device 'Unit Tests @ iPhone 8 - 15.2', devicetype, runtime
13
13
 
14
14
  # Boot the device
15
15
  device.boot
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SimCtl do
4
+ describe '#upgrade' do
5
+ it 'upgrades a device to a newer runtime' do
6
+ old_runtime = SimCtl.runtime(name: 'iOS 15.2')
7
+ new_runtime = SimCtl.runtime(name: 'iOS 15.2')
8
+ device = SimCtl.reset_device 'iPhone 8', SimCtl.devicetype(name: 'iPhone 8'), old_runtime
9
+ expect(device.runtime.version).to be == old_runtime.version
10
+ SimCtl.upgrade device, new_runtime
11
+ device.wait { |d| d.runtime.version == new_runtime.version }
12
+ device.delete
13
+ end
14
+ end
15
+ end
@@ -2,20 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe SimCtl do
4
4
  describe '#warmup' do
5
- if SimCtl.device_set_path.nil?
6
- it 'warms up and returns a device for given strings' do
7
- expect(SimCtl.warmup('iPhone 6', 'iOS 12.1')).to be_kind_of SimCtl::Device
8
- end
5
+ it 'warms up and returns a device for given strings' do
6
+ SimCtl.reset_device 'iPhone 8', SimCtl.devicetype(name: 'iPhone 8'), SimCtl.runtime(name: 'iOS 15.2')
7
+ expect(SimCtl.warmup('iPhone 8', 'iOS 15.2')).to be_kind_of SimCtl::Device
8
+ end
9
9
 
10
- it 'warms up and returns a device for given objects' do
11
- devicetype = SimCtl.devicetype(name: 'iPhone 6')
12
- runtime = SimCtl::Runtime.latest(:ios)
13
- expect(SimCtl.warmup(devicetype, runtime)).to be_kind_of SimCtl::Device
14
- end
15
- else
16
- it 'raises exception' do
17
- expect { SimCtl.warmup('iPhone 6', 'iOS 12.1') }.to raise_error SimCtl::DeviceNotFound
18
- end
10
+ it 'warms up and returns a device for given objects' do
11
+ devicetype = SimCtl.devicetype(name: 'iPhone 8')
12
+ runtime = SimCtl::Runtime.latest(:ios)
13
+ SimCtl.reset_device 'iPhone 8', devicetype, runtime
14
+ expect(SimCtl.warmup(devicetype, runtime)).to be_kind_of SimCtl::Device
19
15
  end
20
16
  end
21
17
  end
data/spec/spec_helper.rb CHANGED
@@ -9,12 +9,7 @@ Coveralls.wear!
9
9
  $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
10
10
  require File.dirname(__FILE__) + '/../lib/simctl.rb'
11
11
 
12
- SimCtl.default_timeout = if ENV['TRAVIS']
13
- 300
14
- else
15
- 60
16
- end
17
-
12
+ SimCtl.default_timeout = 300
18
13
  SimCtl.device_set_path = Dir.mktmpdir 'foo bar' if ENV['CUSTOM_DEVICE_SET_PATH']
19
14
 
20
15
  RSpec.configure do |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Plunien
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: irb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +116,7 @@ extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
104
118
  - ".coveralls.yml"
119
+ - ".github/workflows/test.yml"
105
120
  - ".gitignore"
106
121
  - ".rubocop.yml"
107
122
  - ".rubocop_todo.yml"
@@ -135,16 +150,21 @@ files:
135
150
  - lib/simctl/command/erase.rb
136
151
  - lib/simctl/command/install.rb
137
152
  - lib/simctl/command/io.rb
153
+ - lib/simctl/command/keychain.rb
138
154
  - lib/simctl/command/kill.rb
139
155
  - lib/simctl/command/launch.rb
140
156
  - lib/simctl/command/list.rb
141
157
  - lib/simctl/command/openurl.rb
158
+ - lib/simctl/command/privacy.rb
159
+ - lib/simctl/command/push.rb
142
160
  - lib/simctl/command/rename.rb
143
161
  - lib/simctl/command/reset.rb
144
162
  - lib/simctl/command/shutdown.rb
145
163
  - lib/simctl/command/spawn.rb
164
+ - lib/simctl/command/status_bar.rb
146
165
  - lib/simctl/command/terminate.rb
147
166
  - lib/simctl/command/uninstall.rb
167
+ - lib/simctl/command/upgrade.rb
148
168
  - lib/simctl/command/warmup.rb
149
169
  - lib/simctl/device.rb
150
170
  - lib/simctl/device_launchctl.rb
@@ -152,9 +172,11 @@ files:
152
172
  - lib/simctl/device_settings.rb
153
173
  - lib/simctl/device_type.rb
154
174
  - lib/simctl/executor.rb
175
+ - lib/simctl/keychain.rb
155
176
  - lib/simctl/list.rb
156
177
  - lib/simctl/object.rb
157
178
  - lib/simctl/runtime.rb
179
+ - lib/simctl/status_bar.rb
158
180
  - lib/simctl/version.rb
159
181
  - lib/simctl/xcode/path.rb
160
182
  - lib/simctl/xcode/version.rb
@@ -170,13 +192,14 @@ files:
170
192
  - spec/simctl/executor_spec.rb
171
193
  - spec/simctl/list_spec.rb
172
194
  - spec/simctl/readme_spec.rb
195
+ - spec/simctl/upgrade_spec.rb
173
196
  - spec/simctl/warmup_spec.rb
174
197
  - spec/spec_helper.rb
175
198
  homepage: https://github.com/plu/simctl
176
199
  licenses:
177
200
  - MIT
178
201
  metadata: {}
179
- post_install_message:
202
+ post_install_message:
180
203
  rdoc_options: []
181
204
  require_paths:
182
205
  - lib
@@ -191,8 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
214
  - !ruby/object:Gem::Version
192
215
  version: '0'
193
216
  requirements: []
194
- rubygems_version: 3.0.3
195
- signing_key:
217
+ rubygems_version: 3.2.22
218
+ signing_key:
196
219
  specification_version: 4
197
220
  summary: Ruby interface to xcrun simctl
198
221
  test_files:
@@ -207,5 +230,6 @@ test_files:
207
230
  - spec/simctl/executor_spec.rb
208
231
  - spec/simctl/list_spec.rb
209
232
  - spec/simctl/readme_spec.rb
233
+ - spec/simctl/upgrade_spec.rb
210
234
  - spec/simctl/warmup_spec.rb
211
235
  - spec/spec_helper.rb