saucer 0.2.0 → 0.3.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 +3 -0
- data/lib/saucer/annotations.rb +6 -6
- data/lib/saucer/config/sauce.rb +10 -3
- data/lib/saucer/config/selenium.rb +4 -8
- data/lib/saucer/driver.rb +21 -10
- data/lib/saucer/platform_configuration.rb +0 -1
- data/lib/saucer/version.rb +1 -1
- data/saucer.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2c37e1cabccacc4e978ccea9531be62b2397bf
|
4
|
+
data.tar.gz: 42780591f1c4b0a3a7f6f1972ff6e1f45417db14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd6dcb38eeb62ec7a203fc3e4725f8fd7e2f8d322637151df0b326fb9510444acf7edd9ad826da6a8f745336326a2294d11b5814a56426b9857d07f31f5c8c6c
|
7
|
+
data.tar.gz: 743b759e3447cba6f4e3b81a8a34f797abd08f527ba79f2f4b954af21508842454577b951815e5eb339ff7ffdf883e5b6d198459d518a9cce7281aebafd68f71
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Convenience methods for running your Ruby tests on Sauce Labs
|
4
4
|
|
5
|
+
## Disclaimer
|
6
|
+
*This code is provided on an "AS-IS” basis without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement. Your tests and testing environments may require you to modify this framework. Issues regarding this framework should be submitted through GitHub. For questions regarding Sauce Labs integration, please see the Sauce Labs documentation at https://wiki.saucelabs.com/. This framework is not maintained by Sauce Labs Support.*
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
data/lib/saucer/annotations.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
module Saucer
|
2
2
|
module Annotations
|
3
3
|
|
4
|
-
def comment(comment)
|
4
|
+
def comment=(comment)
|
5
5
|
driver.execute_script("sauce:context=#{comment}")
|
6
6
|
end
|
7
7
|
|
8
|
-
def job_result(result)
|
8
|
+
def job_result=(result)
|
9
9
|
raise ArgumentError, "invalid value for result" unless ['passed', 'failed', true, false].include?(result)
|
10
10
|
driver.execute_script("sauce:job-result=#{result}")
|
11
11
|
end
|
12
12
|
|
13
|
-
def job_name(name)
|
13
|
+
def job_name=(name)
|
14
14
|
driver.execute_script("sauce:job-name=#{name}")
|
15
15
|
end
|
16
16
|
|
17
|
-
def job_tags(tags)
|
17
|
+
def job_tags=(tags)
|
18
18
|
tags = tags.join(',') if tags.is_a?(Array)
|
19
19
|
driver.execute_script("sauce:job-tags=#{tags}")
|
20
20
|
end
|
21
21
|
|
22
|
-
def job_info(info)
|
22
|
+
def job_info=(info)
|
23
23
|
raise ArgumentError, "job info must be JSON" unless info.is_a? JSON
|
24
24
|
driver.execute_script("sauce:job-info=#{info}")
|
25
25
|
end
|
26
26
|
|
27
|
-
def build_name(name)
|
27
|
+
def build_name=(name)
|
28
28
|
driver.execute_script("sauce:job-build=#{name}")
|
29
29
|
end
|
30
30
|
|
data/lib/saucer/config/sauce.rb
CHANGED
@@ -10,17 +10,24 @@ module Saucer
|
|
10
10
|
@@scenario
|
11
11
|
end
|
12
12
|
|
13
|
-
DATA_PARAMS = %i(name build language host_os version ci ip gems framework page_object harness).freeze
|
13
|
+
DATA_PARAMS = %i(name build language host_os version ci ip gems framework page_object harness selenium).freeze
|
14
14
|
|
15
15
|
FRAMEWORKS = %w(capybara watir).freeze
|
16
16
|
PAGE_OBJECTS = %w(site_prism page-object watirsome watir_drops).freeze
|
17
17
|
|
18
18
|
def initialize(opt = {})
|
19
|
+
opt[:browser_name] ||= ENV['BROWSER']
|
20
|
+
opt[:platform] ||= ENV['PLATFORM']
|
21
|
+
opt[:version] ||= ENV['VERSION']
|
22
|
+
|
19
23
|
@gems = {}
|
20
|
-
Bundler.definition.
|
24
|
+
Bundler.definition.specs.map(&:name).each do |gem_name|
|
25
|
+
next if Bundler.environment.specs.to_hash[gem_name].empty?
|
21
26
|
@gems[gem_name] = Bundler.environment.specs.to_hash[gem_name].first.version.version
|
22
27
|
end
|
23
28
|
|
29
|
+
@selenium = @gems['selenium-webdriver']
|
30
|
+
|
24
31
|
frameworks = @gems.select { |gem| FRAMEWORKS.include? gem }
|
25
32
|
@framework = frameworks.first if frameworks.size == 1
|
26
33
|
|
@@ -28,7 +35,7 @@ module Saucer
|
|
28
35
|
@page_object = page_objects.first if page_objects.size == 1
|
29
36
|
|
30
37
|
@name = opt[:name] if opt.key? :name
|
31
|
-
@build = opt[:build]
|
38
|
+
@build = opt[:build] || ['BUILD_TAG'] || "Build - #{Time.now.to_i}"
|
32
39
|
|
33
40
|
if RSpec.respond_to?(:current_example) && !RSpec.current_example.nil?
|
34
41
|
@name ||= RSpec.current_example.full_description
|
@@ -2,6 +2,8 @@ module Saucer
|
|
2
2
|
module Config
|
3
3
|
class Selenium < Common
|
4
4
|
|
5
|
+
attr_reader :sauce
|
6
|
+
|
5
7
|
CONFIG_PARAMS = %i(browser_name version platform selenium_version
|
6
8
|
chromedriver_version iedriver_version).freeze
|
7
9
|
|
@@ -14,20 +16,14 @@ module Saucer
|
|
14
16
|
"https://#{@username}:#{@access_key}@ondemand.saucelabs.com:443/wd/hub"
|
15
17
|
end
|
16
18
|
|
17
|
-
def opts
|
18
|
-
{url: url, desired_capabilities: capabilities}
|
19
|
-
end
|
20
|
-
|
21
19
|
def capabilities
|
22
20
|
caps = @config_params.each_with_object({}) do |param, hash|
|
23
21
|
hash[param] = @opts[param] if @opts.key?(param)
|
24
22
|
hash[param] ||= ENV[param.to_s] if ENV[param.to_s]
|
25
23
|
end
|
26
|
-
sauce = Sauce.new.to_hash
|
27
|
-
caps[:name] = sauce.delete(:name)
|
28
|
-
caps[:build] = sauce.delete(:build)
|
24
|
+
@sauce = Sauce.new.to_hash
|
29
25
|
|
30
|
-
caps[:"sauce:data"] = sauce.to_hash
|
26
|
+
caps[:"sauce:data"] = @sauce.to_hash
|
31
27
|
browser_name = @opts[:browser_name] || :chrome
|
32
28
|
::Selenium::WebDriver::Remote::Capabilities.send(browser_name, caps)
|
33
29
|
end
|
data/lib/saucer/driver.rb
CHANGED
@@ -5,19 +5,28 @@ module Saucer
|
|
5
5
|
|
6
6
|
attr_reader :driver, :config
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
|
10
|
-
@
|
8
|
+
def initialize(opt = {})
|
9
|
+
caps = opt[:desired_capabilities] || {}
|
10
|
+
@config ||= Config::Selenium.new(caps)
|
11
|
+
listener = opt.delete :listener
|
12
|
+
opt[:url] = @config.url
|
13
|
+
opt[:desired_capabilities] = @config.capabilities
|
14
|
+
|
15
|
+
bridge = Selenium::WebDriver::Remote::Bridge.new(opt)
|
16
|
+
bridge = Support::EventFiringBridge.new(bridge, listener) if listener
|
17
|
+
|
18
|
+
@driver = super bridge
|
19
|
+
|
20
|
+
@driver.job_name = @config.sauce[:name]
|
21
|
+
@driver.build_name = @config.sauce[:build]
|
11
22
|
end
|
12
23
|
|
13
24
|
def sauce
|
14
25
|
@api ||= API.new(self, @config)
|
15
26
|
end
|
16
27
|
|
17
|
-
def quit
|
18
|
-
if
|
19
|
-
result = data
|
20
|
-
elsif RSpec.current_example
|
28
|
+
def quit
|
29
|
+
if RSpec.current_example
|
21
30
|
exception = RSpec.current_example.exception
|
22
31
|
result = exception.nil?
|
23
32
|
elsif Saucer::Config::Sauce.scenario
|
@@ -26,11 +35,13 @@ module Saucer
|
|
26
35
|
end
|
27
36
|
|
28
37
|
if exception
|
29
|
-
@driver.comment "Error: #{exception.inspect}"
|
30
|
-
@driver.comment "Error Location: #{exception.backtrace.first}"
|
38
|
+
@driver.comment = "Error: #{exception.inspect}"
|
39
|
+
@driver.comment = "Error Location: #{exception.backtrace.first}"
|
31
40
|
end
|
32
41
|
|
33
|
-
@driver.job_result
|
42
|
+
@driver.job_result = result unless result.nil?
|
43
|
+
results = @driver.sauce.job.log_url[/(.*)\/.*$/, 1]
|
44
|
+
Selenium::WebDriver.logger.warn("Sauce Labs results: #{results}")
|
34
45
|
|
35
46
|
super(*[])
|
36
47
|
end
|
data/lib/saucer/version.rb
CHANGED
data/saucer.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
spec.add_dependency 'parallel_split_test'
|
38
38
|
spec.add_dependency 'require_all'
|
39
|
-
spec.add_dependency 'selenium-webdriver'
|
39
|
+
spec.add_dependency 'selenium-webdriver', "~> 3.0", "< 3.4.1"
|
40
40
|
spec.add_dependency 'sauce_whisk'
|
41
41
|
spec.add_dependency 'sauce_platforms'
|
42
42
|
spec.add_dependency 'json'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saucer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,16 +84,22 @@ dependencies:
|
|
84
84
|
name: selenium-webdriver
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '3.0'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.4.1
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
|
-
- - "
|
97
|
+
- - "~>"
|
95
98
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
99
|
+
version: '3.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.4.1
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: sauce_whisk
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|