sauce_ruby 3.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/bin/sauce +103 -0
  3. data/lib/childprocess/process.rb +34 -0
  4. data/lib/generators/sauce/install/install_generator.rb +54 -0
  5. data/lib/parallel_tests/cli_patch.rb +23 -0
  6. data/lib/parallel_tests/saucecucumber/runner.rb +43 -0
  7. data/lib/parallel_tests/saucerspec/runner.rb +40 -0
  8. data/lib/sauce.rb +33 -0
  9. data/lib/sauce/capybara.rb +189 -0
  10. data/lib/sauce/client.rb +40 -0
  11. data/lib/sauce/config.rb +434 -0
  12. data/lib/sauce/driver_pool.rb +5 -0
  13. data/lib/sauce/heroku.rb +18 -0
  14. data/lib/sauce/job.rb +159 -0
  15. data/lib/sauce/parallel.rb +16 -0
  16. data/lib/sauce/parallel/test_broker.rb +110 -0
  17. data/lib/sauce/parallel/test_group.rb +24 -0
  18. data/lib/sauce/railtie.rb +11 -0
  19. data/lib/sauce/raketasks.rb +83 -0
  20. data/lib/sauce/rspec/rspec.rb +186 -0
  21. data/lib/sauce/rspec/rspec_formatter.rb +20 -0
  22. data/lib/sauce/rspec/rspec_one_support.rb +66 -0
  23. data/lib/sauce/selenium.rb +95 -0
  24. data/lib/sauce/test_base.rb +21 -0
  25. data/lib/sauce/test_unit.rb +111 -0
  26. data/lib/sauce/utilities.rb +80 -0
  27. data/lib/sauce/utilities/connect.rb +45 -0
  28. data/lib/sauce/utilities/rails_server.rb +95 -0
  29. data/lib/sauce/utilities/rake.rb +32 -0
  30. data/lib/sauce/version.rb +9 -0
  31. data/lib/sauce/webmock.rb +16 -0
  32. data/lib/tasks/parallel_testing.rb +148 -0
  33. data/spec/cucumber_helper.rb +42 -0
  34. data/spec/integration/connect/spec/spec_helper.rb +21 -0
  35. data/spec/integration/connect/spec/start_tunnel_spec.rb +9 -0
  36. data/spec/integration/connect/spec/with_capybara_spec.rb +10 -0
  37. data/spec/integration/connect_integration_spec.rb +99 -0
  38. data/spec/integration/rspec-capybara/spec/capybara_required_last_spec.rb +18 -0
  39. data/spec/integration/rspec-capybara/spec/integration_spec.rb +17 -0
  40. data/spec/integration/rspec-capybara/spec/sauce_config_spec.rb +13 -0
  41. data/spec/integration/rspec-capybara/spec/sauce_required_last_spec.rb +21 -0
  42. data/spec/integration/rspec-capybara/spec/selenium/selenium_with_capybara.rb +12 -0
  43. data/spec/integration/rspec-capybara/spec/spec_helper.rb +37 -0
  44. data/spec/integration/rspec/spec/integration_spec.rb +13 -0
  45. data/spec/integration/rspec/spec/selenium/selenium_directory_spec.rb +20 -0
  46. data/spec/integration/rspec/spec/spec_helper.rb +52 -0
  47. data/spec/integration/rspec/spec/tagging/selenium_tagging_spec.rb +29 -0
  48. data/spec/integration/testunit/test/capybara_integration_test.rb +37 -0
  49. data/spec/integration/testunit/test/integration_test.rb +21 -0
  50. data/spec/integration/testunit/test/test_helper.rb +13 -0
  51. data/spec/parallel_tests/sauce_rspec_runner_spec.rb +23 -0
  52. data/spec/sauce/capybara_spec.rb +386 -0
  53. data/spec/sauce/config/browser_spec.rb +73 -0
  54. data/spec/sauce/config/config_spec.rb +400 -0
  55. data/spec/sauce/config/default_browsers_spec.rb +46 -0
  56. data/spec/sauce/config/environment_config_spec.rb +106 -0
  57. data/spec/sauce/config/load_defaults_spec.rb +50 -0
  58. data/spec/sauce/config/perfile_browser_spec.rb +105 -0
  59. data/spec/sauce/connect_spec.rb +21 -0
  60. data/spec/sauce/cucumber_spec.rb +212 -0
  61. data/spec/sauce/driver_pool_spec.rb +8 -0
  62. data/spec/sauce/file_detector_spec.rb +15 -0
  63. data/spec/sauce/jasmine_spec.rb +30 -0
  64. data/spec/sauce/parallel/test_broker_spec.rb +77 -0
  65. data/spec/sauce/selenium_spec.rb +60 -0
  66. data/spec/sauce/tasks_spec.rb +180 -0
  67. data/spec/sauce/utilities/rails_server_spec.rb +109 -0
  68. data/spec/sauce/utilities/rake_spec.rb +46 -0
  69. data/spec/sauce/utilities/utilities_spec.rb +137 -0
  70. data/spec/sauce_helper.rb +8 -0
  71. data/spec/spec_helper.rb +27 -0
  72. metadata +390 -0
