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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2JjYzUwNDFiY2E4NDk2ZWY3ODY2MjliMzE4YzUyMDlmYzA0Yzc1ZQ==
4
+ MjhiN2EwMGM0NjAwOTg1NTBlMzI2NWRkNWJlZWE1YTYzYTU0YzY4ZA==
5
5
  data.tar.gz: !binary |-
6
- N2Q2OTJlZTM3ODIzMjU2ZTM3ZGIzOWNiYmU5NTVlYWI0NDI0NTg0ZQ==
6
+ YTkxN2RmNGM0NzZjMTAzYmQ4MGM3OTYwMzg5NmIxODM0ODgxMzNkZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGMyODQ0YWZmZmE5NDA2Nzk2Y2QwY2MwZWFmZDM5MWE5NDNkMjY3MDhkMTNk
10
- YjAwZGExMDRkZWE0NTBkZjFlNTkwZDRhNTk3ZTgwNTEzMzBiNzUyZGU0MjE3
11
- NzIzMDkwNjgxZGRlZGUxY2ViM2FiMTM5NDA4OTU0OTZkOGI0ZWE=
9
+ Y2E3NWQ2ODQ0NGI5NGEzZjUxYWI4ODQyNTM5NDI1MTgwZWQ4MjQ0ZmNhMmFm
10
+ OTdlNThlNDcxNzRlMzFkMTVjNjFiMDRkZjc5YjU4YWM2YzIwYjE5Yzk2NTkw
11
+ ZThjMzM1MjEyOTQ4MmViN2I5YTgwZjRjZGFmYTQyZDVkZDZhNzA=
12
12
  data.tar.gz: !binary |-
13
- Zjg5Mjk4Zjg4YjhkYjVjOTU1ZTE3MWU1NjM5MWNhY2I2ZDRkOWQxMWEyYWIw
14
- Nzc1NTkyZTkwNWEyOTkwZGQxM2VhM2MxZTBhMGNjNjRiMmIzZmUwOGU5ZDhi
15
- Y2JjYjZmZDBmZGIyNWY3NzkyZDMxN2EwNGQzOTg5YWQxZTE3YmQ=
13
+ N2UzOWU3OGNkYmJmZGI0YzQ4ZTFjYTA5YjgxMjBiMjRkYzJkYzUyOTdkNjVj
14
+ M2ZlYWYwZmNhZTIwZDRiYWM0NjkzNGNiOTg4YjMzOTE4MzM4OTJmYzQ1YzJj
15
+ NGU1NjYzNjVkZTFmZGUwMDNmZjhjZTY2M2VlYmU5NjkxNzkwMTY=
@@ -23,4 +23,4 @@ if RUBY_VERSION == "1.9.3" && RUBY_PATCHLEVEL < 392
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -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']]
@@ -60,7 +60,7 @@ module Sauce
60
60
  @@platforms
61
61
  end
62
62
 
63
- def self.concurrencies
63
+ def self.concurrency
64
64
  response = RestClient.get "#{rest_jobs_url}/#{SAUCE_USERNAME}/limits"
65
65
  res = JSON.parse(response)["concurrency"]
66
66
  end
@@ -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.start(:host => config[:application_host], :port => config[:application_port], :quiet => true)
107
+ Sauce::Utilities::Connect.start_from_config(config)
109
108
  end
110
109
 
111
- if config[:start_local_application] &&
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
- if config[:application_host]
124
- need_tunnel = files_to_run.any? {|file| file =~ /spec\/selenium\//}
125
- end
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.start(:host => config[:application_host], :port => config[:application_port], :quiet => true)
123
+ Sauce::Utilities::Connect.start_from_config(config)
129
124
  end
130
125
 
131
- if config[:start_local_application] &&
132
- files_to_run.any? {|file| file =~ /spec\/selenium\//} &&
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
- @@server.stop if defined? @@server
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
@@ -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)
@@ -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
@@ -1,6 +1,10 @@
1
1
  module Sauce
2
2
  module Utilities
3
3
  class Connect
4
+ def self.start_from_config(config)
5
+ self.start(:host => config[:application_host], :port => config[:application_port], :quiet => true)
6
+ end
7
+
4
8
  def self.start(options={})
5
9
  begin
6
10
  require "sauce/connect"
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Sauce
2
- MAJOR_VERSION = '3.1'
3
- PATCH_VERSION = '3'
2
+ MAJOR_VERSION = '3.2'
3
+ PATCH_VERSION = '0'
4
4
 
5
5
  def version
6
6
  "#{MAJOR_VERSION}.#{PATCH_VERSION}"
@@ -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, :files, :concurrencies, :rspec_opts do |t, args|
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
- :concurrencies => [Sauce::TestBroker.concurrencies, 20].min,
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", "#{args[:concurrencies]}"
30
+ "-n", "#{concurrency}"
19
31
  ]
20
32
 
21
- unless args[:rspec_opts].nil?
33
+ unless rspec_options.nil?
22
34
  parallel_arguments.push "-o"
23
- parallel_arguments.push args[:rspec_opts]
35
+ parallel_arguments.push rspec_options
24
36
  end
25
37
 
26
- parallel_arguments.push args[:files]
38
+ parallel_arguments.push spec_files
39
+
27
40
  ParallelTests::CLI.new.run(parallel_arguments)
28
41
  end
29
42
 
30
- task :features, :files, :concurrencies do |t, args|
43
+ task :features, :files, :concurrency do |t, args|
31
44
  args.with_defaults({
32
- :concurrency => [Sauce::TestBroker.concurrencies, 20].min,
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", args[:concurrencies].to_s,
39
- args[:files]
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
 
@@ -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
- Sauce::Job.stub(:new).and_return(nil)
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.1.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-08-13 00:00:00.000000000 Z
16
+ date: 2013-09-25 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: capybara