sauce 3.1.3 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/sauce.rb +1 -1
- data/lib/sauce/config.rb +12 -1
- data/lib/sauce/parallel/test_broker.rb +1 -1
- data/lib/sauce/rspec.rb +14 -18
- data/lib/sauce/selenium.rb +10 -0
- data/lib/sauce/utilities.rb +38 -0
- data/lib/sauce/utilities/connect.rb +4 -0
- data/lib/sauce/utilities/rails_server.rb +11 -0
- data/lib/sauce/version.rb +2 -2
- data/lib/tasks/parallel_testing.rb +34 -10
- data/spec/sauce/cucumber_spec.rb +1 -1
- data/spec/sauce/utilities/rails_server_spec.rb +14 -0
- data/spec/sauce/utilities/utilities_spec.rb +51 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjhiN2EwMGM0NjAwOTg1NTBlMzI2NWRkNWJlZWE1YTYzYTU0YzY4ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTkxN2RmNGM0NzZjMTAzYmQ4MGM3OTYwMzg5NmIxODM0ODgxMzNkZg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2E3NWQ2ODQ0NGI5NGEzZjUxYWI4ODQyNTM5NDI1MTgwZWQ4MjQ0ZmNhMmFm
|
10
|
+
OTdlNThlNDcxNzRlMzFkMTVjNjFiMDRkZjc5YjU4YWM2YzIwYjE5Yzk2NTkw
|
11
|
+
ZThjMzM1MjEyOTQ4MmViN2I5YTgwZjRjZGFmYTQyZDVkZDZhNzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2UzOWU3OGNkYmJmZGI0YzQ4ZTFjYTA5YjgxMjBiMjRkYzJkYzUyOTdkNjVj
|
14
|
+
M2ZlYWYwZmNhZTIwZDRiYWM0NjkzNGNiOTg4YjMzOTE4MzM4OTJmYzQ1YzJj
|
15
|
+
NGU1NjYzNjVkZTFmZGUwMDNmZjhjZTY2M2VlYmU5NjkxNzkwMTY=
|
data/lib/sauce.rb
CHANGED
data/lib/sauce/config.rb
CHANGED
@@ -27,7 +27,8 @@ module Sauce
|
|
27
27
|
:local_application_port => "3001",
|
28
28
|
:capture_traffic => false,
|
29
29
|
:start_tunnel => true,
|
30
|
-
:start_local_application => true
|
30
|
+
:start_local_application => true,
|
31
|
+
:warn_on_skipped_integration => true
|
31
32
|
}
|
32
33
|
|
33
34
|
DEFAULT_BROWSERS = {
|
@@ -73,6 +74,14 @@ module Sauce
|
|
73
74
|
return POTENTIAL_PORTS[port_index]
|
74
75
|
end
|
75
76
|
|
77
|
+
def self.called_from_integrations?
|
78
|
+
@called_from_integrations || false
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.called_from_integrations
|
82
|
+
@called_from_integrations = true
|
83
|
+
end
|
84
|
+
|
76
85
|
def initialize(opts={})
|
77
86
|
@opts = {}
|
78
87
|
@undefaulted_opts = {}
|
@@ -173,6 +182,8 @@ module Sauce
|
|
173
182
|
end
|
174
183
|
|
175
184
|
def browsers_for_file(file)
|
185
|
+
Sauce::Config.called_from_integrations
|
186
|
+
|
176
187
|
if @opts[:perfile_browsers]
|
177
188
|
@opts[:perfile_browsers][file].map do |h|
|
178
189
|
[h['os'], h['browser'], h['version']]
|
data/lib/sauce/rspec.rb
CHANGED
@@ -102,42 +102,38 @@ begin
|
|
102
102
|
::RSpec.configuration.include(self, :sauce => true)
|
103
103
|
|
104
104
|
::RSpec.configuration.before(:suite, :sauce => true) do
|
105
|
-
|
106
105
|
config = Sauce::Config.new
|
107
106
|
if config[:application_host]
|
108
|
-
Sauce::Utilities::Connect.
|
107
|
+
Sauce::Utilities::Connect.start_from_config(config)
|
109
108
|
end
|
110
109
|
|
111
|
-
|
112
|
-
Sauce::Utilities::RailsServer.is_rails_app?
|
113
|
-
@@server = Sauce::Utilities::RailsServer.new
|
114
|
-
@@server.start
|
115
|
-
end
|
110
|
+
@@server = Sauce::Utilities::RailsServer.start_if_required(config)
|
116
111
|
end
|
117
112
|
|
118
113
|
::RSpec.configuration.before :suite do
|
119
|
-
need_tunnel = false
|
120
114
|
config = Sauce::Config.new
|
115
|
+
# TODO: Check which rspec version this changed in -- If < 2, change.
|
121
116
|
files_to_run = ::RSpec.configuration.respond_to?(:files_to_run) ? ::RSpec.configuration.files_to_run :
|
122
117
|
::RSpec.configuration.settings[:files_to_run]
|
123
|
-
|
124
|
-
|
125
|
-
|
118
|
+
|
119
|
+
running_selenium_specs = files_to_run.any? {|file| file =~ /spec\/selenium\//}
|
120
|
+
need_tunnel = running_selenium_specs && config[:application_host]
|
126
121
|
|
127
122
|
if need_tunnel || config[:start_tunnel]
|
128
|
-
Sauce::Utilities::Connect.
|
123
|
+
Sauce::Utilities::Connect.start_from_config(config)
|
129
124
|
end
|
130
125
|
|
131
|
-
if
|
132
|
-
|
133
|
-
Sauce::Utilities::RailsServer.is_rails_app?
|
134
|
-
@@server = Sauce::Utilities::RailsServer.new
|
135
|
-
@@server.start
|
126
|
+
if running_selenium_specs
|
127
|
+
@@server = Sauce::Utilities::RailsServer.start_if_required(config)
|
136
128
|
end
|
137
129
|
end
|
130
|
+
|
138
131
|
::RSpec.configuration.after :suite do
|
139
132
|
Sauce::Utilities::Connect.close
|
140
|
-
|
133
|
+
if (defined? @@server) && @@server
|
134
|
+
@@server.stop
|
135
|
+
end
|
136
|
+
Sauce::Utilities.warn_if_suspect_misconfiguration
|
141
137
|
end
|
142
138
|
end
|
143
139
|
end
|
data/lib/sauce/selenium.rb
CHANGED
@@ -26,6 +26,14 @@ module Sauce
|
|
26
26
|
class Selenium2
|
27
27
|
attr_reader :config, :driver
|
28
28
|
|
29
|
+
def self.used_at_least_once?
|
30
|
+
@used_at_least_once || false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.used_at_least_once
|
34
|
+
@used_at_least_once = true
|
35
|
+
end
|
36
|
+
|
29
37
|
def initialize(opts={})
|
30
38
|
@config = Sauce::Config.new(opts)
|
31
39
|
http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
|
@@ -40,6 +48,8 @@ module Sauce
|
|
40
48
|
file_path = args.first.to_s
|
41
49
|
File.exist?(file_path) ? file_path : false
|
42
50
|
end
|
51
|
+
|
52
|
+
Sauce::Selenium2.used_at_least_once
|
43
53
|
end
|
44
54
|
|
45
55
|
def method_missing(meth, *args)
|
data/lib/sauce/utilities.rb
CHANGED
@@ -32,11 +32,49 @@ module Sauce
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def self.warn_if_suspect_misconfiguration(style = :rspec)
|
36
|
+
if Sauce::Selenium2.used_at_least_once?
|
37
|
+
integrated = Sauce::Config.called_from_integrations?
|
38
|
+
warnings_on = Sauce::Config.new[:warn_on_skipped_integration]
|
39
|
+
unless (integrated && warnings_on)
|
40
|
+
STDERR.puts Sauce::Utilities.incorrectly_integrated_warning(style)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
35
45
|
def self.page_deprecation_message
|
36
46
|
return <<-MESSAGE
|
37
47
|
[DEPRECATED] Using the #page method is deprecated for RSpec tests without Capybara. Please use the #s or #selenium method instead.
|
38
48
|
If you are using Capybara and are seeing this message, check the Capybara README for information on how to include the Capybara DSL in your tests.
|
39
49
|
MESSAGE
|
40
50
|
end
|
51
|
+
|
52
|
+
def self.incorrectly_integrated_warning(style = :rspec)
|
53
|
+
case style
|
54
|
+
when :cuke
|
55
|
+
tests = 'features'
|
56
|
+
runner = 'Cucumber'
|
57
|
+
tag = '@selenium'
|
58
|
+
else :rspec
|
59
|
+
tests = 'specs'
|
60
|
+
runner = 'RSpec'
|
61
|
+
tag = ':sauce => true'
|
62
|
+
end
|
63
|
+
|
64
|
+
return <<-stringend
|
65
|
+
|
66
|
+
===============================================================================
|
67
|
+
Your #{tests} used the Sauce Selenium driver, but not the #{runner} integration.
|
68
|
+
This may result in undesired behaviour, such as configured platforms being
|
69
|
+
skipped.
|
70
|
+
|
71
|
+
You can correct this by tagging #{tests} intended for Sauce with
|
72
|
+
'#{tag}'.
|
73
|
+
|
74
|
+
You can disable this message by setting the 'warn_on_skipped_integration'
|
75
|
+
config option to false.
|
76
|
+
===============================================================================
|
77
|
+
stringend
|
78
|
+
end
|
41
79
|
end
|
42
80
|
end
|
@@ -6,6 +6,17 @@ module Sauce
|
|
6
6
|
class RailsServer
|
7
7
|
include Sauce::Utilities
|
8
8
|
|
9
|
+
def self.start_if_required(config)
|
10
|
+
if config[:start_local_application] && self.is_rails_app?
|
11
|
+
server = new
|
12
|
+
server.start
|
13
|
+
|
14
|
+
return server
|
15
|
+
end
|
16
|
+
|
17
|
+
return server
|
18
|
+
end
|
19
|
+
|
9
20
|
def self.is_rails_app?
|
10
21
|
return !major_version.nil?
|
11
22
|
end
|
data/lib/sauce/version.rb
CHANGED
@@ -4,41 +4,65 @@ require "parallel_tests/tasks"
|
|
4
4
|
require "parallel_tests/cli_patch"
|
5
5
|
|
6
6
|
namespace :sauce do
|
7
|
-
task :spec, :
|
7
|
+
task :spec, :spec_files, :concurrency, :rspec_options do |t, args|
|
8
8
|
::RSpec::Core::Runner.disable_autorun!
|
9
9
|
|
10
|
+
env_args = {
|
11
|
+
:concurrency => ENV['concurrency'],
|
12
|
+
:rspec_options => ENV['rspec_options'],
|
13
|
+
:spec_files => ENV['specs']
|
14
|
+
}
|
15
|
+
|
16
|
+
env_args.delete_if {|k,v| k.nil? || k == ''}
|
17
|
+
|
10
18
|
args.with_defaults({
|
11
|
-
:
|
19
|
+
:concurrency => [Sauce::TestBroker.concurrency, 20].min,
|
12
20
|
:files => "spec",
|
13
21
|
:rspec_opts => "-t sauce"
|
14
22
|
})
|
15
23
|
|
24
|
+
concurrency = env_args[:concurrency] || args[:concurrency]
|
25
|
+
spec_files = env_args[:spec_files] || args[:files]
|
26
|
+
rspec_options = env_args[:rspec_options] || args[:rspec_options]
|
27
|
+
|
16
28
|
parallel_arguments = [
|
17
29
|
"--type", "saucerspec",
|
18
|
-
"-n", "#{
|
30
|
+
"-n", "#{concurrency}"
|
19
31
|
]
|
20
32
|
|
21
|
-
unless
|
33
|
+
unless rspec_options.nil?
|
22
34
|
parallel_arguments.push "-o"
|
23
|
-
parallel_arguments.push
|
35
|
+
parallel_arguments.push rspec_options
|
24
36
|
end
|
25
37
|
|
26
|
-
parallel_arguments.push
|
38
|
+
parallel_arguments.push spec_files
|
39
|
+
|
27
40
|
ParallelTests::CLI.new.run(parallel_arguments)
|
28
41
|
end
|
29
42
|
|
30
|
-
task :features, :files, :
|
43
|
+
task :features, :files, :concurrency do |t, args|
|
31
44
|
args.with_defaults({
|
32
|
-
:concurrency => [Sauce::TestBroker.
|
45
|
+
:concurrency => [Sauce::TestBroker.concurrency, 20].min,
|
33
46
|
:files => "features"
|
34
47
|
})
|
35
48
|
|
49
|
+
env_args = {
|
50
|
+
:concurrency => ENV['concurrency'],
|
51
|
+
:features => ENV['features']
|
52
|
+
}
|
53
|
+
|
54
|
+
env_args.delete_if {|k,v| k.nil? || k == ''}
|
55
|
+
|
56
|
+
concurrency = env_args[:concurrency] || args[:concurrency]
|
57
|
+
features = env_args[:features] || args[:files]
|
58
|
+
|
36
59
|
parallel_arguments = [
|
37
60
|
"--type", "saucecucumber",
|
38
|
-
"-n",
|
39
|
-
|
61
|
+
"-n", concurrency.to_s,
|
62
|
+
features
|
40
63
|
]
|
41
64
|
|
65
|
+
STDERR.puts "ARGS #{parallel_arguments}"
|
42
66
|
ParallelTests::CLI.new.run(parallel_arguments)
|
43
67
|
end
|
44
68
|
|
data/spec/sauce/cucumber_spec.rb
CHANGED
@@ -69,7 +69,7 @@ module Sauce::Capybara
|
|
69
69
|
before :each do
|
70
70
|
# Need to create our nice mocked Capybara driver
|
71
71
|
Capybara.stub_chain(:current_session, :driver).and_return(driver)
|
72
|
-
|
72
|
+
SauceWhisk::Job.stub(:new).and_return(nil)
|
73
73
|
Sauce::Selenium2.stub(:new).with(anything).and_return Object.new
|
74
74
|
end
|
75
75
|
|
@@ -3,6 +3,20 @@ require "spec_helper"
|
|
3
3
|
describe "Sauce::Utilities::RailsServer" do
|
4
4
|
let (:server) {Sauce::Utilities::RailsServer.new}
|
5
5
|
|
6
|
+
describe "##start_if_required" do
|
7
|
+
context "With an :application_host in config" do
|
8
|
+
it "starts" do
|
9
|
+
config = {:start_local_application => true}
|
10
|
+
fake_rails_server = double("Sauce::Utilities::RailsServer")
|
11
|
+
expect(fake_rails_server).to receive(:start) {nil}
|
12
|
+
expect(Sauce::Utilities::RailsServer).to receive(:new) {fake_rails_server}
|
13
|
+
allow(Sauce::Utilities::RailsServer).to receive(:is_rails_app?) {true}
|
14
|
+
|
15
|
+
Sauce::Utilities::RailsServer.start_if_required(config)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
context "With a Rails 4 app" do
|
7
21
|
before (:each) do
|
8
22
|
File.stub(:exists?).and_return false
|
@@ -14,6 +14,7 @@ describe "Sauce::Utilities::Connect" do
|
|
14
14
|
after :each do
|
15
15
|
Sauce::Utilities::Connect.instance_variable_set(:@tunnel, nil)
|
16
16
|
end
|
17
|
+
|
17
18
|
describe "##start" do
|
18
19
|
it "should call Sauce Connect when included" do
|
19
20
|
@mock_tunnel.stub(:connect).and_return true
|
@@ -83,4 +84,54 @@ describe "Sauce::Utilities::Connect" do
|
|
83
84
|
Sauce::Utilities::Connect.close
|
84
85
|
end
|
85
86
|
end
|
87
|
+
|
88
|
+
describe "##warn_if_suspect_misconfiguration" do
|
89
|
+
it "does not fire if no Selenium sessions have been fired" do
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "##incorrectly_integrated_warning" do
|
95
|
+
it "should return rspec warning by default" do
|
96
|
+
Sauce::Utilities.incorrectly_integrated_warning.should eq rspec_warning
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should allow for the cucumber warning to be selected" do
|
100
|
+
Sauce::Utilities.incorrectly_integrated_warning(:cuke).should eq cuke_warning
|
101
|
+
end
|
102
|
+
end
|
86
103
|
end
|
104
|
+
|
105
|
+
def rspec_warning
|
106
|
+
return <<-stringend
|
107
|
+
|
108
|
+
===============================================================================
|
109
|
+
Your specs used the Sauce Selenium driver, but not the RSpec integration.
|
110
|
+
This may result in undesired behaviour, such as configured platforms being
|
111
|
+
skipped.
|
112
|
+
|
113
|
+
You can correct this by tagging specs intended for Sauce with
|
114
|
+
':sauce => true'.
|
115
|
+
|
116
|
+
You can disable this message by setting the 'warn_on_skipped_integration'
|
117
|
+
config option to false.
|
118
|
+
===============================================================================
|
119
|
+
stringend
|
120
|
+
end
|
121
|
+
|
122
|
+
def cuke_warning
|
123
|
+
return <<-stringend
|
124
|
+
|
125
|
+
===============================================================================
|
126
|
+
Your features used the Sauce Selenium driver, but not the Cucumber integration.
|
127
|
+
This may result in undesired behaviour, such as configured platforms being
|
128
|
+
skipped.
|
129
|
+
|
130
|
+
You can correct this by tagging features intended for Sauce with
|
131
|
+
'@selenium'.
|
132
|
+
|
133
|
+
You can disable this message by setting the 'warn_on_skipped_integration'
|
134
|
+
config option to false.
|
135
|
+
===============================================================================
|
136
|
+
stringend
|
137
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sauce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Lacey
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-
|
16
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: capybara
|