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,73 @@
1
+ require "spec_helper"
2
+
3
+ describe "Sauce::Config" do
4
+ describe "#browser" do
5
+
6
+ after :all do
7
+ ENV["TEST_ENV_NUMBER"] = nil
8
+ end
9
+
10
+ context "when @opts[:browser] is not nil" do
11
+ it "returns @opts[:browser]" do
12
+ Sauce.clear_config
13
+
14
+ Sauce.config do |c|
15
+ c[:browser] = "Opera"
16
+ end
17
+
18
+ Sauce::Config.new.browser.should eq "Opera"
19
+ end
20
+
21
+ it "defaults version to blank for Chrome" do
22
+ Sauce.clear_config
23
+
24
+ Sauce.config do |c|
25
+ c[:browser] = "Chrome"
26
+ c[:os] = "Windows"
27
+ end
28
+
29
+ Sauce::Config.new.browser_version.should eq nil
30
+ end
31
+ end
32
+
33
+ context "when @opts[:browser] is nil" do
34
+ context "and this is not parallel test" do
35
+ it "defaults to the first row of :browsers" do
36
+ Sauce.clear_config
37
+
38
+ ENV["TEST_ENV_NUMBER"] = nil
39
+
40
+ Sauce.config do |c|
41
+ c[:browsers] = [["Windows", "Opera", 10]]
42
+ end
43
+
44
+ Sauce::Config.new.browser.should eq "Opera"
45
+ end
46
+ end
47
+
48
+ context "and this is *not* a parallel test" do
49
+ it "should return the value set for :browser" do
50
+ ENV["TEST_ENV_NUMBER"] = "2"
51
+
52
+ Sauce.clear_config
53
+
54
+ expect {
55
+ Sauce::Config.new.browser.should_raise
56
+ }.to raise_exception(StandardError, no_browser_message)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ def no_browser_message
64
+ <<-MESSAGE
65
+ No browser has been configured.
66
+
67
+ It seems you're trying to run your tests in parallel, but haven't configured your specs/tests to use the Sauce integration.
68
+
69
+ To fix this, add :sauce => true to your specs or make your tests subclasses of Sauce::TestCase or Sauce::RailsTestCase.
70
+
71
+ For more details check the gem readme at https://github.com/saucelabs/sauce_ruby/blob/master/README.markdown
72
+ MESSAGE
73
+ end
@@ -0,0 +1,400 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+ require 'sauce/config'
3
+
4
+ describe Sauce::Config do
5
+ let(:c) do
6
+ config = Sauce::Config.new
7
+ config.stub(:silence_warnings).and_return(true)
8
+ config
9
+ end
10
+ before :each do
11
+ Sauce.clear_config
12
+ end
13
+
14
+ describe '#[]' do
15
+ it "should return nil for options that don't exist" do
16
+ c = Sauce::Config.new
17
+ c[:undefined].should be_nil
18
+ end
19
+
20
+ it "should return defaults if they haven't been set" do
21
+ c = Sauce::Config.new
22
+ c[:browser].should == Sauce::Config::DEFAULT_OPTIONS[:browser]
23
+ end
24
+
25
+ it "should return the value set in the constructor" do
26
+ c = Sauce::Config.new(:myoption => 1337)
27
+ c[:myoption].should == 1337
28
+ end
29
+ end
30
+
31
+ describe "#[]=" do
32
+ it "should allow setting arbitrary options" do
33
+ c[:setting_option] = 1337
34
+ c[:setting_option].should == 1337
35
+ end
36
+
37
+ it "should allow using strings for keys" do
38
+ c["my-option"] = 1337
39
+ c["my-option"].should == 1337
40
+ end
41
+ end
42
+
43
+ describe 'deprecate method_missing' do
44
+ it 'should warn when accessing an old style method' do
45
+ c.stub(:silence_warnings).and_return(false)
46
+ c.should_receive(:warn).with(anything)
47
+ c.start_tunnel
48
+ end
49
+ end
50
+
51
+ describe '#host' do
52
+ it 'should return ondemand.saucelabs.com by default' do
53
+ c.host.should == 'ondemand.saucelabs.com'
54
+ end
55
+ end
56
+
57
+ describe '#os' do
58
+ it 'should return the value set in the config block' do
59
+ Sauce.config do |config|
60
+ config[:os] = 'TEST_OS'
61
+ end
62
+
63
+ c = Sauce::Config.new
64
+ c[:os].should == 'TEST_OS'
65
+ end
66
+ end
67
+
68
+ describe '#to_browser_string' do
69
+ before :each do
70
+ @original_env = {}
71
+ Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
72
+ @original_env[key] = ENV[key] if ENV[key]
73
+ end
74
+ end
75
+
76
+ it 'should create a browser string when running under the Jenkins plugin' do
77
+ browsers_string = "[{\"os\":\"LINUX\",\"browser\":\"opera\",\"url\":\"sauce-ondemand:?os=Linux&browser=opera&browser-version=12\",\"browser-version\":\"12\"}]"
78
+ browsers = JSON.parse(browsers_string)
79
+ ENV['SAUCE_ONDEMAND_BROWSERS'] = browsers_string
80
+
81
+ config = Sauce::Config.new
82
+ result = JSON.parse(config.to_browser_string)
83
+
84
+ result['os'].should == browsers.first['os']
85
+ result['browser'].should == browsers.first['browser']
86
+ result['browser-version'].should == browsers.first['browser-version']
87
+ end
88
+
89
+ it 'should create a browser string from the environment' do
90
+ ENV['SAUCE_USERNAME'] = "test_user"
91
+ ENV['SAUCE_ACCESS_KEY'] = "test_access"
92
+ ENV['SAUCE_OS'] = "Linux"
93
+ ENV['SAUCE_BROWSER'] = "firefox"
94
+ ENV['SAUCE_BROWSER_VERSION'] = "3."
95
+ ENV['BUILD_TAG'] = 'test env build'
96
+
97
+ config = Sauce::Config.new
98
+ browser_data = JSON.parse(config.to_browser_string)
99
+ browser_data.should == {'name' => 'Unnamed Ruby job',
100
+ 'access-key' => 'test_access',
101
+ 'os' => 'Linux',
102
+ 'username' => 'test_user',
103
+ 'browser-version' => '3.',
104
+ 'browser' => 'firefox',
105
+ 'build' => 'test env build'}
106
+ end
107
+
108
+ it 'should create a browser string from the environment set by the jenkins plugin' do
109
+ ENV['SAUCE_USERNAME'] = 'test_user'
110
+ ENV['SAUCE_ACCESS_KEY'] = 'test_access'
111
+ ENV['SAUCE_OS'] = 'Linux'
112
+ ENV['SAUCE_BROWSER'] = 'firefox'
113
+ ENV['SAUCE_BROWSER_VERSION'] = '3.'
114
+ ENV['SAUCE_JOB_NAME'] = 'Named Ruby Job'
115
+ ENV['BUILD_TAG'] = 'test env build'
116
+
117
+ config = Sauce::Config.new
118
+ browser_data = JSON.parse(config.to_browser_string)
119
+ browser_data.should == {'name' => 'Named Ruby Job',
120
+ 'access-key' => 'test_access',
121
+ 'os' => 'Linux',
122
+ 'username' => 'test_user',
123
+ 'browser-version' => '3.',
124
+ 'browser' => 'firefox',
125
+ 'build' => 'test env build'}
126
+
127
+ end
128
+
129
+ it 'should create a browser string from parameters' do
130
+ config = Sauce::Config.new(:username => 'test_user',
131
+ :access_key => 'test_access',
132
+ :os => 'Linux',
133
+ :browser => 'firefox',
134
+ :browser_version => '3.',
135
+ :build => 'test param build')
136
+
137
+ browser_data = JSON.parse(config.to_browser_string)
138
+ browser_data.should == {'name' => 'Unnamed Ruby job',
139
+ 'access-key' => 'test_access',
140
+ 'os' => 'Linux',
141
+ 'username' => 'test_user',
142
+ 'browser-version' => '3.',
143
+ 'browser' => 'firefox',
144
+ 'build' => 'test param build'}
145
+ end
146
+
147
+ it 'should create a browser string with optional parameters' do
148
+ config = Sauce::Config.new(:username => "test_user", :access_key => "test_access",
149
+ :os => "Linux", :browser => "firefox", :browser_version => "3.",
150
+ :build => "test opt build",
151
+ :"user-extensions-url" => "testing")
152
+ browser_data = JSON.parse(config.to_browser_string)
153
+ browser_data.should == {'name' => 'Unnamed Ruby job',
154
+ 'access-key' => 'test_access',
155
+ 'os' => 'Linux',
156
+ 'username' => 'test_user',
157
+ 'browser-version' => '3.',
158
+ 'browser' => 'firefox',
159
+ 'build' => 'test opt build',
160
+ 'user-extensions-url' => 'testing',
161
+ }
162
+ end
163
+
164
+ it 'should create a browser string with optional parameters as underscored symbols' do
165
+ config = Sauce::Config.new(:username => "test_user", :access_key => "test_access",
166
+ :os => "Linux", :browser => "firefox", :browser_version => "3.",
167
+ :build => "test opt build",
168
+ :user_extensions_url => "testing")
169
+ browser_data = JSON.parse(config.to_browser_string)
170
+ browser_data.should == {'name' => 'Unnamed Ruby job',
171
+ 'access-key' => 'test_access',
172
+ 'os' => 'Linux',
173
+ 'username' => 'test_user',
174
+ 'browser-version' => '3.',
175
+ 'browser' => 'firefox',
176
+ 'build' => 'test opt build',
177
+ 'user-extensions-url' => 'testing'}
178
+ end
179
+
180
+ after :each do
181
+ Sauce::Config::ENVIRONMENT_VARIABLES.each do |key|
182
+ ENV[key] = @original_env[key]
183
+ end
184
+ end
185
+ end
186
+
187
+ describe '#to_desired_capabilities' do
188
+ context 'with custom sauce options' do
189
+ context 'max-duration' do
190
+ subject do
191
+ Sauce::Config.new(:'max-duration' => 600).to_desired_capabilities
192
+ end
193
+
194
+ it { should have_key :'max-duration' }
195
+ end
196
+
197
+ context "prerun" do
198
+ subject do
199
+ Sauce::Config.new('prerun' => "Something Prerun").to_desired_capabilities
200
+ end
201
+
202
+ it { should have_key :'prerun'}
203
+ end
204
+
205
+ context 'iedriver-version' do
206
+ subject do
207
+ Sauce::Config.new('iedriver-version' => '2.30.1').to_desired_capabilities
208
+ end
209
+
210
+ it { should have_key :'iedriver-version' }
211
+ end
212
+ end
213
+
214
+ context 'with a :name set' do
215
+ subject do
216
+ Sauce::Config.new(:name => 'As Sweet').to_desired_capabilities[:name]
217
+ end
218
+
219
+ it {should eq "As Sweet"}
220
+ end
221
+
222
+ context 'platforms' do
223
+ it 'should refer to Windows 2003 as WINDOWS' do
224
+ config = Sauce::Config.new(:os => "Windows 2003")
225
+ config.to_desired_capabilities[:platform].should == 'WINDOWS'
226
+ end
227
+
228
+ it 'should refer to Windows 2008 as VISTA' do
229
+ config = Sauce::Config.new(:os => "Windows 2008")
230
+ config.to_desired_capabilities[:platform].should == 'VISTA'
231
+ end
232
+ end
233
+
234
+ context 'client_version' do
235
+ let(:config) {Sauce::Config.new()}
236
+
237
+ it 'should include the Ruby engine' do
238
+ config.to_desired_capabilities[:client_version].should include RUBY_ENGINE
239
+ end
240
+
241
+ it "should include the ruby platform" do
242
+ config.to_desired_capabilities[:client_version].should include RUBY_PLATFORM
243
+ end
244
+
245
+ it "should include the ruby version" do
246
+ config.to_desired_capabilities[:client_version].should include RUBY_VERSION
247
+ end
248
+
249
+ it "should include the gem version" do
250
+ config.to_desired_capabilities[:client_version].should include Sauce.version
251
+ end
252
+
253
+ it "should include a bracketed array of tools in use" do
254
+ config.to_desired_capabilities[:client_version].should include config.tools.to_s
255
+ end
256
+ end
257
+
258
+ context 'with unusual options' do
259
+ let(:config) {Sauce::Config.new}
260
+
261
+ it 'should ignore them by default' do
262
+ config[:new_option] = 'caramel'
263
+ config.to_desired_capabilities[:new_option].should be_nil
264
+ end
265
+
266
+ it 'should include them when configured with exceptions' do
267
+ config[:new_option] = 'elderflower'
268
+ config.whitelist :new_option
269
+ config.to_desired_capabilities[:new_option].should include 'elderflower'
270
+ end
271
+
272
+ it 'should include them when created anew' do
273
+ config.whitelist :new_option
274
+ config_two = Sauce::Config.new({})
275
+ config_two[:new_option] = 'elderflower'
276
+ config_two.to_desired_capabilities[:new_option].should include 'elderflower'
277
+ end
278
+
279
+ it 'should allow multiple exceptions' do
280
+ config[:new_option] = 'elderflower'
281
+ config[:another_option] = 'mint'
282
+ config.whitelist :new_option
283
+ config.whitelist :another_option
284
+
285
+ config.to_desired_capabilities[:new_option].should include 'elderflower'
286
+ config.to_desired_capabilities[:another_option].should include 'mint'
287
+ config.to_desired_capabilities[:not_an_option].should be_nil
288
+ end
289
+ end
290
+ end
291
+
292
+ describe "#tools" do
293
+ let(:config) {Sauce::Config.new}
294
+
295
+ before :each do
296
+ config.stub(:is_defined?).and_call_original
297
+ end
298
+
299
+ it "should include rspec if present" do
300
+ config.tools.should include "Rspec"
301
+ end
302
+
303
+ it "should include capybara" do
304
+ config.stub(:is_defined?).with("Capybara") {true}
305
+ config.tools.should include "Capybara"
306
+ end
307
+
308
+ it "should not include capybara when absent" do
309
+ config.stub(:is_defined?).with("Capybara") {false}
310
+ config.tools.should_not include "Capybara"
311
+ end
312
+
313
+ it "should not include cucumber when not present" do
314
+ config.stub(:is_defined?).with("Cucumber") {false}
315
+ config.tools.should_not include "Cucumber"
316
+ end
317
+
318
+ it "should include cucumber when present" do
319
+ config.stub(:is_defined?).with("Cucumber") {true}
320
+ config.tools.should include "Cucumber"
321
+ end
322
+
323
+ it "should include test::unit if present" do
324
+ config.stub(:is_defined?).with("Test","Unit") {true}
325
+ config.tools.should include "Test::Unit"
326
+ end
327
+
328
+ it "should not include test::unit if absent" do
329
+ config.stub(:is_defined?).with("Test", "Unit") {false}
330
+ config.tools.should_not include "Test::Unit"
331
+ end
332
+ end
333
+
334
+ context 'configuring Sauce' do
335
+ it 'should make foo? methods for set boolean values' do
336
+ c.some_option = true
337
+ c.some_option?.should be true
338
+ end
339
+
340
+ it 'should allow overrides as constructor options' do
341
+ Sauce.config do |config|
342
+ config[:browsers] = [['OS1', 'BROWSER1', 'BROWSER_VERSION1']]
343
+ end
344
+
345
+ c = Sauce::Config.new(:os => 'OS2', :browser => 'BROWSER2',
346
+ :browser_version => 'BROWSER_VERSION2')
347
+ c.os.should == 'OS2'
348
+ c.browser.should == 'BROWSER2'
349
+ c.browser_version.should == 'BROWSER_VERSION2'
350
+ end
351
+ end
352
+
353
+ describe "#"
354
+ end
355
+
356
+ describe Sauce do
357
+
358
+ # Ensure any doubles are removed to stop other tests choking
359
+ after :all do
360
+ Sauce.clear_config
361
+ end
362
+
363
+ describe '#get_config' do
364
+ context 'when #config has never been called' do
365
+ # See: <https://github.com/sauce-labs/sauce_ruby/issues/59>
366
+ before :each do
367
+ # This is kind of hack-ish, but the best way I can think to properly
368
+ # prevent this class variable from existing
369
+ Sauce.instance_variable_set(:@cfg, nil)
370
+ end
371
+
372
+ it 'should return a newly created Sauce::Config' do
373
+ dummy_config = double('Sauce::Config')
374
+ Sauce::Config.should_receive(:new).and_return(dummy_config)
375
+ Sauce.get_config.should_not be nil
376
+ end
377
+ end
378
+
379
+ context 'when config has been called' do
380
+ before :each do
381
+ Sauce.clear_config
382
+ Sauce.config do |c|
383
+ c[:some_setting] = true
384
+ end
385
+ end
386
+ it 'should return the same config with the same configuration' do
387
+ Sauce.get_config.should_not be nil
388
+ Sauce.get_config[:some_setting].should be true
389
+ end
390
+ end
391
+ end
392
+
393
+ describe '#clear_config' do
394
+ it 'should reset the config object' do
395
+ c = Sauce.get_config
396
+ Sauce.clear_config
397
+ c.should_not equal(Sauce.get_config)
398
+ end
399
+ end
400
+ end