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,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "DriverPool" do
4
+
5
+ it "should be a hash" do
6
+ Sauce.driver_pool.should be_an_instance_of Hash
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe Sauce::Selenium2 do
4
+ describe "#file_detector" do
5
+ it "should return the path of files when they exist" do
6
+ Selenium::WebDriver::Remote::Bridge.any_instance.stub(:create_session).and_return({})
7
+
8
+ path = __FILE__
9
+
10
+ client = Sauce::Selenium2.new()
11
+ bridge = client.driver.instance_variable_get(:@bridge)
12
+ bridge.file_detector.call([path]).should eq path
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'sauce/jasmine'
3
+
4
+ describe Jasmine::SeleniumDriver do
5
+ describe '#initialize' do
6
+ let(:address) { 'http://saucelabs.com' }
7
+ let(:browser) { 'firefox' }
8
+
9
+ it 'should take set the @http_address' do
10
+ Sauce::Selenium2.stub(:new)
11
+ d = Jasmine::SeleniumDriver.new(browser, address)
12
+ d.http_address.should equal(address)
13
+ end
14
+
15
+ it 'should initialize a Sauce driver' do
16
+ Sauce::Selenium2.should_receive(:new).with(anything).and_return(true)
17
+ d = Jasmine::SeleniumDriver.new(browser, address)
18
+ d.should_not be_nil
19
+ end
20
+ end
21
+ end
22
+
23
+
24
+ describe Jasmine::Configuration do
25
+ describe '#port' do
26
+ it 'returns 3001' do
27
+ expect(Jasmine::Configuration.new.port).to eq(3001)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,77 @@
1
+ require "json"
2
+ require "rspec"
3
+ require "sauce/parallel/test_broker"
4
+
5
+ describe Sauce::TestBroker do
6
+
7
+ describe "#next_environment" do
8
+
9
+ before :each do
10
+ Sauce::TestBroker.reset
11
+ end
12
+
13
+ it "returns the first browser for new entries" do
14
+ first_environment = Sauce::TestBroker.next_environment ["spec/a_spec"]
15
+ first_environment.should eq({
16
+ :SAUCE_PERFILE_BROWSERS => (
17
+ "'" +
18
+ JSON.generate({"./spec/a_spec" => [{"os" => "Windows 7",
19
+ "browser" => "Opera",
20
+ "version" => "10"}]}) +
21
+ "'")
22
+ })
23
+ end
24
+
25
+ it "only returns a browser once for a given file" do
26
+ Sauce::TestBroker.next_environment ["spec/a_spec"]
27
+ second_environment = Sauce::TestBroker.next_environment ["spec/a_spec"]
28
+
29
+ second_environment.should eq({
30
+ :SAUCE_PERFILE_BROWSERS => (
31
+ "'" +
32
+ JSON.generate({"./spec/a_spec" => [{"os" => "Linux",
33
+ "browser" => "Firefox",
34
+ "version" => "19"}]}) +
35
+ "'")
36
+ })
37
+ end
38
+
39
+ it "returns multiple browsers for files given multiple times" do
40
+ first_environment = Sauce::TestBroker.next_environment ["spec/a_spec",
41
+ "spec/a_spec"]
42
+ first_environment.should eq({
43
+ :SAUCE_PERFILE_BROWSERS => (
44
+ "'" +
45
+ JSON.generate({"./spec/a_spec" => [{"os" => "Windows 7",
46
+ "browser" => "Opera",
47
+ "version" => "10"},
48
+ {"os" => "Linux",
49
+ "browser" => "Firefox",
50
+ "version" => "19"}]}) +
51
+ "'")
52
+ })
53
+ end
54
+
55
+ it "uses the first browser for each of multiple files" do
56
+ first_environment = Sauce::TestBroker.next_environment ["spec/a_spec",
57
+ "spec/b_spec"]
58
+ first_environment.should eq({
59
+ :SAUCE_PERFILE_BROWSERS => (
60
+ "'" +
61
+ JSON.generate({"./spec/a_spec" => [{"os" => "Windows 7",
62
+ "browser" => "Opera",
63
+ "version" => "10"}],
64
+ "./spec/b_spec" => [{"os" => "Windows 7",
65
+ "browser" => "Opera",
66
+ "version" => "10"}]}) +
67
+ "'")
68
+ })
69
+ end
70
+ end
71
+
72
+ describe "#test_platforms" do
73
+ it "should report the same groups as configured in Sauce.config" do
74
+ Sauce::TestBroker.test_platforms.should eq Sauce.get_config.browsers
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Sauce::Selenium2 do
4
+ describe "itself" do
5
+
6
+ before :each do
7
+ mock_driver = double(::Selenium::WebDriver::Driver)
8
+ mock_driver.stub(:file_detector=)
9
+ ::Selenium::WebDriver.should_receive(:for).and_return(mock_driver)
10
+ end
11
+
12
+ describe '#initialize' do
13
+ it 'should work without arguments' do
14
+ client = Sauce::Selenium2.new
15
+ client.should_not be nil
16
+ end
17
+
18
+ it 'should pass the job_name argument into the config' do
19
+ expected = 'Dummy Job Name'
20
+ client = Sauce::Selenium2.new(:job_name => expected)
21
+ client.config[:job_name].should == expected
22
+ end
23
+ end
24
+
25
+
26
+ context 'with an initialized object' do
27
+ before :each do
28
+ @client = Sauce::Selenium2.new
29
+ end
30
+
31
+ describe '#stop' do
32
+ it 'should call quit on the driver' do
33
+ @client.driver.should_receive(:quit).and_return(true)
34
+ @client.stop
35
+ end
36
+ end
37
+
38
+ describe '#session_id' do
39
+ it 'should query the driver for the session_id' do
40
+ expected = 101
41
+ bridge = double('bridge')
42
+ bridge.should_receive(:session_id).and_return(expected)
43
+ @client.driver.should_receive(:bridge).and_return(bridge)
44
+ @client.session_id.should == expected
45
+ end
46
+ end
47
+
48
+ describe '#method_missing' do
49
+ it 'should pass #navigate#to onto the driver' do
50
+ url = 'http://example.com'
51
+ navigator = double('navigator')
52
+ navigator.should_receive(:to).with(url).and_return(true)
53
+ @client.driver.should_receive(:navigate).and_return(navigator)
54
+
55
+ @client.navigate.to url
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,180 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'parse_task_args' do
4
+ before :each do
5
+ Sauce::TestBroker.stub(:concurrency) {20}
6
+ end
7
+
8
+ it 'returns the saucerspec type when using rspec' do
9
+ actual_args = parse_task_args(:rspec, {}).join ' '
10
+ actual_args.should include '--type saucerspec'
11
+ end
12
+
13
+ it 'returns the saucecucumber type when using cucumber' do
14
+ actual_args = parse_task_args(:cucumber, {}).join ' '
15
+ actual_args.should include '--type saucecucumber'
16
+ end
17
+
18
+ context 'files' do
19
+ it 'is parsed from the :files argument' do
20
+ task_args = {:files => 'proscuitto/iberico.spec'}
21
+ actual_args = parse_task_args(task_args).join ' '
22
+ actual_args.end_with?('proscuitto/iberico.spec').should be_true
23
+ end
24
+
25
+ it 'defaults to spec when rspec is used' do
26
+ actual_args = parse_task_args(:rspec, {}).join ' '
27
+ actual_args.end_with?('spec').should be_true
28
+ end
29
+
30
+ it 'defaults to features when cucumber is used' do
31
+ actual_args = parse_task_args(:cucumber, {}).join ' '
32
+ actual_args.end_with?('features').should be_true
33
+ end
34
+
35
+ context 'when set by environment variable' do
36
+ before :each do
37
+ @stored_test_files = ENV['test_files']
38
+ ENV['test_files'] = nil
39
+ end
40
+
41
+ after :each do
42
+ ENV['test_files'] = @stored_test_files
43
+ end
44
+
45
+ it 'comes from the test_files variable' do
46
+ ENV['test_files'] = 'pancetta'
47
+ actual_args = parse_task_args(:rspec, {}).join ' '
48
+ actual_args.end_with?('pancetta').should be_true
49
+ end
50
+
51
+ it 'is overridden by the CLI' do
52
+ ENV['test_files'] = 'spam'
53
+ test_args = {:files => 'bacon'}
54
+ actual_args = parse_task_args(:rspec, test_args).join ' '
55
+ actual_args.end_with?('bacon').should be_true
56
+ actual_args.should_not include 'spam'
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'concurrency' do
62
+ it 'parses the second argument' do
63
+ task_args = {:features => 'features', :concurrency => '4'}
64
+ actual_args = parse_task_args(task_args).join ' '
65
+ actual_args.should include '-n 4'
66
+ end
67
+
68
+ context 'when set by environment variable' do
69
+ before :each do
70
+ @stored_concurrency = ENV['concurrency']
71
+ ENV['concurrency'] = nil
72
+ end
73
+
74
+ after :each do
75
+ ENV['concurrency'] = @stored_concurrency
76
+ end
77
+
78
+ it 'is parsed out' do
79
+ ENV['concurrency'] = '18'
80
+ actual_args = parse_task_args({}).join ' '
81
+ actual_args.should include '-n 18'
82
+ end
83
+
84
+ it 'is overridden by the CLI' do
85
+ ENV['concurrency'] = '14'
86
+ task_args = {:files => 'features', :concurrency => '12'}
87
+ actual_args = parse_task_args(task_args).join ' '
88
+ actual_args.should include '-n 12'
89
+ end
90
+ end
91
+
92
+ context 'test options' do
93
+ it 'are parsed from the test_options argument' do
94
+ task_args = {:test_options => '--no-derp'}
95
+ actual_args = parse_task_args(task_args).join ' '
96
+ actual_args.should include '-o --no-derp'
97
+ end
98
+
99
+ context 'when not supplied' do
100
+ it 'default to -t sauce for rspec' do
101
+ actual_args = parse_task_args(:rspec, {}).join ' '
102
+ actual_args.should include '-o -t sauce'
103
+ end
104
+
105
+ it 'defaults to not being present for cucumber' do
106
+ actual_args = parse_task_args(:cucumber, {}).join ' '
107
+ actual_args.should_not include '-o'
108
+ end
109
+ end
110
+
111
+ context 'when set from environment options' do
112
+ before :each do
113
+ @stored_rspec_options = ENV['test_options']
114
+ ENV['test_options'] = nil
115
+ end
116
+
117
+ after :each do
118
+ ENV['test_options'] = @stored_rspec_options
119
+ end
120
+
121
+ it 'is read from the test_options variable' do
122
+ ENV['test_options'] = '-derp_level some'
123
+ actual_args = parse_task_args({}).join ' '
124
+ actual_args.should include '-o -derp_level some'
125
+ end
126
+
127
+ it 'is overridden by the CLI' do
128
+ ENV['test_options'] = '-derp_level maximum'
129
+ task_args = {:test_options => '--no-derp'}
130
+ actual_args = parse_task_args(task_args).join ' '
131
+ actual_args.should_not include '-derp_level maximum'
132
+ actual_args.should include '-o --no-derp'
133
+ end
134
+ end
135
+ end
136
+
137
+ context "parallel tests options" do
138
+ it 'is parsed from the parallel_options argument' do
139
+ test_args = {:parallel_options => 'wow'}
140
+ actual_args = parse_task_args(test_args).join ' '
141
+ actual_args.should include 'wow'
142
+ end
143
+
144
+ it 'is broken into individual options' do
145
+ test_args = {:parallel_options => '--scared so'}
146
+ actual_args = parse_task_args(:rspec, test_args)
147
+
148
+ actual_args.should include '--scared'
149
+ actual_args.should include 'so'
150
+ index = actual_args.index '--scared'
151
+ actual_args[index + 1].should eq 'so'
152
+ end
153
+
154
+ context 'read from environment variables' do
155
+ before :each do
156
+ @@stored_rspec_options = ENV['rspec_options']
157
+ ENV['parallel_test_options'] = nil
158
+ end
159
+
160
+ after :each do
161
+ ENV['parallel_test_options'] = @@stored_rspec_options
162
+ end
163
+
164
+ it 'is read from the parallel_test_options variable' do
165
+ ENV['parallel_test_options'] = '-such option'
166
+ actual_args = parse_task_args({}).join ' '
167
+ actual_args.should include '-such option'
168
+ end
169
+
170
+ it 'is overridden by the CLI' do
171
+ ENV['parallel_test_options'] = '-such option'
172
+ task_args = {:parallel_options => 'many override'}
173
+ actual_args = parse_task_args(task_args).join ' '
174
+ actual_args.should_not include '-such option'
175
+ actual_args.should include 'many override'
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -0,0 +1,109 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce::Utilities::RailsServer" do
4
+ let (:server) {Sauce::Utilities::RailsServer.new}
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
+
20
+ context "With a Rails 4 app" do
21
+ before (:each) do
22
+ File.stub(:exists?).and_return false
23
+ File.stub(:exists?).with("bin/rails").and_return true
24
+ end
25
+
26
+ describe "#is_rails_app?" do
27
+ it "should be true" do
28
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
29
+ end
30
+ end
31
+
32
+ describe "#major_version" do
33
+ it "should be 4" do
34
+ Sauce::Utilities::RailsServer.major_version.should eq 4
35
+ end
36
+ end
37
+
38
+ describe "#process_arguments" do
39
+ it "returns bundle exec rails server" do
40
+ expected_args = %w{bundle exec rails server}
41
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
42
+ end
43
+ end
44
+ end
45
+
46
+ context "With a Rails 3 app" do
47
+ before (:each) do
48
+ File.stub(:exists?).and_return false
49
+ File.stub(:exists?).with("script/rails").and_return true
50
+ end
51
+
52
+ describe "#is_rails_app?" do
53
+ it "should be true" do
54
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
55
+ end
56
+ end
57
+
58
+ describe "#major_version" do
59
+ it "should be 3" do
60
+ Sauce::Utilities::RailsServer.major_version.should eq 3
61
+ end
62
+ end
63
+
64
+ describe "#process_arguments" do
65
+ it "returns bundle exec rails server" do
66
+ expected_args = %w{bundle exec rails server}
67
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
68
+ end
69
+ end
70
+ end
71
+
72
+ context "Without a Rails app" do
73
+ before (:each) do
74
+ File.stub(:exists?).and_return false
75
+ end
76
+
77
+ describe "#is_rails_app?" do
78
+ it "should be false" do
79
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_false
80
+ end
81
+ end
82
+ end
83
+
84
+ context "With a Rails 4 app" do
85
+ before (:each) do
86
+ File.stub(:exists?).and_return false
87
+ File.stub(:exists?).with("bin/rails").and_return true
88
+ end
89
+
90
+ describe "#is_rails_app?" do
91
+ it "should be true" do
92
+ Sauce::Utilities::RailsServer.is_rails_app?.should be_true
93
+ end
94
+ end
95
+
96
+ describe "#major_version" do
97
+ it "should be 4" do
98
+ Sauce::Utilities::RailsServer.major_version.should eq 4
99
+ end
100
+ end
101
+
102
+ describe "#process_arguments" do
103
+ it "returns bundle exec rails server" do
104
+ expected_args = %w{bundle exec rails server}
105
+ Sauce::Utilities::RailsServer.process_arguments.should eq expected_args
106
+ end
107
+ end
108
+ end
109
+ end