sauce_bindings 1.0.0 → 1.1.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/.rspec +0 -1
- data/.rubocop.yml +13 -4
- data/lib/sauce_bindings/options.rb +29 -1
- data/lib/sauce_bindings/session.rb +4 -3
- data/lib/sauce_bindings/version.rb +1 -1
- data/spec/examples/basic_options_spec.rb +26 -0
- data/spec/examples/browser_options_spec.rb +28 -0
- data/spec/examples/create_session_spec.rb +22 -0
- data/spec/examples/data_center_spec.rb +22 -0
- data/spec/examples/sauce_options_spec.rb +27 -0
- data/spec/unit/options_spec.rb +50 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 911fcc77b89278c32496a2c1e29a8076494208a2133fa4fa854e949d5db8437d
|
4
|
+
data.tar.gz: c8a91543d40f08b14fd3253e7ca32ecd639c9d2c24833f63c4668da51699ed27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6d3809d1efd72a5b89b0130a659b4d82863b16cf14377480bdfc3989ddf6f4c4e4bf2d9105968a03ee378c295366982a00b008fe2d9a91186ca107c1ea6231
|
7
|
+
data.tar.gz: 6f9a7311e6c206e3ac8689d402bed4dfb7ec8f19e2380b4543e64ddcfc5ed2dbf673da00c9788b6cea8aa3f20a432ff08cf8235d9a22c72f1d585445e3e7c82d
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -9,17 +9,17 @@ Layout/SpaceInsideHashLiteralBraces:
|
|
9
9
|
EnforcedStyle: no_space
|
10
10
|
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 25
|
13
13
|
|
14
14
|
Metrics/BlockLength:
|
15
15
|
Exclude:
|
16
16
|
- "**/*_spec.rb"
|
17
17
|
|
18
18
|
Metrics/CyclomaticComplexity:
|
19
|
-
Max:
|
19
|
+
Max: 8
|
20
20
|
|
21
21
|
Metrics/PerceivedComplexity:
|
22
|
-
Max:
|
22
|
+
Max: 9
|
23
23
|
|
24
24
|
Metrics/ClassLength:
|
25
25
|
Exclude:
|
@@ -29,7 +29,7 @@ Metrics/LineLength:
|
|
29
29
|
Max: 120
|
30
30
|
|
31
31
|
Metrics/MethodLength:
|
32
|
-
Max:
|
32
|
+
Max: 17
|
33
33
|
|
34
34
|
Metrics/ModuleLength:
|
35
35
|
CountComments: false
|
@@ -39,9 +39,18 @@ Metrics/ModuleLength:
|
|
39
39
|
Style/Documentation:
|
40
40
|
Enabled: false
|
41
41
|
|
42
|
+
RSpec/AnyInstance:
|
43
|
+
Enabled: false
|
44
|
+
|
42
45
|
RSpec/ExampleLength:
|
43
46
|
Enabled: false
|
44
47
|
|
48
|
+
RSpec/DescribeClass:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
RSpec/FilePath:
|
52
|
+
Enabled: false
|
53
|
+
|
45
54
|
RSpec/MultipleExpectations:
|
46
55
|
Enabled: false
|
47
56
|
|
@@ -8,6 +8,31 @@ module SauceBindings
|
|
8
8
|
def camel_case(str)
|
9
9
|
str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
10
10
|
end
|
11
|
+
|
12
|
+
def chrome(**opts)
|
13
|
+
opts[:browser_name] = 'chrome'
|
14
|
+
Options.new(**opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def edge(**opts)
|
18
|
+
opts[:browser_name] = 'MicrosoftEdge'
|
19
|
+
Options.new(**opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
def firefox(**opts)
|
23
|
+
opts[:browser_name] = 'firefox'
|
24
|
+
Options.new(**opts)
|
25
|
+
end
|
26
|
+
|
27
|
+
def ie(**opts)
|
28
|
+
opts[:browser_name] = 'internet explorer'
|
29
|
+
Options.new(**opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
def safari(**opts)
|
33
|
+
opts[:browser_name] = 'safari'
|
34
|
+
Options.new(**opts)
|
35
|
+
end
|
11
36
|
end
|
12
37
|
|
13
38
|
BROWSER_NAMES = {Selenium::WebDriver::Chrome::Options => 'chrome',
|
@@ -145,8 +170,11 @@ module SauceBindings
|
|
145
170
|
# CircleCI
|
146
171
|
elsif ENV['CIRCLE_JOB']
|
147
172
|
"#{ENV['CIRCLE_JOB']}: #{ENV['CIRCLE_BUILD_NUM']}"
|
173
|
+
# GitHub Actions
|
174
|
+
elsif ENV['GITHUB_SHA']
|
175
|
+
"#{ENV['GITHUB_WORKFLOW']}: #{ENV['GITHUB_SHA']}"
|
148
176
|
# Gitlab
|
149
|
-
elsif ENV['
|
177
|
+
elsif ENV['CI_JOB_NAME']
|
150
178
|
"#{ENV['CI_JOB_NAME']}: #{ENV['CI_JOB_ID']}"
|
151
179
|
# Team City
|
152
180
|
elsif ENV['TEAMCITY_PROJECT_NAME']
|
@@ -7,7 +7,8 @@ module SauceBindings
|
|
7
7
|
class Session
|
8
8
|
DATA_CENTERS = {US_WEST: 'ondemand.us-west-1.saucelabs.com',
|
9
9
|
US_EAST: 'ondemand.us-east-1.saucelabs.com',
|
10
|
-
EU_CENTRAL: 'ondemand.eu-central-1.saucelabs.com'
|
10
|
+
EU_CENTRAL: 'ondemand.eu-central-1.saucelabs.com',
|
11
|
+
APAC_SOUTHEAST: 'ondemand.apac-southeast-1.saucelabs.com'}.freeze
|
11
12
|
|
12
13
|
attr_writer :url
|
13
14
|
attr_reader :driver, :options, :data_center
|
@@ -36,7 +37,7 @@ module SauceBindings
|
|
36
37
|
SauceWhisk::Jobs.change_status(@driver.session_id, result)
|
37
38
|
# Add output for the Sauce OnDemand Jenkins plugin
|
38
39
|
# The first print statement will automatically populate links on Jenkins to Sauce
|
39
|
-
# The second print statement will output the job link to logging/console
|
40
|
+
# The second print statement will output the job link to logging/console
|
40
41
|
puts "SauceOnDemandSessionID=#{@driver.session_id} job-name=#{@options.name}"
|
41
42
|
puts "Test Job Link: https://app.saucelabs.com/tests/#{@driver.session_id}"
|
42
43
|
@driver.quit
|
@@ -44,7 +45,7 @@ module SauceBindings
|
|
44
45
|
|
45
46
|
def data_center=(data_center)
|
46
47
|
unless DATA_CENTERS.key?(data_center)
|
47
|
-
msg = "#{data_center} is an invalid data center; specify
|
48
|
+
msg = "#{data_center} is an invalid data center; specify one of: #{DATA_CENTERS.keys}"
|
48
49
|
raise ArgumentError, msg
|
49
50
|
end
|
50
51
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Basic Options' do
|
7
|
+
before { WebMock.allow_net_connect! }
|
8
|
+
|
9
|
+
it 'creates session' do
|
10
|
+
# 1. Create a SauceOptions instance with the 3 primary parameters
|
11
|
+
sauce_options = SauceBindings::Options.firefox(browser_version: '73.0',
|
12
|
+
platform_name: 'Windows 8')
|
13
|
+
|
14
|
+
# 2. Create Session object with SauceOptions object instance
|
15
|
+
session = SauceBindings::Session.new(sauce_options)
|
16
|
+
|
17
|
+
# 3. Start Session to get the Driver
|
18
|
+
driver = session.start
|
19
|
+
|
20
|
+
# 4. Use the driver in your tests just like normal
|
21
|
+
driver.get('https://www.saucedemo.com/')
|
22
|
+
|
23
|
+
# 5. Stop the Session with whether the test passed or failed
|
24
|
+
session.stop(true)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Browser Options' do
|
7
|
+
before { WebMock.allow_net_connect! }
|
8
|
+
|
9
|
+
it 'creates session' do
|
10
|
+
# 1. Create Selenium Browser Options instance
|
11
|
+
browser_options = Selenium::WebDriver::Firefox::Options.new(args: ['--foo'])
|
12
|
+
|
13
|
+
# 2. Create Sauce Options object with the Browser Options object instance
|
14
|
+
sauce_options = SauceBindings::Options.firefox(selenium_options: browser_options)
|
15
|
+
|
16
|
+
# 3. Create Session object with SauceOptions object instance
|
17
|
+
session = SauceBindings::Session.new(sauce_options)
|
18
|
+
|
19
|
+
# 4. Start Session to get the Driver
|
20
|
+
driver = session.start
|
21
|
+
|
22
|
+
# 5. Use the driver in your tests just like normal
|
23
|
+
driver.get('https://www.saucedemo.com/')
|
24
|
+
|
25
|
+
# 6. Stop the Session with whether the test passed or failed
|
26
|
+
session.stop(true)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Create Session' do
|
7
|
+
before { WebMock.allow_net_connect! }
|
8
|
+
|
9
|
+
it 'starts session' do
|
10
|
+
# 1. Create Session object with the defaults
|
11
|
+
session = SauceBindings::Session.new
|
12
|
+
|
13
|
+
# 2. Start Session to get the Driver
|
14
|
+
driver = session.start
|
15
|
+
|
16
|
+
# 3. Use the driver in your tests just like normal
|
17
|
+
driver.get('https://www.saucedemo.com/')
|
18
|
+
|
19
|
+
# 4. Stop the Session with whether the test passed or failed
|
20
|
+
session.stop(true)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Create Session' do
|
7
|
+
before { WebMock.allow_net_connect! }
|
8
|
+
|
9
|
+
it 'starts session' do
|
10
|
+
# 1. Create Session object with the desired Data Center
|
11
|
+
session = SauceBindings::Session.new(data_center: :EU_CENTRAL)
|
12
|
+
|
13
|
+
# 2. Start Session to get the Driver
|
14
|
+
driver = session.start
|
15
|
+
|
16
|
+
# 3. Use the driver in your tests just like normal
|
17
|
+
driver.get('https://www.saucedemo.com/')
|
18
|
+
|
19
|
+
# 4. Stop the Session with whether the test passed or failed
|
20
|
+
session.stop(true)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sauce_bindings'
|
4
|
+
require 'rspec'
|
5
|
+
|
6
|
+
describe 'Sauce Options' do
|
7
|
+
before { WebMock.allow_net_connect! }
|
8
|
+
|
9
|
+
it 'creates session' do
|
10
|
+
# 1. Create a SauceOptions instance with Sauce Labs Specific Options
|
11
|
+
sauce_options = SauceBindings::Options.firefox(extended_debugging: true,
|
12
|
+
idle_timeout: 100,
|
13
|
+
time_zone: 'Alaska')
|
14
|
+
|
15
|
+
# 2. Create Session object with SauceOptions object instance
|
16
|
+
session = SauceBindings::Session.new(sauce_options)
|
17
|
+
|
18
|
+
# 3. Start Session to get the Driver
|
19
|
+
driver = session.start
|
20
|
+
|
21
|
+
# 4. Use the driver in your tests just like normal
|
22
|
+
driver.get('https://www.saucedemo.com/')
|
23
|
+
|
24
|
+
# 5. Stop the Session with whether the test passed or failed
|
25
|
+
session.stop(true)
|
26
|
+
end
|
27
|
+
end
|
data/spec/unit/options_spec.rb
CHANGED
@@ -10,6 +10,56 @@ module SauceBindings
|
|
10
10
|
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
11
11
|
end
|
12
12
|
|
13
|
+
describe 'self#chrome' do
|
14
|
+
it 'creates Options for Chrome' do
|
15
|
+
options = Options.chrome
|
16
|
+
|
17
|
+
expect(options.browser_name).to eq 'chrome'
|
18
|
+
expect(options.browser_version).to eq 'latest'
|
19
|
+
expect(options.platform_name).to eq 'Windows 10'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'self#edge' do
|
24
|
+
it 'creates Options for Edge' do
|
25
|
+
options = Options.edge
|
26
|
+
|
27
|
+
expect(options.browser_name).to eq 'MicrosoftEdge'
|
28
|
+
expect(options.browser_version).to eq 'latest'
|
29
|
+
expect(options.platform_name).to eq 'Windows 10'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'self#firefox' do
|
34
|
+
it 'creates Options for Firefox' do
|
35
|
+
options = Options.firefox
|
36
|
+
|
37
|
+
expect(options.browser_name).to eq 'firefox'
|
38
|
+
expect(options.browser_version).to eq 'latest'
|
39
|
+
expect(options.platform_name).to eq 'Windows 10'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'self#ie' do
|
44
|
+
it 'creates Options for Chrome' do
|
45
|
+
options = Options.ie
|
46
|
+
|
47
|
+
expect(options.browser_name).to eq 'internet explorer'
|
48
|
+
expect(options.browser_version).to eq 'latest'
|
49
|
+
expect(options.platform_name).to eq 'Windows 10'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'self#safari' do
|
54
|
+
it 'creates Options for Safari' do
|
55
|
+
options = Options.safari
|
56
|
+
|
57
|
+
expect(options.browser_name).to eq 'safari'
|
58
|
+
expect(options.browser_version).to eq 'latest'
|
59
|
+
expect(options.platform_name).to eq 'Windows 10'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
13
63
|
describe '#new' do
|
14
64
|
let(:default_options) do
|
15
65
|
{'browserName' => 'chrome',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sauce_bindings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -177,6 +177,11 @@ files:
|
|
177
177
|
- lib/sauce_bindings/session.rb
|
178
178
|
- lib/sauce_bindings/version.rb
|
179
179
|
- sauce_bindings.gemspec
|
180
|
+
- spec/examples/basic_options_spec.rb
|
181
|
+
- spec/examples/browser_options_spec.rb
|
182
|
+
- spec/examples/create_session_spec.rb
|
183
|
+
- spec/examples/data_center_spec.rb
|
184
|
+
- spec/examples/sauce_options_spec.rb
|
180
185
|
- spec/integration/desktop_spec.rb
|
181
186
|
- spec/options.yml
|
182
187
|
- spec/spec_helper.rb
|
@@ -207,6 +212,11 @@ signing_key:
|
|
207
212
|
specification_version: 4
|
208
213
|
summary: Simple interface for interacting with Sauce Labs.
|
209
214
|
test_files:
|
215
|
+
- spec/examples/basic_options_spec.rb
|
216
|
+
- spec/examples/browser_options_spec.rb
|
217
|
+
- spec/examples/create_session_spec.rb
|
218
|
+
- spec/examples/data_center_spec.rb
|
219
|
+
- spec/examples/sauce_options_spec.rb
|
210
220
|
- spec/integration/desktop_spec.rb
|
211
221
|
- spec/options.yml
|
212
222
|
- spec/spec_helper.rb
|