sauce_bindings 1.1.1 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +12 -6
- data/CHANGES.md +46 -0
- data/LICENSE.txt +1 -1
- data/README.md +11 -87
- data/Rakefile +15 -1
- data/lib/sauce_bindings/capybara_session.rb +0 -3
- data/lib/sauce_bindings/errors.rb +7 -0
- data/lib/sauce_bindings/logger.rb +20 -0
- data/lib/sauce_bindings/options.rb +23 -5
- data/lib/sauce_bindings/session.rb +98 -18
- data/lib/sauce_bindings/version.rb +1 -1
- data/lib/sauce_bindings.rb +8 -0
- data/sauce_bindings.gemspec +7 -6
- data/spec/examples/accessibility_spec.rb +32 -0
- data/spec/examples/axe.min.js +1 -0
- data/spec/examples/browser_options_spec.rb +2 -2
- data/spec/examples/{basic_options_spec.rb → common_options_spec.rb} +4 -3
- data/spec/examples/sauce_options_spec.rb +1 -1
- data/spec/integration/accessibility_spec.rb +59 -0
- data/spec/integration/desktop_spec.rb +33 -4
- data/spec/spec_helper.rb +39 -1
- data/spec/unit/capybara_session_spec.rb +10 -20
- data/spec/unit/deprecated_options_spec.rb +479 -456
- data/spec/unit/options_spec.rb +121 -154
- data/spec/unit/session_spec.rb +437 -84
- metadata +56 -33
data/spec/unit/session_spec.rb
CHANGED
@@ -13,15 +13,13 @@ module SauceBindings
|
|
13
13
|
{browserName: 'chrome',
|
14
14
|
browserVersion: 'latest',
|
15
15
|
platformName: 'Windows 10',
|
16
|
-
'sauce:options': {
|
16
|
+
'sauce:options': {username: 'foo',
|
17
|
+
accessKey: '123',
|
18
|
+
build: 'TEMP BUILD: 11'}}
|
17
19
|
end
|
18
20
|
|
19
|
-
def expect_request
|
20
|
-
|
21
|
-
capabilities: {firstMatch: [default_capabilities]}}.to_json
|
22
|
-
se4 = {capabilities: {alwaysMatch: default_capabilities}}.to_json
|
23
|
-
|
24
|
-
body = Selenium::WebDriver::VERSION[0] == '3' ? se3 : se4
|
21
|
+
def expect_request(caps = default_capabilities)
|
22
|
+
body = {capabilities: {alwaysMatch: caps}}.to_json
|
25
23
|
|
26
24
|
endpoint ||= 'https://ondemand.us-west-1.saucelabs.com/wd/hub/session'
|
27
25
|
stub_request(:post, endpoint).with(body: body).to_return(valid_response)
|
@@ -29,115 +27,165 @@ module SauceBindings
|
|
29
27
|
|
30
28
|
before do
|
31
29
|
allow_any_instance_of(Selenium::WebDriver::Remote::Http::Default).to receive(:use_proxy?).and_return(false)
|
32
|
-
allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
|
33
|
-
allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
|
34
|
-
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
35
|
-
allow(ENV).to receive(:[]).with('SAUCE_USERNAME').and_return('foo')
|
36
|
-
allow(ENV).to receive(:[]).with('SAUCE_ACCESS_KEY').and_return('123')
|
37
30
|
end
|
38
31
|
|
39
32
|
describe '#new' do
|
40
33
|
it 'creates default Options instance if none is provided' do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
34
|
+
ClimateControl.modify(**BUILD_ENV) do
|
35
|
+
@session = Session.new
|
36
|
+
end
|
37
|
+
|
38
|
+
expected_caps = {'browserName' => 'chrome',
|
39
|
+
'browserVersion' => 'latest',
|
40
|
+
'platformName' => 'Windows 10',
|
41
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11',
|
42
|
+
'username' => 'foo',
|
43
|
+
'accessKey' => '123'}}
|
44
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
45
|
+
@results = @session.to_selenium
|
46
|
+
end
|
47
|
+
expect(@results[:url]).to eq 'https://ondemand.us-west-1.saucelabs.com/wd/hub'
|
48
|
+
expect(@results[:capabilities].as_json).to eq expected_caps
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'uses provided Options class' do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
52
|
+
ClimateControl.modify(**BUILD_ENV) do
|
53
|
+
@sauce_opts = Options.chrome(browser_version: '123',
|
54
|
+
platform_name: 'Mac',
|
55
|
+
idle_timeout: 4)
|
56
|
+
end
|
57
|
+
|
58
|
+
session = Session.new(@sauce_opts)
|
59
|
+
|
60
|
+
expected_caps = {'browserName' => 'chrome',
|
61
|
+
'browserVersion' => '123',
|
62
|
+
'platformName' => 'Mac',
|
63
|
+
'sauce:options' => {'idleTimeout' => 4,
|
64
|
+
'build' => 'TEMP BUILD: 11',
|
65
|
+
'username' => 'foo',
|
66
|
+
'accessKey' => '123'}}
|
67
|
+
|
68
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
69
|
+
@results = session.to_selenium
|
70
|
+
end
|
71
|
+
|
72
|
+
expect(@results[:url]).to eq 'https://ondemand.us-west-1.saucelabs.com/wd/hub'
|
73
|
+
expect(@results[:capabilities].as_json).to eq expected_caps
|
64
74
|
end
|
65
75
|
|
66
76
|
it 'defaults to US West data Center' do
|
67
|
-
|
68
|
-
|
77
|
+
ClimateControl.modify(**BUILD_ENV) do
|
78
|
+
@session = Session.new
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(@session.data_center).to eq :US_WEST
|
69
82
|
end
|
70
83
|
|
71
84
|
it 'uses provided Data Center' do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
85
|
+
ClimateControl.modify(**BUILD_ENV) do
|
86
|
+
@session = Session.new(data_center: :EU_CENTRAL)
|
87
|
+
end
|
88
|
+
|
89
|
+
expected_caps = {'browserName' => 'chrome',
|
90
|
+
'browserVersion' => 'latest',
|
91
|
+
'platformName' => 'Windows 10',
|
92
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11',
|
93
|
+
'username' => 'foo',
|
94
|
+
'accessKey' => '123'}}
|
95
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
96
|
+
@results = @session.to_selenium
|
97
|
+
end
|
98
|
+
|
99
|
+
expect(@results[:url]).to eq 'https://ondemand.eu-central-1.saucelabs.com/wd/hub'
|
100
|
+
expect(@results[:capabilities].as_json).to eq expected_caps
|
80
101
|
end
|
81
102
|
|
82
103
|
it 'uses provided Event Listener' do
|
83
104
|
listener = instance_double(Selenium::WebDriver::Support::AbstractEventListener)
|
84
|
-
|
105
|
+
ClimateControl.modify(**BUILD_ENV) do
|
106
|
+
@session = Session.new(listener: listener)
|
107
|
+
end
|
85
108
|
|
86
|
-
|
109
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
110
|
+
expect(@session.to_selenium[:listener]).to eq listener
|
111
|
+
end
|
87
112
|
end
|
88
113
|
|
89
114
|
it 'uses provided HTTP Client' do
|
90
115
|
http_client = instance_double(Selenium::WebDriver::Remote::Http::Default)
|
91
|
-
session = Session.new(http_client: http_client)
|
92
116
|
|
93
|
-
|
117
|
+
ClimateControl.modify(**BUILD_ENV) do
|
118
|
+
@session = Session.new(http_client: http_client)
|
119
|
+
end
|
120
|
+
|
121
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
122
|
+
expect(@session.to_selenium[:http_client]).to eq http_client
|
123
|
+
end
|
94
124
|
end
|
95
125
|
|
96
126
|
it 'raises exception if data center is invalid' do
|
97
|
-
|
127
|
+
ClimateControl.modify(**BUILD_ENV) do
|
128
|
+
expect { Session.new(data_center: :FOO) }.to raise_exception(ArgumentError)
|
129
|
+
end
|
98
130
|
end
|
99
131
|
end
|
100
132
|
|
101
133
|
describe '#start' do
|
102
134
|
it 'starts the session and returns Selenium Driver instance' do
|
103
135
|
expect_request
|
136
|
+
ClimateControl.modify(**BUILD_ENV, **SAUCE_ACCESS) do
|
137
|
+
@driver = Session.new.start
|
138
|
+
end
|
104
139
|
|
105
|
-
driver
|
106
|
-
expect(driver).to be_a Selenium::WebDriver::Driver
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'uses username and access key from ENV' do
|
110
|
-
session = Session.new
|
111
|
-
|
112
|
-
expect(session.url).to include('foo:123')
|
140
|
+
expect(@driver).to be_a Selenium::WebDriver::Driver
|
113
141
|
end
|
114
142
|
|
115
143
|
it 'raises exception if no username set' do
|
116
|
-
|
117
|
-
|
118
|
-
|
144
|
+
ClimateControl.modify SAUCE_USERNAME: nil do
|
145
|
+
expect { Session.new.start }.to raise_exception(ArgumentError)
|
146
|
+
end
|
119
147
|
end
|
120
148
|
|
121
149
|
it 'raises exception if no access key set' do
|
122
|
-
|
123
|
-
|
124
|
-
|
150
|
+
ClimateControl.modify SAUCE_ACCESS_KEY: nil do
|
151
|
+
expect { Session.new.start }.to raise_exception(ArgumentError)
|
152
|
+
end
|
125
153
|
end
|
126
154
|
end
|
127
155
|
|
128
156
|
describe '#stop' do
|
129
157
|
it 'quits the driver' do
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
158
|
+
expect_request
|
159
|
+
ClimateControl.modify(**BUILD_ENV) do
|
160
|
+
@session = Session.new
|
161
|
+
end
|
134
162
|
|
135
|
-
|
136
|
-
|
137
|
-
|
163
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
164
|
+
@driver = @session.start
|
165
|
+
end
|
166
|
+
|
167
|
+
allow(@session).to receive :print_results
|
168
|
+
allow(@driver).to receive :quit
|
169
|
+
allow(SauceWhisk::Jobs).to receive(:change_status).with('0', false)
|
170
|
+
@session.stop(false)
|
171
|
+
|
172
|
+
expect(@driver).to have_received(:quit)
|
173
|
+
expect(SauceWhisk::Jobs).to have_received(:change_status).with('0', false)
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'raises error when argument value is not boolean' do
|
177
|
+
expect_request
|
178
|
+
|
179
|
+
ClimateControl.modify(**BUILD_ENV) do
|
180
|
+
@session = Session.new
|
181
|
+
end
|
182
|
+
|
183
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
184
|
+
@driver = @session.start
|
185
|
+
end
|
186
|
+
allow(@driver).to receive :quit
|
138
187
|
|
139
|
-
expect(
|
140
|
-
expect(SauceWhisk::Jobs).to have_received(:change_status).with('1234', true)
|
188
|
+
expect { @session.stop('String') }.to raise_error(ArgumentError)
|
141
189
|
end
|
142
190
|
end
|
143
191
|
|
@@ -146,7 +194,7 @@ module SauceBindings
|
|
146
194
|
session = Session.new
|
147
195
|
session.data_center = :US_EAST
|
148
196
|
|
149
|
-
expect(session.url).to eq('https://
|
197
|
+
expect(session.url).to eq('https://ondemand.us-east-1.saucelabs.com/wd/hub')
|
150
198
|
end
|
151
199
|
|
152
200
|
it 'raises exception if data center is invalid' do
|
@@ -166,27 +214,332 @@ module SauceBindings
|
|
166
214
|
end
|
167
215
|
end
|
168
216
|
|
169
|
-
describe '#
|
217
|
+
describe '#listener=' do
|
170
218
|
it 'uses provided Event Listener' do
|
171
219
|
listener = instance_double(Selenium::WebDriver::Support::AbstractEventListener)
|
172
|
-
|
173
|
-
|
220
|
+
ClimateControl.modify(**BUILD_ENV) do
|
221
|
+
@session = Session.new
|
222
|
+
end
|
223
|
+
|
224
|
+
@session.listener = listener
|
174
225
|
|
175
|
-
|
226
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
227
|
+
expect(@session.to_selenium[:listener]).to eq listener
|
228
|
+
end
|
176
229
|
end
|
177
230
|
end
|
178
231
|
|
179
232
|
describe '#url=' do
|
180
233
|
it 'allows user to override default URL' do
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
234
|
+
ClimateControl.modify(**BUILD_ENV) do
|
235
|
+
@session = Session.new
|
236
|
+
end
|
237
|
+
|
238
|
+
@session.url = 'https://mycustomurl/foo/wd/hub:8080'
|
239
|
+
|
240
|
+
expected_caps = {'browserName' => 'chrome',
|
241
|
+
'browserVersion' => 'latest',
|
242
|
+
'platformName' => 'Windows 10',
|
243
|
+
'sauce:options' => {'build' => 'TEMP BUILD: 11',
|
244
|
+
'username' => 'foo',
|
245
|
+
'accessKey' => '123'}}
|
246
|
+
|
247
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
248
|
+
@results = @session.to_selenium
|
249
|
+
end
|
250
|
+
expect(@results[:url]).to eq 'https://mycustomurl/foo/wd/hub:8080'
|
251
|
+
expect(@results[:capabilities].as_json).to eq expected_caps
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe '#annotate' do
|
256
|
+
it 'raises exception if session not started' do
|
257
|
+
ClimateControl.modify(**BUILD_ENV) do
|
258
|
+
@session = Session.new
|
259
|
+
end
|
260
|
+
|
261
|
+
expect { @session.annotate('Comment') }.to raise_error(SessionNotStartedError)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'accepts annotation' do
|
265
|
+
expect_request
|
266
|
+
ClimateControl.modify(**BUILD_ENV) do
|
267
|
+
@session = Session.new
|
268
|
+
end
|
269
|
+
|
270
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
271
|
+
@driver = @session.start
|
272
|
+
end
|
273
|
+
allow(@driver).to receive :quit
|
274
|
+
allow(@driver).to receive(:execute_script)
|
275
|
+
|
276
|
+
@session.annotate('comment')
|
277
|
+
|
278
|
+
expect(@driver).to have_received(:execute_script).with('sauce:context=comment')
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
describe '#pause' do
|
283
|
+
it 'raises exception if session not started' do
|
284
|
+
ClimateControl.modify(**BUILD_ENV) do
|
285
|
+
@session = Session.new
|
286
|
+
end
|
287
|
+
|
288
|
+
expect { @session.pause }.to raise_error(SessionNotStartedError)
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'pauses test' do
|
292
|
+
expect_request
|
293
|
+
ClimateControl.modify(**BUILD_ENV) do
|
294
|
+
@session = Session.new
|
295
|
+
end
|
296
|
+
|
297
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
298
|
+
@driver = @session.start
|
299
|
+
end
|
300
|
+
allow(@driver).to receive :quit
|
301
|
+
allow(@driver).to receive(:execute_script)
|
302
|
+
|
303
|
+
message = "\nThis test has been stopped; no more driver commands will be accepted\n\n" \
|
304
|
+
"You can take manual control of the test from the Sauce Labs UI here: https://app.saucelabs.com/tests/0\n"
|
305
|
+
expect { @session.pause }.to output(message).to_stdout
|
306
|
+
|
307
|
+
expect(@driver).to have_received(:execute_script).with('sauce: break')
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
describe '#enable_logs' do
|
312
|
+
it 'raises exception if session not started' do
|
313
|
+
ClimateControl.modify(**BUILD_ENV) do
|
314
|
+
@session = Session.new
|
315
|
+
end
|
316
|
+
|
317
|
+
expect { @session.enable_logging }.to raise_error(SessionNotStartedError)
|
318
|
+
end
|
319
|
+
|
320
|
+
it 'enables logs' do
|
321
|
+
expect_request
|
322
|
+
ClimateControl.modify(**BUILD_ENV) do
|
323
|
+
@session = Session.new
|
324
|
+
end
|
325
|
+
|
326
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
327
|
+
@driver = @session.start
|
328
|
+
end
|
329
|
+
allow(@driver).to receive :quit
|
330
|
+
allow(@driver).to receive(:execute_script)
|
331
|
+
|
332
|
+
@session.enable_logging
|
333
|
+
|
334
|
+
expect(@driver).to have_received(:execute_script).with('sauce: enable log')
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
describe '#disable_logs' do
|
339
|
+
it 'raises exception if session not started' do
|
340
|
+
ClimateControl.modify(**BUILD_ENV) do
|
341
|
+
@session = Session.new
|
342
|
+
end
|
343
|
+
|
344
|
+
expect { @session.disable_logging }.to raise_error(SessionNotStartedError)
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'disables logs' do
|
348
|
+
expect_request
|
349
|
+
ClimateControl.modify(**BUILD_ENV) do
|
350
|
+
@session = Session.new
|
351
|
+
end
|
352
|
+
|
353
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
354
|
+
@driver = @session.start
|
355
|
+
end
|
356
|
+
allow(@driver).to receive :quit
|
357
|
+
allow(@driver).to receive(:execute_script)
|
358
|
+
|
359
|
+
@session.disable_logging
|
360
|
+
|
361
|
+
expect(@driver).to have_received(:execute_script).with('sauce: disable log')
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
describe '#stop_network' do
|
366
|
+
it 'raises exception if session not started' do
|
367
|
+
ClimateControl.modify(**BUILD_ENV) do
|
368
|
+
@session = Session.new
|
369
|
+
end
|
370
|
+
|
371
|
+
expect { @session.stop_network }.to raise_error(SessionNotStartedError)
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'raises exception if session not on a Mac' do
|
375
|
+
expect_request
|
376
|
+
ClimateControl.modify(**BUILD_ENV) do
|
377
|
+
@session = Session.new
|
378
|
+
end
|
379
|
+
|
380
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
381
|
+
@driver = @session.start
|
382
|
+
end
|
383
|
+
allow(@driver).to receive :quit
|
384
|
+
allow(@driver).to receive(:execute_script)
|
385
|
+
|
386
|
+
error = /Can only start or stop the network on a Mac/
|
387
|
+
expect { @session.stop_network }.to raise_error(InvalidPlatformError, error)
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'stops network' do
|
391
|
+
caps = default_capabilities.merge(platformName: 'mac')
|
392
|
+
expect_request(caps)
|
393
|
+
ClimateControl.modify(**BUILD_ENV) do
|
394
|
+
@session = Session.new(Options.chrome(platform_name: 'mac'))
|
395
|
+
end
|
396
|
+
|
397
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
398
|
+
@driver = @session.start
|
399
|
+
end
|
400
|
+
allow(@driver).to receive :quit
|
401
|
+
allow(@driver).to receive(:execute_script)
|
402
|
+
|
403
|
+
@session.stop_network
|
404
|
+
|
405
|
+
expect(@driver).to have_received(:execute_script).with('sauce: stop network')
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
describe '#start_network' do
|
410
|
+
it 'raises exception if session not started' do
|
411
|
+
ClimateControl.modify(**BUILD_ENV) do
|
412
|
+
@session = Session.new
|
413
|
+
end
|
414
|
+
|
415
|
+
expect { @session.start_network }.to raise_error(SessionNotStartedError)
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'raises exception if session not on a Mac' do
|
419
|
+
expect_request
|
420
|
+
ClimateControl.modify(**BUILD_ENV) do
|
421
|
+
@session = Session.new
|
422
|
+
end
|
423
|
+
|
424
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
425
|
+
@driver = @session.start
|
426
|
+
end
|
427
|
+
allow(@driver).to receive :quit
|
428
|
+
allow(@driver).to receive(:execute_script)
|
429
|
+
|
430
|
+
error = /Can only start or stop the network on a Mac/
|
431
|
+
expect { @session.start_network }.to raise_error(InvalidPlatformError, error)
|
432
|
+
end
|
433
|
+
|
434
|
+
it 'starts network' do
|
435
|
+
caps = default_capabilities.merge(platformName: 'mac')
|
436
|
+
expect_request(caps)
|
437
|
+
ClimateControl.modify(**BUILD_ENV) do
|
438
|
+
@session = Session.new(Options.chrome(platform_name: 'mac'))
|
439
|
+
end
|
440
|
+
|
441
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
442
|
+
@driver = @session.start
|
443
|
+
end
|
444
|
+
|
445
|
+
allow(@driver).to receive :quit
|
446
|
+
allow(@driver).to receive(:execute_script)
|
447
|
+
|
448
|
+
@session.start_network
|
449
|
+
|
450
|
+
expect(@driver).to have_received(:execute_script).with('sauce: start network')
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
describe '#change_name' do
|
455
|
+
it 'raises exception if session not started' do
|
456
|
+
ClimateControl.modify(**BUILD_ENV) do
|
457
|
+
@session = Session.new
|
458
|
+
end
|
459
|
+
|
460
|
+
expect { @session.change_name('New Name') }.to raise_error(SessionNotStartedError)
|
461
|
+
end
|
462
|
+
|
463
|
+
it 'changes the test name' do
|
464
|
+
expect_request
|
465
|
+
ClimateControl.modify(**BUILD_ENV) do
|
466
|
+
@session = Session.new
|
467
|
+
end
|
468
|
+
|
469
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
470
|
+
@driver = @session.start
|
471
|
+
end
|
472
|
+
|
473
|
+
allow(@driver).to receive :quit
|
474
|
+
allow(@driver).to receive(:execute_script)
|
475
|
+
|
476
|
+
@session.change_name('New Name')
|
477
|
+
|
478
|
+
expect(@driver).to have_received(:execute_script).with('sauce:job-name=New Name')
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
describe '#tags=' do
|
483
|
+
it 'raises exception if session not started' do
|
484
|
+
ClimateControl.modify(**BUILD_ENV) do
|
485
|
+
@session = Session.new
|
486
|
+
end
|
487
|
+
|
488
|
+
expect { @session.add_tags([]) }.to raise_error(SessionNotStartedError)
|
489
|
+
end
|
490
|
+
|
491
|
+
it 'accepts single tag' do
|
492
|
+
expect_request
|
493
|
+
ClimateControl.modify(**BUILD_ENV) do
|
494
|
+
@session = Session.new
|
495
|
+
end
|
496
|
+
|
497
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
498
|
+
@driver = @session.start
|
499
|
+
end
|
500
|
+
|
501
|
+
allow(@driver).to receive :quit
|
502
|
+
allow(@driver).to receive(:execute_script)
|
503
|
+
|
504
|
+
@session.add_tags 'foo'
|
505
|
+
|
506
|
+
expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo')
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'accepts multiple tags as String' do
|
510
|
+
expect_request
|
511
|
+
ClimateControl.modify(**BUILD_ENV) do
|
512
|
+
@session = Session.new
|
513
|
+
end
|
514
|
+
|
515
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
516
|
+
@driver = @session.start
|
517
|
+
end
|
518
|
+
|
519
|
+
allow(@driver).to receive :quit
|
520
|
+
allow(@driver).to receive(:execute_script)
|
521
|
+
|
522
|
+
@session.add_tags 'foo,bar'
|
523
|
+
|
524
|
+
expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo,bar')
|
525
|
+
end
|
526
|
+
|
527
|
+
it 'accepts multiple tags as Array' do
|
528
|
+
expect_request
|
529
|
+
ClimateControl.modify(**BUILD_ENV) do
|
530
|
+
@session = Session.new
|
531
|
+
end
|
532
|
+
|
533
|
+
ClimateControl.modify(**SAUCE_ACCESS) do
|
534
|
+
@driver = @session.start
|
535
|
+
end
|
536
|
+
|
537
|
+
allow(@driver).to receive :quit
|
538
|
+
allow(@driver).to receive(:execute_script)
|
539
|
+
|
540
|
+
@session.add_tags %w[foo bar]
|
541
|
+
|
542
|
+
expect(@driver).to have_received(:execute_script).with('sauce:job-tags=foo,bar')
|
190
543
|
end
|
191
544
|
end
|
192
545
|
end
|