sauce_bindings 1.0.0.beta1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/sauce_bindings/session.rb +8 -3
- data/lib/sauce_bindings/version.rb +1 -1
- data/spec/integration/desktop_spec.rb +41 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/{capybara_session_spec.rb → unit/capybara_session_spec.rb} +8 -14
- data/spec/{options_spec.rb → unit/options_spec.rb} +3 -5
- data/spec/{session_spec.rb → unit/session_spec.rb} +9 -17
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e197c96695967d753e6c60e80e64a4845d10d5f06fbaf1dcf38c1a30d4aa9dc3
|
4
|
+
data.tar.gz: 42fe96bb1a78b8f3b2d0560151d5b52a73ca6cf56298bd8a54d63046e3b5450b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f8a82b1d8029f0820fb79190529012c3a10e1dc9481ad8bc7a9023f5ee5089f90673438d4f7f49493c52f6b1d8acd586e1a536cc183060d4246b22ba8463361
|
7
|
+
data.tar.gz: beccada13701765b1cf497b8575c5cfd1688338bb9d1953ba990d0c107092512553285f525bfbe35364cb1a3fded8a1b945df42438ad1b24fc12f22b9573a748
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#
|
2
|
-
##
|
1
|
+
# Sauce Bindings
|
2
|
+
## A library for interacting with Sauce Labs using Ruby
|
3
3
|
|
4
|
-
This gem is intended as a way to
|
4
|
+
This gem is intended as a way to interact with Sauce Labs in an obvious and straightforward way.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -27,7 +27,7 @@ To run tests for the Ruby Sauce Bindings, execute
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
`
|
30
|
+
`SauceBindings` is broken into two main components, `Options` and `Session`
|
31
31
|
|
32
32
|
### Options class
|
33
33
|
`Options` provides an easy interface to the Sauce Labs specific settings you want in your tests.
|
@@ -35,7 +35,7 @@ To run tests for the Ruby Sauce Bindings, execute
|
|
35
35
|
If you want the default settings (the latest Chrome version on Windows 10) with no other settings,
|
36
36
|
this is all the code you need:
|
37
37
|
```
|
38
|
-
sauce_opts =
|
38
|
+
sauce_opts = SauceBindings::Options.new
|
39
39
|
```
|
40
40
|
To specify additional
|
41
41
|
[Sauce Labs supported settings](https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options),
|
@@ -44,14 +44,14 @@ simply pass these in as a `Hash`, or use an accessor:
|
|
44
44
|
sauce_options = {screen_resolution: '1080x720',
|
45
45
|
browser_name: 'Firefox',
|
46
46
|
platform_name: 'Mac OS'}
|
47
|
-
sauce_opts =
|
47
|
+
sauce_opts = SauceBindings::Options.new(sauce_options)
|
48
48
|
sauce_opts.idle_timeout = 100
|
49
49
|
```
|
50
50
|
if you have additional browser specific settings, or
|
51
51
|
[webdriver w3c spec compliant settings](http://w3c.github.io/webdriver/webdriver-spec.html#capabilities), in
|
52
52
|
Selenium 3.x you need to generate each of these separately; see the `Session` class below for how to use it:
|
53
53
|
```
|
54
|
-
sauce_options =
|
54
|
+
sauce_options = SauceBindings::Options.new(screen_resolution: '1080x720',
|
55
55
|
browser_name: 'Firefox',
|
56
56
|
platform_name: 'Mac OS')
|
57
57
|
|
@@ -112,5 +112,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
112
112
|
|
113
113
|
## Code of Conduct
|
114
114
|
|
115
|
-
Everyone interacting in the
|
115
|
+
Everyone interacting in the SauceBindings project’s codebases, issue trackers, chat rooms and mailing lists
|
116
116
|
is expected to follow the [code of conduct](https://github.com/saucelabs/sauce_bindings/blob/master/CODE_OF_CONDUCT.md).
|
@@ -7,7 +7,7 @@ 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
|
-
|
10
|
+
EU_CENTRAL: 'ondemand.eu-central-1.saucelabs.com'}.freeze
|
11
11
|
|
12
12
|
attr_writer :url
|
13
13
|
attr_reader :driver, :options, :data_center
|
@@ -34,16 +34,21 @@ module SauceBindings
|
|
34
34
|
return if @driver.nil?
|
35
35
|
|
36
36
|
SauceWhisk::Jobs.change_status(@driver.session_id, result)
|
37
|
+
# Add output for the Sauce OnDemand Jenkins plugin
|
38
|
+
# 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
|
+
puts "SauceOnDemandSessionID=#{@driver.session_id} job-name=#{@options.name}"
|
41
|
+
puts "Test Job Link: https://app.saucelabs.com/tests/#{@driver.session_id}"
|
37
42
|
@driver.quit
|
38
43
|
end
|
39
44
|
|
40
45
|
def data_center=(data_center)
|
41
46
|
unless DATA_CENTERS.key?(data_center)
|
42
|
-
msg = "#{data_center} is an invalid data center; specify :US_WEST, :US_EAST or :
|
47
|
+
msg = "#{data_center} is an invalid data center; specify :US_WEST, :US_EAST or :EU_CENTRAL"
|
43
48
|
raise ArgumentError, msg
|
44
49
|
end
|
45
50
|
|
46
|
-
SauceWhisk.data_center = data_center
|
51
|
+
SauceWhisk.data_center = data_center == :EU_CENTRAL ? :EU_VDC : data_center
|
47
52
|
@data_center = data_center
|
48
53
|
end
|
49
54
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module SauceBindings
|
6
|
+
describe Session do
|
7
|
+
describe 'starts with data center' do
|
8
|
+
before { WebMock.allow_net_connect! }
|
9
|
+
|
10
|
+
it 'defaults to US West' do
|
11
|
+
session = Session.new
|
12
|
+
driver = session.start
|
13
|
+
|
14
|
+
expect(driver).not_to be_nil
|
15
|
+
expect(session.url).to include('us-west-1')
|
16
|
+
session.stop(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'executes on US East' do
|
20
|
+
options = Options.new(platform_name: 'Linux')
|
21
|
+
session = Session.new(options, data_center: :US_EAST)
|
22
|
+
driver = session.start
|
23
|
+
|
24
|
+
expect(driver).not_to be_nil
|
25
|
+
expect(session.url).to include('us-east-1')
|
26
|
+
|
27
|
+
session.stop(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'executes on EU Central' do
|
31
|
+
session = Session.new(data_center: :EU_CENTRAL)
|
32
|
+
driver = session.start
|
33
|
+
|
34
|
+
expect(driver).not_to be_nil
|
35
|
+
expect(session.url).to include('eu-central-1')
|
36
|
+
|
37
|
+
session.stop(true)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'webmock/rspec'
|
5
4
|
require 'sauce_bindings/capybara_session'
|
6
5
|
|
7
6
|
module SauceBindings
|
@@ -26,19 +25,14 @@ module SauceBindings
|
|
26
25
|
end
|
27
26
|
|
28
27
|
before do
|
29
|
-
|
30
|
-
|
31
|
-
ENV[
|
32
|
-
ENV['
|
33
|
-
ENV['
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ENV.delete 'BUILD_TAG'
|
38
|
-
ENV.delete 'BUILD_NAME'
|
39
|
-
ENV.delete 'BUILD_NUMBER'
|
40
|
-
ENV.delete 'SAUCE_USERNAME'
|
41
|
-
ENV.delete 'SAUCE_ACCESS_KEY'
|
28
|
+
allow_any_instance_of(Net::HTTP).to receive(:proxy_uri)
|
29
|
+
allow_any_instance_of(Selenium::WebDriver::Remote::Http::Default).to receive(:use_proxy?).and_return(false)
|
30
|
+
allow(ENV).to receive(:[]).with('DISABLE_CAPYBARA_SELENIUM_OPTIMIZATIONS')
|
31
|
+
allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
|
32
|
+
allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
|
33
|
+
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
34
|
+
allow(ENV).to receive(:[]).with('SAUCE_USERNAME').and_return('foo')
|
35
|
+
allow(ENV).to receive(:[]).with('SAUCE_ACCESS_KEY').and_return('123')
|
42
36
|
end
|
43
37
|
|
44
38
|
describe '#new' do
|
@@ -5,13 +5,11 @@ require 'spec_helper'
|
|
5
5
|
module SauceBindings
|
6
6
|
describe Options do
|
7
7
|
before do
|
8
|
-
ENV['BUILD_TAG'
|
9
|
-
ENV['BUILD_NAME'
|
10
|
-
ENV['BUILD_NUMBER'
|
8
|
+
allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
|
9
|
+
allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
|
10
|
+
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
11
11
|
end
|
12
12
|
|
13
|
-
after { ENV.delete 'BUILD_TAG' }
|
14
|
-
|
15
13
|
describe '#new' do
|
16
14
|
let(:default_options) do
|
17
15
|
{'browserName' => 'chrome',
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'webmock/rspec'
|
5
4
|
|
6
5
|
module SauceBindings
|
7
6
|
describe Session do
|
@@ -25,19 +24,12 @@ module SauceBindings
|
|
25
24
|
end
|
26
25
|
|
27
26
|
before do
|
28
|
-
|
29
|
-
ENV['
|
30
|
-
ENV['
|
31
|
-
ENV['
|
32
|
-
ENV['
|
33
|
-
|
34
|
-
|
35
|
-
after do
|
36
|
-
ENV.delete 'BUILD_TAG'
|
37
|
-
ENV.delete 'BUILD_NAME'
|
38
|
-
ENV.delete 'BUILD_NUMBER'
|
39
|
-
ENV.delete 'SAUCE_USERNAME'
|
40
|
-
ENV.delete 'SAUCE_ACCESS_KEY'
|
27
|
+
allow_any_instance_of(Selenium::WebDriver::Remote::Http::Default).to receive(:use_proxy?).and_return(false)
|
28
|
+
allow(ENV).to receive(:[]).with('BUILD_TAG').and_return('')
|
29
|
+
allow(ENV).to receive(:[]).with('BUILD_NAME').and_return('TEMP BUILD')
|
30
|
+
allow(ENV).to receive(:[]).with('BUILD_NUMBER').and_return('11')
|
31
|
+
allow(ENV).to receive(:[]).with('SAUCE_USERNAME').and_return('foo')
|
32
|
+
allow(ENV).to receive(:[]).with('SAUCE_ACCESS_KEY').and_return('123')
|
41
33
|
end
|
42
34
|
|
43
35
|
describe '#new' do
|
@@ -73,7 +65,7 @@ module SauceBindings
|
|
73
65
|
end
|
74
66
|
|
75
67
|
it 'uses provided Data Center' do
|
76
|
-
session = Session.new(data_center: :
|
68
|
+
session = Session.new(data_center: :EU_CENTRAL)
|
77
69
|
|
78
70
|
expected_results = {url: 'https://foo:123@ondemand.eu-central-1.saucelabs.com:443/wd/hub',
|
79
71
|
desired_capabilities: {'browserName' => 'chrome',
|
@@ -117,13 +109,13 @@ module SauceBindings
|
|
117
109
|
end
|
118
110
|
|
119
111
|
it 'raises exception if no username set' do
|
120
|
-
ENV.
|
112
|
+
allow(ENV).to receive(:[]).with('SAUCE_USERNAME')
|
121
113
|
|
122
114
|
expect { Session.new.start }.to raise_exception(ArgumentError)
|
123
115
|
end
|
124
116
|
|
125
117
|
it 'raises exception if no access key set' do
|
126
|
-
ENV.
|
118
|
+
allow(ENV).to receive(:[]).with('SAUCE_ACCESS_KEY')
|
127
119
|
|
128
120
|
expect { Session.new.start }.to raise_exception(ArgumentError)
|
129
121
|
end
|
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.0.0
|
4
|
+
version: 1.0.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: 2020-
|
11
|
+
date: 2020-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -177,11 +177,12 @@ files:
|
|
177
177
|
- lib/sauce_bindings/session.rb
|
178
178
|
- lib/sauce_bindings/version.rb
|
179
179
|
- sauce_bindings.gemspec
|
180
|
-
- spec/
|
180
|
+
- spec/integration/desktop_spec.rb
|
181
181
|
- spec/options.yml
|
182
|
-
- spec/options_spec.rb
|
183
|
-
- spec/session_spec.rb
|
184
182
|
- spec/spec_helper.rb
|
183
|
+
- spec/unit/capybara_session_spec.rb
|
184
|
+
- spec/unit/options_spec.rb
|
185
|
+
- spec/unit/session_spec.rb
|
185
186
|
homepage: https://github.com/saucelabs/sauce_bindings
|
186
187
|
licenses:
|
187
188
|
- MIT
|
@@ -197,17 +198,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
198
|
version: '0'
|
198
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
200
|
requirements:
|
200
|
-
- - "
|
201
|
+
- - ">="
|
201
202
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
203
|
+
version: '0'
|
203
204
|
requirements: []
|
204
205
|
rubygems_version: 3.0.3
|
205
206
|
signing_key:
|
206
207
|
specification_version: 4
|
207
208
|
summary: Simple interface for interacting with Sauce Labs.
|
208
209
|
test_files:
|
209
|
-
- spec/
|
210
|
+
- spec/integration/desktop_spec.rb
|
210
211
|
- spec/options.yml
|
211
|
-
- spec/options_spec.rb
|
212
|
-
- spec/session_spec.rb
|
213
212
|
- spec/spec_helper.rb
|
213
|
+
- spec/unit/capybara_session_spec.rb
|
214
|
+
- spec/unit/options_spec.rb
|
215
|
+
- spec/unit/session_spec.rb
|