@@ -0,0 +1,46 @@
1
+ require "rspec"
2
+
3
+ describe "Sauce::Config :browsers" do
4
+ before :each do
5
+ Sauce.clear_config
6
+ end
7
+
8
+ context "When unset" do
9
+ it "defaults to the tutorial browsers" do
10
+ tutorial_browsers = [
11
+ ["Windows 8", "Internet Explorer", "10"],
12
+ ["Windows 7", "Firefox", "20"],
13
+ ["OS X 10.8", "Safari", "6"],
14
+ ["Linux", "Chrome", nil]
15
+ ]
16
+
17
+ Sauce::Config.new[:browsers].should eq tutorial_browsers
18
+ end
19
+ end
20
+
21
+ context "When set" do
22
+ before :each do
23
+ Sauce.clear_config
24
+
25
+ Sauce.config do |config|
26
+ config[:browsers] = [['TEST_OS', 'TEST_BROWSER', 'TEST_BROWSER_VERSION']]
27
+ end
28
+ end
29
+
30
+ it 'should default the config to the first item' do
31
+ c = Sauce::Config.new
32
+ c.os.should == 'TEST_OS'
33
+ c.browser.should == 'TEST_BROWSER'
34
+ c.browser_version == 'TEST_BROWSER_VERSION'
35
+ end
36
+
37
+ it 'should return an Array of the (os, browser, version)' do
38
+ c = Sauce::Config.new
39
+ c[:os] = 'A'
40
+ c[:browser] = 'B'
41
+ c[:browser_version] = 'C'
42
+
43
+ c.browsers.should == [['A', 'B', 'C']]
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,106 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'sauce/config'
3
+
4
+ describe "Sauce::Config" do
5
+ describe "#extract_options_from_hash" do
6
+ let(:test_options) {
7
+ {
8
+ "SAUCE_USERNAME" => "user",
9
+ "SAUCE_ACCESS_KEY" => "ac",
10
+ "SAUCE_APPLICATION_HOST" => "application_host"
11
+ }
12
+ }
13
+
14
+ let(:test_config) {Sauce::Config.new}
15
+
16
+ it "should set any options starting with SAUCE" do
17
+ test_config
18
+ opts = test_config.send(:extract_options_from_hash, test_options)
19
+
20
+ opts[:username].should eq "user"
21
+ opts[:application_host].should eq "application_host"
22
+ end
23
+
24
+ context "when passed the jenkins authentication parameters" do
25
+ let(:jenkins_options) {
26
+ {
27
+ "SAUCE_USER_NAME" => "jenkins_user",
28
+ "SAUCE_API_KEY" => "jenkins_access_key"
29
+ }
30
+ }
31
+
32
+ it "should parse the SAUCE_USER_NAME value" do
33
+ test_config
34
+ opts = test_config.send(:extract_options_from_hash, jenkins_options)
35
+
36
+ opts[:username].should eq "jenkins_user"
37
+ end
38
+
39
+ it "should parse the SAUCE_USER_NAME value" do
40
+ test_config
41
+ opts = test_config.send(:extract_options_from_hash, jenkins_options)
42
+
43
+ opts[:access_key].should eq "jenkins_access_key"
44
+ end
45
+ end
46
+
47
+ context "when passed build numbers" do
48
+ it "should accept BUILD_NUMBER" do
49
+ opts = test_config.send(:extract_options_from_hash, {"BUILD_NUMBER" => "build"})
50
+ opts[:build].should eq "build"
51
+ end
52
+
53
+ it "should accept TRAVIS_BUILD_NUMBER" do
54
+ opts = test_config.send(:extract_options_from_hash, {"TRAVIS_BUILD_NUMBER" => "build"})
55
+ opts[:build].should eq "build"
56
+ end
57
+
58
+ it "should accept CIRCLE_BUILD_NUM" do
59
+ opts = test_config.send(:extract_options_from_hash, {"CIRCLE_BUILD_NUM" => "build"})
60
+ opts[:build].should eq "build"
61
+ end
62
+ end
63
+
64
+ context "when passed browsers in a json array keyed to SAUCE_ONDEMAND_BROWSERS" do
65
+ let(:browsers) {
66
+ { "SAUCE_ONDEMAND_BROWSERS" => [
67
+ {:os => "os1", :browser => "ie1", "browser-version" => "version1"},
68
+ {:os => "os2", :browser => "ie2", "browser-version" => "version2"}
69
+ ].to_json,
70
+ "SAUCE_BROWSER" => "not_browser",
71
+ "SAUCE_BROWSER_VERSION" => "not_version",
72
+ "SAUCE_OS" => "not_os"
73
+ }
74
+ }
75
+
76
+ it "should extract the browsers" do
77
+ opts = test_config.send(:extract_options_from_hash, browsers)
78
+ opts[:browsers].should eq([
79
+ ["os1", "ie1", "version1"],
80
+ ["os2", "ie2", "version2"]
81
+ ])
82
+ end
83
+ end
84
+
85
+ context "when passed browsers in a json array keyed to SAUCE_BROWSERS" do
86
+ let(:browsers) {
87
+ { "SAUCE_BROWSERS" => [
88
+ {:os => "os1", :browser => "ie1", "version" => "version1"},
89
+ {:os => "os2", :browser => "ie2", "version" => "version2"}
90
+ ].to_json,
91
+ "SAUCE_BROWSER" => "not_browser",
92
+ "SAUCE_BROWSER_VERSION" => "not_version",
93
+ "SAUCE_OS" => "not_os"
94
+ }
95
+ }
96
+
97
+ it "should extract the browsers" do
98
+ opts = test_config.send(:extract_options_from_hash, browsers)
99
+ opts[:browsers].should eq([
100
+ ["os1", "ie1", "version1", nil],
101
+ ["os2", "ie2", "version2", nil]
102
+ ])
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce" do
4
+ before :each do
5
+ Sauce.clear_config
6
+ end
7
+
8
+ describe "#get_config" do
9
+ it "returns an empty config by default" do
10
+ Sauce.get_config.opts.should eq Sauce::Config.new(false).opts
11
+ end
12
+
13
+ it "Can return default options" do
14
+ Sauce.get_config(:default).opts.should eq Sauce::Config.new().opts
15
+ Sauce.get_config(:default).opts.length.should_not eq 0
16
+ end
17
+ end
18
+
19
+ describe "::Config" do
20
+ describe "#new" do
21
+ before :each do
22
+ Sauce.clear_config
23
+ end
24
+
25
+ context "passed a hash and :without_defaults => false" do
26
+ let(:c) { Sauce::Config.new(:myoption => 1337, :without_defaults => false) }
27
+
28
+ it "uses options from the hash" do
29
+ c[:myoption].should == 1337
30
+ end
31
+
32
+ it "defaults other options" do
33
+ c[:host].should equal Sauce::Config::DEFAULT_OPTIONS[:host]
34
+ end
35
+ end
36
+
37
+ context "passed a hash and :without_defaults => true" do
38
+ let(:c) { Sauce::Config.new(:myoption => 1337, :without_defaults => true) }
39
+
40
+ it "uses options from the hash" do
41
+ c[:myoption].should == 1337
42
+ end
43
+
44
+ it "does not default other options" do
45
+ c[:host].should be_nil
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,105 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce::Config" do
4
+ describe "#perfile_browsers" do
5
+ before :each do
6
+ ENV['SAUCE_PERFILE_BROWSERS'] = nil
7
+ end
8
+
9
+ after :each do
10
+ ENV['SAUCE_PERFILE_BROWSERS'] = nil
11
+ end
12
+
13
+ it "returns browsers when perfile_browsers is blank" do
14
+ expected_browsers = [
15
+ ["Linux", "Chrome", "nil"]
16
+ ]
17
+
18
+ Sauce.config do |c|
19
+ c[:browsers] = expected_browsers
20
+ end
21
+
22
+ config = Sauce::Config.new
23
+
24
+ filename = "./features/duckduck.feature"
25
+ fn = 14
26
+
27
+ Sauce::Config.new.caps_for_location(filename, fn).should eq expected_browsers
28
+ end
29
+
30
+ it "should return the browsers for the requested location" do
31
+ expected_browsers = [
32
+ ["Linux", "Chrome", "nil", {}],
33
+ ["Mac", "Safari", "5", {}]
34
+ ]
35
+
36
+ browser_hash = expected_browsers.map { |a|
37
+ {"os" => a[0], "browser" => a[1], "version" => a[2], "caps" => a[3]}
38
+ }
39
+
40
+ env_hash = {
41
+ "./features/duckduck.feature:14"=> browser_hash,
42
+ "./features/adifferent.feature"=>[
43
+ {"os"=>"Windows 7", "browser"=>"Firefox", "version"=>"19"}
44
+ ]
45
+ }
46
+
47
+ ENV['SAUCE_PERFILE_BROWSERS'] = env_hash.to_json
48
+
49
+ filename = "./features/duckduck.feature"
50
+ fn = 14
51
+
52
+ Sauce::Config.new.caps_for_location(filename, fn).should eq expected_browsers
53
+ end
54
+
55
+ it "returns the line number location if present" do
56
+ expected_browsers = [
57
+ ["Linux", "Chrome", "nil", {}],
58
+ ["Mac", "Safari", "5", {}]
59
+ ]
60
+
61
+ browser_hash = expected_browsers.map { |a|
62
+ {"os" => a[0], "browser" => a[1], "version" => a[2]}
63
+ }
64
+
65
+ env_hash = {
66
+ "./features/duckduck.feature"=>[
67
+ {"os"=>"Windows 7", "browser"=>"Firefox", "version"=>"19"}
68
+ ],
69
+ "./features/duckduck.feature:11"=> browser_hash
70
+ }
71
+
72
+ ENV['SAUCE_PERFILE_BROWSERS'] = env_hash.to_json
73
+
74
+ filename = "./features/duckduck.feature"
75
+ fn = 11
76
+
77
+ Sauce::Config.new.caps_for_location(filename, fn).should eq expected_browsers
78
+ end
79
+
80
+ it "ignores line number if it can't find it" do
81
+ expected_browsers = [
82
+ ["Linux", "Chrome", "nil", {}],
83
+ ["Mac", "Safari", "5", {}]
84
+ ]
85
+
86
+ browser_hash = expected_browsers.map { |a|
87
+ {"os" => a[0], "browser" => a[1], "version" => a[2]}
88
+ }
89
+
90
+ env_hash = {
91
+ "./features/duckduck.feature:11"=>[
92
+ {"os"=>"Windows 7", "browser"=>"Firefox", "version"=>"19"}
93
+ ],
94
+ "./features/duckduck.feature"=> browser_hash
95
+ }
96
+
97
+ ENV['SAUCE_PERFILE_BROWSERS'] = env_hash.to_json
98
+
99
+ filename = "./features/duckduck.feature"
100
+ fn = 6
101
+
102
+ Sauce::Config.new.caps_for_location(filename, fn).should eq expected_browsers
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce::Connect" do
4
+ describe "#connect" do
5
+ context "skip_connection_test is false" do
6
+
7
+ before do
8
+ Sauce.clear_config
9
+ end
10
+
11
+ it "ensures it can gain access to Sauce Connect's servers" do
12
+ end
13
+ end
14
+
15
+ context "skip_connection_test is true" do
16
+ it "does not try to connect to Sauce Connect's servers" do
17
+ end
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,212 @@
1
+ require 'spec_helper'
2
+
3
+ require 'sauce/cucumber'
4
+ # We need to pull in the cucumber_helper to effectively test cucumbery things
5
+ require 'cucumber_helper'
6
+
7
+ module Sauce::Capybara
8
+ describe Cucumber do
9
+ include Sauce::Capybara::Cucumber
10
+ include Sauce::Cucumber::SpecHelper
11
+
12
+ before :each do
13
+ Sauce::Utilities::Connect.stub(:start) {}
14
+ end
15
+
16
+ describe '#use_sauce_driver' do
17
+ before :each do
18
+ ::Capybara.current_driver = :test
19
+ end
20
+
21
+ it 'should change Capybara.current_driver to :sauce' do
22
+ use_sauce_driver
23
+ ::Capybara.current_driver.should == :sauce
24
+ end
25
+ end
26
+
27
+ describe 'generating job names' do
28
+ context 'with a simple, standard scenario' do
29
+ let(:scenario) do
30
+ s = double('Cucumber::AST::Scenario')
31
+ s.stub(:name).and_return('This is a simple scenario')
32
+ s
33
+ end
34
+ let(:feature) do
35
+ f = double('Cucumber::AST::Feature')
36
+ f.stub(:short_name).and_return('A simple feature')
37
+ f
38
+ end
39
+
40
+ before :each do
41
+ scenario.stub(:feature).and_return(feature)
42
+ end
43
+
44
+ describe '#name_from_scenario' do
45
+ it 'should generated a useful name' do
46
+ expected = 'A simple feature - This is a simple scenario'
47
+ name_from_scenario(scenario).should == expected
48
+ end
49
+ end
50
+
51
+ describe 'jenkins_name_from_scenario' do
52
+ it 'should generate the dotted name the Jenkins plugin wants' do
53
+ expected = 'A simple feature.This is a simple scenario.This is a simple scenario'
54
+ jenkins_name_from_scenario(scenario).should == expected
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ context 'Around hook' do
61
+ let(:session_id) { 'deadbeef' }
62
+ let(:driver) do
63
+ driver = double('Sauce::Selenium2 Driver')
64
+ driver.stub(:finish!)
65
+ driver.stub_chain(:browser, :quit)
66
+ driver.stub_chain(:browser, :session_id).and_return(session_id)
67
+ driver
68
+ end
69
+
70
+ before :each do
71
+ # Need to create our nice mocked Capybara driver
72
+ Capybara.stub_chain(:current_session, :driver).and_return(driver)
73
+ SauceWhisk::Job.stub(:new).and_return(nil)
74
+ Sauce::Selenium2.stub(:new).with(anything).and_return Object.new
75
+ Sauce.config do |c|
76
+ c[:browsers] = [
77
+ ["OS X 10.8", "Safari", "6"],
78
+ ["Linux", "Chrome", nil]
79
+ ]
80
+ end
81
+ end
82
+
83
+ context 'with a scenario outline' do
84
+ before :each do
85
+ $ran_scenario = 0
86
+ end
87
+
88
+ let(:feature) do
89
+ """
90
+ Feature: A dummy feature with a table
91
+ @selenium
92
+ Scenario Outline: Mic check
93
+ Given a <Number>
94
+ When I raise no exceptions
95
+ Examples: Numbers
96
+ | Number |
97
+ | 1 |
98
+ | 2 |
99
+ """
100
+ end
101
+
102
+ it 'should have executed the scenario twice for each browser' do
103
+ define_steps do
104
+ Given /^a (\d+)$/ do |number|
105
+ $ran_scenario = $ran_scenario + 1
106
+ end
107
+ When /^I raise no exceptions$/ do
108
+ end
109
+ # Set up and invoke our defined Around hook
110
+ Around('@selenium') do |scenario, block|
111
+ # We need to fully reference the module function here due to a
112
+ # change in scoping that will happen to this block courtesy of
113
+ # define_steps
114
+ Sauce::Capybara::Cucumber.around_hook(scenario, block)
115
+ end
116
+ end
117
+
118
+ run_defined_feature feature
119
+ $ran_scenario.should eq 4 # 2 browsers, two examples
120
+ end
121
+
122
+ end
123
+
124
+ context "when using sauce/connect" do
125
+ let(:feature) do
126
+ """
127
+ Feature: A dummy feature
128
+ @selenium
129
+ Scenario: A dummy scenario
130
+ Given a scenario
131
+ When I raise no exceptions
132
+ """
133
+ end
134
+
135
+ before :each do
136
+ Sauce.config do |c|
137
+ c[:start_tunnel] = true
138
+ end
139
+ $ran_scenario = nil
140
+ end
141
+
142
+ after :all do
143
+ Sauce::Utilities::Connect.stub(:start) {}
144
+ end
145
+
146
+ it 'should have set up a tunnel' do
147
+ define_steps do
148
+ Given /^a scenario$/ do
149
+ end
150
+ When /^I raise no exceptions$/ do
151
+ $ran_scenario = true
152
+ end
153
+ # Set up and invoke our defined Around hook
154
+ Around('@selenium') do |scenario, block|
155
+ # We need to fully reference the module function here due to a
156
+ # change in scoping that will happen to this block courtesy of
157
+ # define_steps
158
+ Sauce::Capybara::Cucumber.around_hook(scenario, block)
159
+ end
160
+ end
161
+
162
+ # Make sure we actually configure ourselves
163
+ Sauce::Utilities::Connect.should_receive(:start).with(anything).and_return {true}
164
+ run_defined_feature feature
165
+ $ran_scenario.should be true
166
+ end
167
+ end
168
+
169
+ context 'with a correct scenario' do
170
+ let(:feature) do
171
+ """
172
+ Feature: A dummy feature
173
+ @selenium
174
+ Scenario: A dummy scenario
175
+ Given a scenario
176
+ When I raise no exceptions
177
+ """
178
+ end
179
+
180
+ before :each do
181
+ # Using this gnarly global just because it's easier to just use a
182
+ # global than try to fish the scenario results back out of the
183
+ # Cucumber bits
184
+ $ran_scenario = 0
185
+ end
186
+
187
+ it 'should have executed the feature once for each browser' do
188
+ define_steps do
189
+ Given /^a scenario$/ do
190
+ end
191
+ When /^I raise no exceptions$/ do
192
+ $ran_scenario += 1
193
+ end
194
+ # Set up and invoke our defined Around hook
195
+ Around('@selenium') do |scenario, block|
196
+ # We need to fully reference the module function here due to a
197
+ # change in scoping that will happen to this block courtesy of
198
+ # define_steps
199
+ Sauce::Capybara::Cucumber.around_hook(scenario, block)
200
+ end
201
+ end
202
+
203
+ # Make sure we actually configure ourselves
204
+ Sauce.should_receive(:config)
205
+ run_defined_feature feature
206
+ $ran_scenario.should eq 2 # Two browsers
207
+ end
208
+ end
209
+ end
210
+ end
211
+ end
212
+