simple_sauce 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 459ade86f96fd32db8ec9a44670c1d25676790b0ad4ab5b1cc517831b7e4ccdc
4
+ data.tar.gz: eac33556eaa40e1d672f246a6cd59603662b5131280aa6030672d6f82a2de42d
5
+ SHA512:
6
+ metadata.gz: 60b6e3ab41402f963e7f4a7085c7413a11788aa087b49a57d63f64bfe5c0945c74922f786aef84a1f298b37b3cd03125e8295222a1a244b338413568179d0cfb
7
+ data.tar.gz: a03a428ecff642195fc148f96a207f2106977dc909f26ed5576bbfcc923a8fb71a0a2ceeb6c16521884f8c6c97d21998123b0ddec7bc39194e2dbbf4b40ffeb2
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea/
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ #ignore Gemfile.lock
15
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,36 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5.3
3
+
4
+ require:
5
+ - rubocop-rspec
6
+ - rubocop-performance
7
+
8
+ Layout/SpaceInsideHashLiteralBraces:
9
+ EnforcedStyle: no_space
10
+
11
+ Metrics/BlockLength:
12
+ Exclude:
13
+ - "**/*_spec.rb"
14
+
15
+ Metrics/LineLength:
16
+ Max: 120
17
+
18
+ Metrics/MethodLength:
19
+ Max: 13
20
+
21
+ Metrics/ModuleLength:
22
+ CountComments: false
23
+ Exclude:
24
+ - 'spec/**/*'
25
+
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ RSpec/ExampleLength:
30
+ Enabled: false
31
+
32
+ RSpec/MultipleExpectations:
33
+ Enabled: false
34
+
35
+ RSpec/DescribedClass:
36
+ EnforcedStyle: explicit
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in simple_sauce.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Titus Fortner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # SimpleSauce
2
+ ## Ruby's Sauce Labs Bindings!
3
+
4
+ This gem is intended as a way to easily interact with Sauce Labs in an obvious and straightforward way.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'simple_sauce'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install simple_sauce
21
+
22
+ ## Usage
23
+
24
+ `SimpleSauce` is broken into two main components, `Options` and `Session`
25
+
26
+ ### Options class
27
+ `Options` provides an easy interface to the Sauce Labs specific settings you want in your tests.
28
+
29
+ If you want the default settings (the latest Chrome version on Windows 10) with no other settings,
30
+ this is all the code you need:
31
+ ```
32
+ sauce_opts = SimpleSauce::Options.new
33
+ ```
34
+ To specify additional
35
+ [Sauce Labs supported settings](https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options),
36
+ simply pass these in as a `Hash`, or use an accessor:
37
+ ```
38
+ sauce_options = {screen_resolution: '1080x720',
39
+ browser_name: 'Firefox',
40
+ platform_name: 'Mac OS'}
41
+ sauce_opts = SimpleSauce::Options.new(sauce_options)
42
+ sauce_opts.idle_timeout = 100
43
+ ```
44
+ if you have additional browser specific settings, or
45
+ [webdriver w3c spec compliant settings](http://w3c.github.io/webdriver/webdriver-spec.html#capabilities), in
46
+ Selenium 3.x you need to generate each of these separately; see the `Session` class below for how to use it:
47
+ ```
48
+ sauce_options = SimpleSauce::Options.new(screen_resolution: '1080x720',
49
+ browser_name: 'Firefox',
50
+ platform_name: 'Mac OS')
51
+
52
+ selenium_options = Selenium::WebDriver::Remote::Capabilities.new(accept_insecure_certs: false,
53
+ page_load_strategy: 'eager'}
54
+
55
+ browser_options = Selenium::WebDriver::Firefox::Options.new(args: ['-foo'])
56
+ ```
57
+
58
+ ### Session class
59
+ #### Intializing a Session
60
+ `Session` class gets initialized with an `Options` instance. If you want the
61
+ default settings (latest Chrome version on Windows 10), you don't even need to use an `Options` instance:
62
+ ```ruby
63
+ @session = SimpleSauce::Session.new
64
+ ```
65
+ If you want something other than the default, create a Sauce `Option` instance (as generated in the section above,
66
+ then pass it into the constructor:
67
+ ```ruby
68
+ @session = SimpleSauce::Session.new(sauce_opts)
69
+ ```
70
+ If you also have Selenium or Browser options as described above, then you pass them in with an `Array` like so:
71
+ ```ruby
72
+ @session = SimpleSauce::Session.new([sauce_opts, se_opts, browser_opts])
73
+ ```
74
+
75
+ #### Creating a driver instance
76
+ The `#start` method is required, and will return a `Selenium::WebDriver::<Browser>::Driver` instance,
77
+ and the `#stop` method will automatically quit the driver as well as ending the Sauce Labs session.
78
+ ```ruby
79
+ session = SimpleSauce::Session.new
80
+ driver = session.start
81
+ # Use the driver
82
+ session.stop
83
+ ```
84
+ Note that the `Driver` instance can also be obtained at any time with the `#driver` method:
85
+ ```ruby
86
+ session = SimpleSauce::Session.new
87
+ session.start
88
+ driver = session.driver
89
+ # Use the driver
90
+ session.stop
91
+ ```
92
+ #### Additional Session methods
93
+ We have a number of features we plan to add; stay tuned to see what additional features are made available. If you
94
+ have any request, please contact the Sauce Labs Solution Architect team.
95
+
96
+ ## Contributing
97
+
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sauce/simple_sauce.
99
+ This project is intended to be a safe, welcoming space for collaboration,
100
+ and contributors are expected to adhere to the
101
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
102
+
103
+ ## License
104
+
105
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
106
+
107
+ ## Code of Conduct
108
+
109
+ Everyone interacting in the SimpleSauce project’s codebases, issue trackers, chat rooms and mailing lists
110
+ is expected to follow the [code of conduct](https://github.com/saucelabs/simple_sauce/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simple_sauce/version'
4
+ require 'simple_sauce/options'
5
+ require 'simple_sauce/session'
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleSauce
4
+ class Options
5
+ class << self
6
+ def camel_case(str)
7
+ str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
8
+ end
9
+ end
10
+
11
+ W3C = %i[browser_name platform_name browser_version].freeze
12
+
13
+ SAUCE = %i[access_key appium_version avoid_proxy build capture_html chromedriver_version command_timeout
14
+ crmuxdriver_version custom_data disable_popup_handler extended_debugging firefox_adapter_version
15
+ firefox_profile_url idle_timeout iedriver_version max_duration name parent_tunnel passed prerun
16
+ prevent_requeue priority proxy_host public record_logs record_screenshots record_video
17
+ restricted_public_info screen_resolution selenium_version source tags time_zone tunnel_identifier
18
+ username video_upload_on_pass capture_performance].freeze
19
+
20
+ def initialize(**opts)
21
+ @browser_name = 'chrome'
22
+ @platform_name = 'Windows 10'
23
+ @browser_version = 'latest'
24
+
25
+ create_variables(SAUCE + W3C, opts)
26
+ end
27
+
28
+ def capabilities
29
+ caps = W3C.each_with_object({}) do |key, hash|
30
+ value = send(key)
31
+ hash[self.class.camel_case(key)] = value if value
32
+ end
33
+ caps['sauce:options'] = {}
34
+ SAUCE.each do |key|
35
+ value = send(key)
36
+ caps['sauce:options'][self.class.camel_case(key)] = value unless value.nil?
37
+ end
38
+ caps
39
+ end
40
+
41
+ alias as_json capabilities
42
+
43
+ private
44
+
45
+ def create_variables(key, opts)
46
+ key.each do |option|
47
+ self.class.__send__(:attr_accessor, option)
48
+ next unless opts.key?(option)
49
+
50
+ instance_variable_set("@#{option}", opts.delete(option))
51
+ end
52
+ return if opts.empty?
53
+
54
+ raise ArgumentError, "#{opts.inspect} are not valid parameters for Options class"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'sauce_whisk'
4
+ require 'selenium-webdriver'
5
+
6
+ module SimpleSauce
7
+ class Session
8
+ attr_writer :username, :access_key, :url
9
+ attr_reader :driver, :options, :data_center
10
+
11
+ def initialize(options = nil)
12
+ @options = options || Options.new
13
+ raise unless [Array, Options].include?(@options.class)
14
+
15
+ self.data_center = :US_WEST
16
+ @username = ENV['SAUCE_USERNAME']
17
+ @access_key = ENV['SAUCE_ACCESS_KEY']
18
+ end
19
+
20
+ def start
21
+ @driver = Selenium::WebDriver.for :remote, url: url, desired_capabilities: options.capabilities
22
+ end
23
+
24
+ def stop(result)
25
+ SauceWhisk::Jobs.change_status(@driver.session_id, result)
26
+ @driver.quit
27
+ end
28
+
29
+ def data_center=(data_center)
30
+ @data_center = data_center
31
+ @dc_url = case data_center
32
+ when :US_WEST
33
+ 'ondemand.saucelabs.com:443/wd/hub'
34
+ when :US_EAST
35
+ 'us-east-1.saucelabs.com:443/wd/hub'
36
+ when :EU_VDC
37
+ 'ondemand.eu-central-1.saucelabs.com:443/wd/hub'
38
+ else
39
+ msg = "#{data_center} is an invalid data center; specify :US_WEST, :US_EAST or :EU_VDC"
40
+ raise ::ArgumentError, msg
41
+ end
42
+ SauceWhisk.data_center = @data_center
43
+ end
44
+
45
+ def url
46
+ raise ArgumentError, "No user name was set; use `ENV['SAUCE_USERNAME']` or `Session#username=`" unless @username
47
+ unless @access_key
48
+ raise ArgumentError, "No access key was set; use `ENV['SAUCE_ACCESS_KEY']` or `Session#access_key=`"
49
+ end
50
+
51
+ @url ||= "https://#{@username}:#{@access_key}@#{@dc_url}"
52
+ end
53
+
54
+ def to_selenium
55
+ {url: url, desired_capabilities: Array(@options).map(&:as_json).inject(:merge)}
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleSauce
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
5
+ require 'simple_sauce/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'simple_sauce'
9
+ spec.version = SimpleSauce::VERSION
10
+ spec.authors = ['Titus Fortner']
11
+ spec.email = ['titusfortner@gmail.com']
12
+
13
+ spec.summary = 'Simple interface for interacting with Sauce Labs.'
14
+ spec.description = 'Reduces complexity in user code for running Selenium tests on Sauce Labs'
15
+ spec.homepage = 'https://github.com/saucelabs/simple_sauce'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files`.split("\n")
19
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 2.0'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'rubocop', '~>0.66'
26
+ spec.add_development_dependency 'rubocop-performance'
27
+ spec.add_development_dependency 'rubocop-rspec', '~>1.32'
28
+ spec.add_development_dependency 'webmock', '~> 3.5'
29
+
30
+ spec.add_runtime_dependency 'selenium-webdriver', '~> 3.0'
31
+ spec.add_runtime_dependency 'sauce_whisk'
32
+
33
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ module SimpleSauce
6
+ describe Options do
7
+ describe '#new' do
8
+ let(:default_options) do
9
+ {'browserName' => 'chrome',
10
+ 'browserVersion' => 'latest',
11
+ 'platformName' => 'Windows 10',
12
+ 'sauce:options' => {}}
13
+ end
14
+
15
+ it 'uses latest Chrome version on Windows 10 by default' do
16
+ sauce_opts = SimpleSauce::Options.new
17
+
18
+ expect(sauce_opts.capabilities).to eq(default_options)
19
+ end
20
+
21
+ it 'accepts provided values for browser, browser version and platform name' do
22
+ options = Options.new(browser_name: 'firefox',
23
+ browser_version: '123',
24
+ platform_name: 'Mac')
25
+
26
+ expect(options.browser_name).to eq 'firefox'
27
+ expect(options.browser_version).to eq '123'
28
+ expect(options.platform_name).to eq 'Mac'
29
+ end
30
+
31
+ it 'accepts Sauce Lab specific settings' do
32
+ sauce_options = {max_duration: 1,
33
+ command_timeout: 2,
34
+ idle_timeout: 3,
35
+ name: 'foo',
36
+ build: 'bar',
37
+ tags: %w[foo bar],
38
+ parent_tunnel: 'bar',
39
+ tunnel_identifier: 'foobar',
40
+ screen_resolution: '10x10',
41
+ time_zone: 'Foo',
42
+ extended_debugging: true,
43
+ capture_performance: true,
44
+ record_video: false,
45
+ video_upload_on_pass: false,
46
+ record_screenshots: false,
47
+ record_logs: false,
48
+ username: 'foo',
49
+ access_key: '1234',
50
+ passed: true}
51
+
52
+ sauce_opts = SimpleSauce::Options.new(sauce_options)
53
+
54
+ expected_options = default_options.merge('sauce:options' => {})
55
+ sauce_options.each do |key, value|
56
+ expected_options['sauce:options'][SimpleSauce::Options.send(:camel_case, key.to_s)] = value
57
+ end
58
+
59
+ expect(sauce_opts.capabilities).to eq(expected_options)
60
+ end
61
+
62
+ it 'raises ArgumentError if parameter is not recognized as valid' do
63
+ expect { SimpleSauce::Options.new(foo: 'bar') }.to raise_exception(ArgumentError)
64
+ end
65
+ end
66
+
67
+ it 'uses accessor' do
68
+ sauce_opts = SimpleSauce::Options.new
69
+ sauce_opts.browser_name = 'firefox'
70
+ sauce_opts.idle_timeout = 3
71
+
72
+ expect(sauce_opts.capabilities).to eq('browserName' => 'firefox',
73
+ 'browserVersion' => 'latest',
74
+ 'platformName' => 'Windows 10',
75
+ 'sauce:options' => {'idleTimeout' => 3})
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,179 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'webmock/rspec'
5
+
6
+ module SimpleSauce
7
+ describe Session do
8
+ let(:valid_response) do
9
+ {status: 200,
10
+ body: {value: {sessionId: 0, capabilities: Selenium::WebDriver::Remote::Capabilities.chrome}}.to_json,
11
+ headers: {"content_type": 'application/json'}}
12
+ end
13
+ let(:default_capabilities) do
14
+ {browserName: 'chrome',
15
+ platformName: 'Windows 10',
16
+ browserVersion: 'latest',
17
+ 'sauce:options': {}}
18
+ end
19
+
20
+ def expect_request(body: nil, endpoint: nil)
21
+ body = (body || {desiredCapabilities: default_capabilities,
22
+ capabilities: {firstMatch: [default_capabilities]}}).to_json
23
+ endpoint ||= 'https://ondemand.saucelabs.com/wd/hub/session'
24
+ stub_request(:post, endpoint).with(body: body).to_return(valid_response)
25
+ end
26
+
27
+ before do
28
+ ENV['SAUCE_USERNAME'] = 'foo'
29
+ ENV['SAUCE_ACCESS_KEY'] = '123'
30
+ end
31
+
32
+ after do
33
+ ENV.delete 'SAUCE_USERNAME'
34
+ ENV.delete 'SAUCE_ACCESS_KEY'
35
+ end
36
+
37
+ describe '#new' do
38
+ it 'uses latest Chrome version and Windows 10 by default' do
39
+ session = SimpleSauce::Session.new
40
+
41
+ expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
42
+ desired_capabilities: {'browserName' => 'chrome',
43
+ 'browserVersion' => 'latest',
44
+ 'platformName' => 'Windows 10',
45
+ 'sauce:options' => {}}}
46
+ expect(session.to_selenium).to eq expected_results
47
+ end
48
+
49
+ it 'uses provided Options class' do
50
+ sauce_opts = Options.new(browser_version: '123',
51
+ platform_name: 'Mac',
52
+ idle_timeout: 4)
53
+ session = SimpleSauce::Session.new(sauce_opts)
54
+
55
+ expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
56
+ desired_capabilities: {'browserName' => 'chrome',
57
+ 'browserVersion' => '123',
58
+ 'platformName' => 'Mac',
59
+ 'sauce:options' => {'idleTimeout' => 4}}}
60
+ expect(session.to_selenium).to eq expected_results
61
+ end
62
+
63
+ it 'uses provided Options with Selenium Capabilities and Options classes' do
64
+ sauce_options = {idle_timeout: 4,
65
+ browser_name: 'Firefox',
66
+ platform_name: 'Mac OS'}
67
+
68
+ se_options = {accept_insecure_certs: false,
69
+ page_load_strategy: 'eager'}
70
+
71
+ browser_options = {args: ['-foo']}
72
+
73
+ sauce_opts = SimpleSauce::Options.new(sauce_options)
74
+ se_opts = Selenium::WebDriver::Remote::Capabilities.firefox(se_options)
75
+ browser_opts = Selenium::WebDriver::Firefox::Options.new(browser_options)
76
+
77
+ session = SimpleSauce::Session.new([sauce_opts, se_opts, browser_opts])
78
+
79
+ expected_capabilities = {'browserName' => 'firefox',
80
+ 'platformName' => 'Mac OS',
81
+ 'browserVersion' => 'latest',
82
+ 'acceptInsecureCerts' => false,
83
+ 'pageLoadStrategy' => 'eager',
84
+ 'moz:firefoxOptions' => {args: ['-foo']},
85
+ 'sauce:options' => {'idleTimeout' => 4}}
86
+
87
+ oss_capabilities = {'cssSelectorsEnabled' => false,
88
+ 'javascriptEnabled' => false,
89
+ 'marionette' => true,
90
+ 'nativeEvents' => false,
91
+ 'platform' => 'ANY',
92
+ 'rotatable' => false,
93
+ 'takesScreenshot' => false,
94
+ 'timeouts' => {},
95
+ 'version' => ''}
96
+
97
+ expected_results = {url: 'https://foo:123@ondemand.saucelabs.com:443/wd/hub',
98
+ desired_capabilities: expected_capabilities.merge(oss_capabilities)}
99
+ expect(session.to_selenium).to eq expected_results
100
+ end
101
+
102
+ it 'defaults to US West data Center' do
103
+ session = SimpleSauce::Session.new
104
+ expect(session.data_center).to eq :US_WEST
105
+ end
106
+ end
107
+
108
+ describe '#start' do
109
+ it 'starts the session and returns Selenium Driver instance' do
110
+ expect_request
111
+
112
+ driver = SimpleSauce::Session.new.start
113
+ expect(driver).to be_a Selenium::WebDriver::Driver
114
+ end
115
+
116
+ it 'raises exception if no username set' do
117
+ ENV.delete('SAUCE_USERNAME')
118
+
119
+ expect { SimpleSauce::Session.new.start }.to raise_exception(ArgumentError)
120
+ end
121
+
122
+ it 'raises exception if no access key set' do
123
+ ENV.delete('SAUCE_ACCESS_KEY')
124
+
125
+ expect { SimpleSauce::Session.new.start }.to raise_exception(ArgumentError)
126
+ end
127
+ end
128
+
129
+ describe '#stop' do
130
+ it 'quits the driver' do
131
+ driver = instance_double(Selenium::WebDriver::Remote::Driver, session_id: '1234')
132
+ allow(Selenium::WebDriver::Driver).to receive(:for).and_return(driver)
133
+ allow(driver).to receive :quit
134
+ allow(SauceWhisk::Jobs).to receive(:change_status).with('1234', true)
135
+
136
+ session = SimpleSauce::Session.new
137
+
138
+ session.start
139
+ session.stop(true)
140
+
141
+ expect(driver).to have_received(:quit)
142
+ expect(SauceWhisk::Jobs).to have_received(:change_status).with('1234', true)
143
+ end
144
+ end
145
+
146
+ describe '#data_center=' do
147
+ it 'overrides default value for data center' do
148
+ session = SimpleSauce::Session.new
149
+ session.data_center = :US_EAST
150
+
151
+ expect(session.url).to eq('https://foo:123@us-east-1.saucelabs.com:443/wd/hub')
152
+ end
153
+
154
+ it 'raises exception if data center is invalid' do
155
+ session = SimpleSauce::Session.new
156
+
157
+ expect { session.data_center = :FOO }.to raise_exception(ArgumentError)
158
+ end
159
+ end
160
+
161
+ describe '#username=' do
162
+ it 'accepts provided username' do
163
+ session = SimpleSauce::Session.new
164
+ session.username = 'name'
165
+
166
+ expect(session.url).to eq('https://name:123@ondemand.saucelabs.com:443/wd/hub')
167
+ end
168
+ end
169
+
170
+ describe '#access_key=' do
171
+ it 'accepts provided access key' do
172
+ session = SimpleSauce::Session.new
173
+ session.access_key = '456'
174
+
175
+ expect(session.url).to eq('https://foo:456@ondemand.saucelabs.com:443/wd/hub')
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simple_sauce'
4
+ require 'rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |c|
8
+ c.syntax = :expect
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_sauce
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Titus Fortner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.66'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.66'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.32'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.32'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: selenium-webdriver
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: sauce_whisk
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Reduces complexity in user code for running Selenium tests on Sauce Labs
140
+ email:
141
+ - titusfortner@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rubocop.yml"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - lib/simple_sauce.rb
155
+ - lib/simple_sauce/options.rb
156
+ - lib/simple_sauce/session.rb
157
+ - lib/simple_sauce/version.rb
158
+ - simple_sauce.gemspec
159
+ - spec/options_spec.rb
160
+ - spec/session_spec.rb
161
+ - spec/spec_helper.rb
162
+ homepage: https://github.com/saucelabs/simple_sauce
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubygems_version: 3.0.3
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: Simple interface for interacting with Sauce Labs.
185
+ test_files:
186
+ - spec/options_spec.rb
187
+ - spec/session_spec.rb
188
+ - spec/spec_helper.rb