special_sauce 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +105 -0
- data/Rakefile +47 -0
- data/lib/special_sauce/capybara.rb +22 -0
- data/lib/special_sauce/driver.rb +67 -0
- data/lib/special_sauce/version.rb +3 -0
- data/lib/special_sauce/watir.rb +15 -0
- data/lib/special_sauce.rb +6 -0
- data/lib/tasks/special_sauce_tasks.rake +4 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c861dcfea52c8836c7d645bd64f009a768a0e2b5
|
4
|
+
data.tar.gz: e2c388db2f03e0e73a3cceb7d39828b9de71e03c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0889cc057466f6ebf0d2da9d269164dc6b7be2353389b632eead937a448bb90e06a0f51daa84336fd4e98f90c3995719935be7ed6457ced98ff31854cfafffe4
|
7
|
+
data.tar.gz: cff53e4e149cef8a6e7511de099d54d3ed18bdf3e7a59009bab60125a2f76939e499b8563a474ce6337afb2efab0499d4998c5beb8a5dd5dae15ebc8d8f16cb6
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Eric Arnold
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# SpecialSauce
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/nativestranger/special_sauce.svg?branch=master)](https://travis-ci.org/nativestranger/special_sauce)
|
4
|
+
|
5
|
+
|
6
|
+
special_sauce makes it easy to run existing [capybara](https://github.com/teamcapybara/capybara) or [watir](https://github.com/watir/watir) based tests against [SauceLabs](https://saucelabs.com/) browsers.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'special_sauce', git: 'https://github.com/nativestranger/special_sauce.git'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Watir Example
|
15
|
+
|
16
|
+
If the authentication ENV variables are set, `special_sauce` will try to setup a remote browser, otherwise default to chrome.
|
17
|
+
|
18
|
+
``` ruby
|
19
|
+
@browser = SpecialSauce::Watir.browser || Watir::Browser.new(:chrome)
|
20
|
+
```
|
21
|
+
|
22
|
+
## Capybara Example
|
23
|
+
|
24
|
+
If the authentication ENV variables are set, `special_sauce` will try to setup a remote browser, otherwise use your capybara default.
|
25
|
+
|
26
|
+
``` ruby
|
27
|
+
@browser = SpecialSauce::Capybara.browser || Capybara.current_session
|
28
|
+
```
|
29
|
+
|
30
|
+
## Environment Variables
|
31
|
+
|
32
|
+
In order to create remote sessions with Sauce Labs, some environment variables must be set.
|
33
|
+
|
34
|
+
**Authentication Variables - Required**
|
35
|
+
|
36
|
+
| Environment Variable | Value |
|
37
|
+
|---------- |:----------------------------------------:|
|
38
|
+
| SAUCE_USER_NAME | your saucelabs username |
|
39
|
+
| SAUCE_API_KEY | saucelabs api key for your username |
|
40
|
+
|
41
|
+
**Optional**
|
42
|
+
|
43
|
+
*The following 3 are set automatically when Jenkin's [Sauce OnDemand Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Sauce+OnDemand+Plugin) is configured to run against **one browser**.*
|
44
|
+
|
45
|
+
| Environment Variable | Value |
|
46
|
+
|---------- |:----------------------------------------:|
|
47
|
+
| SELENIUM_BROWSER | browser name |
|
48
|
+
| SELENIUM_VERSION | browser version |
|
49
|
+
| SELENIUM_PLATFORM | operating system & version |
|
50
|
+
|
51
|
+
OR
|
52
|
+
|
53
|
+
*`SAUCE_ONDEMAND_BROWSERS` is set automatically when Jenkin's [Sauce OnDemand Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Sauce+OnDemand+Plugin) is configured to run against **multiple browsers**.*
|
54
|
+
|
55
|
+
| Environment Variable | Value |
|
56
|
+
|---------- |:----------------------------------------------:|
|
57
|
+
| SAUCE_ONDEMAND_BROWSERS | JSON serialized array of browser capabilities |
|
58
|
+
| CURRENT_BROWSER_ID | **Set this to choose the browser caps from `SAUCE_ONDEMAND_BROWSERS` that should be used. '0' will be the first in the array, '1' will be the second, etc.** |
|
59
|
+
|
60
|
+
## How Browser Capabilities are set.
|
61
|
+
|
62
|
+
When calling `SpecialSauce::Watir.browser` or `SpecialSauce::Capybara.browser` without any arguments, `special_sauce` will use the environment variables above to determine browser capabilities.
|
63
|
+
|
64
|
+
* When `SAUCE_ONDEMAND_BROWSERS` is absent, `SELENIUM_BROWSER`, `SELENIUM_VERSION`, and `SELENIUM_PLATFORM` is used.
|
65
|
+
|
66
|
+
* When `SAUCE_ONDEMAND_BROWSERS` is present, the value is parsed into an array and the caps are set based on `CURRENT_BROWSER_ID`.
|
67
|
+
|
68
|
+
## Adding Browser Capabilities
|
69
|
+
To add additional browser capabilities, use `plus_caps`:
|
70
|
+
|
71
|
+
``` ruby
|
72
|
+
additional_caps = { 'tunnel-identifier' => ENV['TRAVIS_JOB_NUMBER'] }
|
73
|
+
@browser = SpecialSauce::Watir.browser(plus_caps: additional_caps)
|
74
|
+
```
|
75
|
+
|
76
|
+
## Overriding Browser Capabilities
|
77
|
+
To override default browser capabilities, use `using_caps`:
|
78
|
+
|
79
|
+
``` ruby
|
80
|
+
custom_caps = { 'browserName' => 'internet explorer',
|
81
|
+
'version' => '9',
|
82
|
+
'platform' => 'Windows 7' }
|
83
|
+
@browser = SpecialSauce::Watir.browser(using_caps: custom_caps)
|
84
|
+
```
|
85
|
+
|
86
|
+
## Sauce Labs Options
|
87
|
+
|
88
|
+
See [Sauce Lab's Documentation](https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options) for more options such as test name, build number, and screen resolution.
|
89
|
+
|
90
|
+
``` ruby
|
91
|
+
additional_caps = { 'name' => 'my test name', 'screenResolution' => '1280x1024' }
|
92
|
+
@browser = SpecialSauce::Watir.browser(plus_caps: additional_caps)
|
93
|
+
```
|
94
|
+
|
95
|
+
## [Tips for running against multiple browsers](docs/MULTIPLEBROWSERS.md)
|
96
|
+
|
97
|
+
## License
|
98
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
99
|
+
|
100
|
+
# TODO
|
101
|
+
|
102
|
+
* appraise more versions of ruby & versions of capybara & watir.
|
103
|
+
* allow customization of ENV variables?
|
104
|
+
* update description
|
105
|
+
* add contributing version
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'SpecialSauce'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::TestTask.new(:watir_test) do |t|
|
34
|
+
t.libs << 'lib'
|
35
|
+
t.libs << 'test'
|
36
|
+
t.pattern = 'test/sauce/watir_test.rb'
|
37
|
+
t.verbose = false
|
38
|
+
end
|
39
|
+
|
40
|
+
Rake::TestTask.new(:capybara_test) do |t|
|
41
|
+
t.libs << 'lib'
|
42
|
+
t.libs << 'test'
|
43
|
+
t.pattern = 'test/sauce/capybara_test.rb'
|
44
|
+
t.verbose = false
|
45
|
+
end
|
46
|
+
|
47
|
+
task default: :test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SpecialSauce
|
2
|
+
class Capybara < SpecialSauce::Driver
|
3
|
+
|
4
|
+
def self.current_session(options = {})
|
5
|
+
puts "Sauce Labs auth ENV variables not set." && return unless auth?
|
6
|
+
|
7
|
+
::Capybara.register_driver :special_sauce do |app|
|
8
|
+
::Capybara::Selenium::Driver.new(
|
9
|
+
app,
|
10
|
+
browser: :remote,
|
11
|
+
url: sauce_endpoint,
|
12
|
+
desired_capabilities: desired_capabilities(options)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
::Capybara.current_driver = :special_sauce
|
17
|
+
|
18
|
+
::Capybara.current_session
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module SpecialSauce
|
2
|
+
class Driver
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def auth?
|
7
|
+
authentication != ':'
|
8
|
+
end
|
9
|
+
|
10
|
+
def authentication
|
11
|
+
"#{ ENV['SAUCE_USER_NAME'] }:#{ ENV['SAUCE_API_KEY'] }"
|
12
|
+
end
|
13
|
+
|
14
|
+
def sauce_endpoint
|
15
|
+
"http://#{ authentication }@ondemand.saucelabs.com:80/wd/hub"
|
16
|
+
end
|
17
|
+
|
18
|
+
# ENV vars for when running against a single saucelabs browser. (As set by jenkins plugin.)
|
19
|
+
#
|
20
|
+
# Example running locally against saucelabs:
|
21
|
+
# { 'browserName' => 'internet explorer',
|
22
|
+
# 'version' => '9',
|
23
|
+
# 'platform' => 'Windows 7' }
|
24
|
+
#
|
25
|
+
# https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
|
26
|
+
def single_browser_caps
|
27
|
+
{ 'browserName' => ENV['SELENIUM_BROWSER'],
|
28
|
+
'version' => ENV['SELENIUM_VERSION'],
|
29
|
+
'platform' => ENV['SELENIUM_PLATFORM'] }
|
30
|
+
end
|
31
|
+
|
32
|
+
# Set SAUCE_ONDEMAND_BROWSERS when running against multiple saucelabs browers.
|
33
|
+
# The value should be a JSON serialized array of browser capabilities.
|
34
|
+
# (Set by jenkins plugin.)
|
35
|
+
def browsers
|
36
|
+
all_browser_caps = ENV['SAUCE_ONDEMAND_BROWSERS'] && JSON.parse(ENV['SAUCE_ONDEMAND_BROWSERS'])
|
37
|
+
if all_browser_caps && all_browser_caps.size > 0
|
38
|
+
all_browser_caps
|
39
|
+
else
|
40
|
+
[single_browser_caps]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Jenkins plugin doesn't set browserName sometimes.
|
45
|
+
def sanitized_browser_options(current_browser_id)
|
46
|
+
options = browsers[current_browser_id]
|
47
|
+
options['browserName'] ||= options['browser']
|
48
|
+
options
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_browser_caps
|
52
|
+
if ENV['CURRENT_BROWSER_ID']
|
53
|
+
sanitized_browser_options(ENV['CURRENT_BROWSER_ID'].to_i)
|
54
|
+
else
|
55
|
+
single_browser_caps
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def desired_capabilities(options = {})
|
60
|
+
options[:plus_caps] ||= {}
|
61
|
+
options[:using_caps] || current_browser_caps.merge(options[:plus_caps])
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SpecialSauce
|
2
|
+
class Watir < SpecialSauce::Driver
|
3
|
+
|
4
|
+
def self.browser(options = {})
|
5
|
+
puts "Sauce Labs auth ENV variables not set." && return unless auth?
|
6
|
+
|
7
|
+
::Watir::Browser.new(
|
8
|
+
:remote,
|
9
|
+
url: sauce_endpoint,
|
10
|
+
desired_capabilities: desired_capabilities(options)
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: special_sauce
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Arnold
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: appraisal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: watir
|
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: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: climate_control
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: SpecialSauce helps you run your Capybara or Watir tests with Sauce Labs.
|
112
|
+
email:
|
113
|
+
- earnold@covermymeds.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- MIT-LICENSE
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- lib/special_sauce.rb
|
122
|
+
- lib/special_sauce/capybara.rb
|
123
|
+
- lib/special_sauce/driver.rb
|
124
|
+
- lib/special_sauce/version.rb
|
125
|
+
- lib/special_sauce/watir.rb
|
126
|
+
- lib/tasks/special_sauce_tasks.rake
|
127
|
+
homepage: https://github.com/nativestranger/special_sauce
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.6.8
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: SpecialSauce helps you run your Capybara or Watir tests with Sauce Labs.
|
151
|
+
test_files: []
|