special_sauce 0.1.0 → 0.2.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 +28 -40
- data/lib/special_sauce/capybara.rb +14 -1
- data/lib/special_sauce/version.rb +1 -1
- data/lib/special_sauce/watir.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03137b3e4dcc6c8bc674f5ff2df06d2a44d3d51e
|
4
|
+
data.tar.gz: 70072679b00e5d88504415378bde5ab9c409944e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3de8a1fb1cf790a2975b01365d52baf0797f9493622a07c7cdd6b715a49e43e6850af9627d8672375abe3db07daa0e1aea561bcc302a4c6c4dbb5067f775f5
|
7
|
+
data.tar.gz: d359dea36ac55c5d09d92a24df1c55935bca71f0e8199f651be9d90770f5c116c31a600b28beb53081feeef450ae5b7e289493107988f259d6d841cbab1c9d2b
|
data/README.md
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/nativestranger/special_sauce.svg?branch=master)](https://travis-ci.org/nativestranger/special_sauce)
|
4
4
|
|
5
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 [
|
6
|
+
special_sauce makes it easy to run existing [capybara](https://github.com/teamcapybara/capybara) or [watir](https://github.com/watir/watir) based (selenium) tests against [Sauce Labs](https://saucelabs.com/) browsers.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'special_sauce',
|
11
|
+
gem 'special_sauce', '0.2.0'
|
12
12
|
```
|
13
13
|
|
14
14
|
## Watir Example
|
15
15
|
|
16
|
-
If the authentication ENV variables are set, `special_sauce` will try to
|
16
|
+
If the authentication ENV variables are set, `special_sauce` will try to set up a remote browser, otherwise default to chrome.
|
17
17
|
|
18
18
|
``` ruby
|
19
19
|
@browser = SpecialSauce::Watir.browser || Watir::Browser.new(:chrome)
|
@@ -21,15 +21,21 @@ If the authentication ENV variables are set, `special_sauce` will try to setup a
|
|
21
21
|
|
22
22
|
## Capybara Example
|
23
23
|
|
24
|
-
If the authentication ENV variables are set, `special_sauce` will try to
|
24
|
+
If the authentication ENV variables are set, `special_sauce` will try to set up a remote browser and set the current drivers, otherwise use Chrome locally.
|
25
25
|
|
26
26
|
``` ruby
|
27
|
-
|
27
|
+
Capybara.register_driver :selenium_chrome do |app|
|
28
|
+
Capybara::Selenium::Driver.new(app, :browser => :chrome)
|
29
|
+
end
|
30
|
+
|
31
|
+
SpecialSauce::Capybara.setup_session || Capybara.current_driver = :selenium_chrome
|
28
32
|
```
|
29
33
|
|
30
34
|
## Environment Variables
|
31
35
|
|
32
|
-
|
36
|
+
`special_sauce` relies on the following env vars to set up remote sessions with sauce labs.
|
37
|
+
|
38
|
+
You can set these explicitly or rely on the [Sauce OnDemand Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Sauce+OnDemand+Plugin) to set them in Jenkins builds.
|
33
39
|
|
34
40
|
**Authentication Variables - Required**
|
35
41
|
|
@@ -38,40 +44,13 @@ In order to create remote sessions with Sauce Labs, some environment variables m
|
|
38
44
|
| SAUCE_USER_NAME | your saucelabs username |
|
39
45
|
| SAUCE_API_KEY | saucelabs api key for your username |
|
40
46
|
|
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
47
|
## How Browser Capabilities are set.
|
61
48
|
|
62
|
-
When calling `SpecialSauce::Watir.browser` or `SpecialSauce::Capybara.
|
49
|
+
When calling `SpecialSauce::Watir.browser` or `SpecialSauce::Capybara.setup_session` without any arguments, `special_sauce` will use env vars to determine browser capabilities.
|
63
50
|
|
64
|
-
|
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`:
|
51
|
+
You may set these explicitly [or rely on the Sauce OnDemand Plugin](docs/JENKINS_PLUGIN_ENV.md) to set them for you.
|
70
52
|
|
71
|
-
|
72
|
-
additional_caps = { 'tunnel-identifier' => ENV['TRAVIS_JOB_NUMBER'] }
|
73
|
-
@browser = SpecialSauce::Watir.browser(plus_caps: additional_caps)
|
74
|
-
```
|
53
|
+
**It is recommended you explicitly declare your browser capabilities with `using_caps`.**
|
75
54
|
|
76
55
|
## Overriding Browser Capabilities
|
77
56
|
To override default browser capabilities, use `using_caps`:
|
@@ -83,6 +62,14 @@ custom_caps = { 'browserName' => 'internet explorer',
|
|
83
62
|
@browser = SpecialSauce::Watir.browser(using_caps: custom_caps)
|
84
63
|
```
|
85
64
|
|
65
|
+
## Adding Browser Capabilities
|
66
|
+
To add additional browser capabilities, use `plus_caps`:
|
67
|
+
|
68
|
+
``` ruby
|
69
|
+
additional_caps = { 'tunnel-identifier' => ENV['TRAVIS_JOB_NUMBER'] }
|
70
|
+
SpecialSauce::Capybara.setup_session(plus_caps: additional_caps)
|
71
|
+
```
|
72
|
+
|
86
73
|
## Sauce Labs Options
|
87
74
|
|
88
75
|
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.
|
@@ -94,12 +81,13 @@ additional_caps = { 'name' => 'my test name', 'screenResolution' => '1280x1024'
|
|
94
81
|
|
95
82
|
## [Tips for running against multiple browsers](docs/MULTIPLEBROWSERS.md)
|
96
83
|
|
84
|
+
## [CHANGLELOG](docs/CHANGELOG.md)
|
85
|
+
|
97
86
|
## License
|
98
87
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
99
88
|
|
100
89
|
# TODO
|
101
90
|
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
105
|
-
* add contributing version
|
91
|
+
* Appraise more versions of ruby & versions of capybara & watir.
|
92
|
+
* Allow customization of ENV variables?
|
93
|
+
* Add 'contributing' section.
|
@@ -2,7 +2,19 @@ module SpecialSauce
|
|
2
2
|
class Capybara < SpecialSauce::Driver
|
3
3
|
|
4
4
|
def self.current_session(options = {})
|
5
|
-
|
5
|
+
Kernel.warn(
|
6
|
+
"SpecialSauce::Capybara#current_session is deprecated and will be removed in v1.0.0. Use 'setup_session' instead."
|
7
|
+
)
|
8
|
+
setup_session(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.setup_session(options = {})
|
12
|
+
unless auth?
|
13
|
+
Kernel.warn(
|
14
|
+
'Sauce Labs auth ENV variables not set ... skipping SpecialSauce::Capybara.setup_session'
|
15
|
+
)
|
16
|
+
return
|
17
|
+
end
|
6
18
|
|
7
19
|
::Capybara.register_driver :special_sauce do |app|
|
8
20
|
::Capybara::Selenium::Driver.new(
|
@@ -14,6 +26,7 @@ module SpecialSauce
|
|
14
26
|
end
|
15
27
|
|
16
28
|
::Capybara.current_driver = :special_sauce
|
29
|
+
::Capybara.javascript_driver = :special_sauce
|
17
30
|
|
18
31
|
::Capybara.current_session
|
19
32
|
end
|
data/lib/special_sauce/watir.rb
CHANGED
@@ -2,7 +2,12 @@ module SpecialSauce
|
|
2
2
|
class Watir < SpecialSauce::Driver
|
3
3
|
|
4
4
|
def self.browser(options = {})
|
5
|
-
|
5
|
+
unless auth?
|
6
|
+
Kernel.warn(
|
7
|
+
'Sauce Labs auth ENV variables not set ... skipping SpecialSauce::Watir.browser'
|
8
|
+
)
|
9
|
+
return
|
10
|
+
end
|
6
11
|
|
7
12
|
::Watir::Browser.new(
|
8
13
|
:remote,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: special_sauce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Arnold
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|