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.
- checksums.yaml +7 -0
- data/bin/sauce +103 -0
- data/lib/childprocess/process.rb +34 -0
- data/lib/generators/sauce/install/install_generator.rb +54 -0
- data/lib/parallel_tests/cli_patch.rb +23 -0
- data/lib/parallel_tests/saucecucumber/runner.rb +43 -0
- data/lib/parallel_tests/saucerspec/runner.rb +40 -0
- data/lib/sauce.rb +33 -0
- data/lib/sauce/capybara.rb +189 -0
- data/lib/sauce/client.rb +40 -0
- data/lib/sauce/config.rb +434 -0
- data/lib/sauce/driver_pool.rb +5 -0
- data/lib/sauce/heroku.rb +18 -0
- data/lib/sauce/job.rb +159 -0
- data/lib/sauce/parallel.rb +16 -0
- data/lib/sauce/parallel/test_broker.rb +110 -0
- data/lib/sauce/parallel/test_group.rb +24 -0
- data/lib/sauce/railtie.rb +11 -0
- data/lib/sauce/raketasks.rb +83 -0
- data/lib/sauce/rspec/rspec.rb +186 -0
- data/lib/sauce/rspec/rspec_formatter.rb +20 -0
- data/lib/sauce/rspec/rspec_one_support.rb +66 -0
- data/lib/sauce/selenium.rb +95 -0
- data/lib/sauce/test_base.rb +21 -0
- data/lib/sauce/test_unit.rb +111 -0
- data/lib/sauce/utilities.rb +80 -0
- data/lib/sauce/utilities/connect.rb +45 -0
- data/lib/sauce/utilities/rails_server.rb +95 -0
- data/lib/sauce/utilities/rake.rb +32 -0
- data/lib/sauce/version.rb +9 -0
- data/lib/sauce/webmock.rb +16 -0
- data/lib/tasks/parallel_testing.rb +148 -0
- data/spec/cucumber_helper.rb +42 -0
- data/spec/integration/connect/spec/spec_helper.rb +21 -0
- data/spec/integration/connect/spec/start_tunnel_spec.rb +9 -0
- data/spec/integration/connect/spec/with_capybara_spec.rb +10 -0
- data/spec/integration/connect_integration_spec.rb +99 -0
- data/spec/integration/rspec-capybara/spec/capybara_required_last_spec.rb +18 -0
- data/spec/integration/rspec-capybara/spec/integration_spec.rb +17 -0
- data/spec/integration/rspec-capybara/spec/sauce_config_spec.rb +13 -0
- data/spec/integration/rspec-capybara/spec/sauce_required_last_spec.rb +21 -0
- data/spec/integration/rspec-capybara/spec/selenium/selenium_with_capybara.rb +12 -0
- data/spec/integration/rspec-capybara/spec/spec_helper.rb +37 -0
- data/spec/integration/rspec/spec/integration_spec.rb +13 -0
- data/spec/integration/rspec/spec/selenium/selenium_directory_spec.rb +20 -0
- data/spec/integration/rspec/spec/spec_helper.rb +52 -0
- data/spec/integration/rspec/spec/tagging/selenium_tagging_spec.rb +29 -0
- data/spec/integration/testunit/test/capybara_integration_test.rb +37 -0
- data/spec/integration/testunit/test/integration_test.rb +21 -0
- data/spec/integration/testunit/test/test_helper.rb +13 -0
- data/spec/parallel_tests/sauce_rspec_runner_spec.rb +23 -0
- data/spec/sauce/capybara_spec.rb +386 -0
- data/spec/sauce/config/browser_spec.rb +73 -0
- data/spec/sauce/config/config_spec.rb +400 -0
- data/spec/sauce/config/default_browsers_spec.rb +46 -0
- data/spec/sauce/config/environment_config_spec.rb +106 -0
- data/spec/sauce/config/load_defaults_spec.rb +50 -0
- data/spec/sauce/config/perfile_browser_spec.rb +105 -0
- data/spec/sauce/connect_spec.rb +21 -0
- data/spec/sauce/cucumber_spec.rb +212 -0
- data/spec/sauce/driver_pool_spec.rb +8 -0
- data/spec/sauce/file_detector_spec.rb +15 -0
- data/spec/sauce/jasmine_spec.rb +30 -0
- data/spec/sauce/parallel/test_broker_spec.rb +77 -0
- data/spec/sauce/selenium_spec.rb +60 -0
- data/spec/sauce/tasks_spec.rb +180 -0
- data/spec/sauce/utilities/rails_server_spec.rb +109 -0
- data/spec/sauce/utilities/rake_spec.rb +46 -0
- data/spec/sauce/utilities/utilities_spec.rb +137 -0
- data/spec/sauce_helper.rb +8 -0
- data/spec/spec_helper.rb +27 -0
- metadata +390 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Capybara Examples where Capybara is included last", :type => :feature, :sauce => true do
|
4
|
+
context "When calling the #page method" do
|
5
|
+
it "should get access to a Capybara Session object" do
|
6
|
+
page.should be_a_kind_of Capybara::Session
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not output a deprecation message" do
|
10
|
+
self.should_not_receive(:warn).with(page_deprecation_warning)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should not create a new driver" do
|
15
|
+
::Sauce::Selenium2.should_not_receive(:new)
|
16
|
+
visit "http://wwww.google.com"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Capybara examples", :js => true, :sauce => true, :type => :feature do
|
4
|
+
it "should not create a new driver" do
|
5
|
+
::Sauce::Selenium2.should_not_receive(:new)
|
6
|
+
visit "http://wwww.google.com"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should get access to a Capybara Session object" do
|
10
|
+
page.should be_a_kind_of Capybara::Session
|
11
|
+
visit "http://www.google.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have the same driver as stock webdriver" do
|
15
|
+
Capybara.current_session.driver.browser.should eq @selenium
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Sauce::Config", :sauce => true do
|
4
|
+
it "should have rspec in its tool set", :sauce => true do
|
5
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
6
|
+
capabilities[:client_version].should include "Rspec"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have Capybara in its tool set", :sauce => true do
|
10
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
11
|
+
capabilities[:client_version].should include "Capybara"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Capybarad Examples where Sauce is included second", :js => true do
|
4
|
+
include Capybara::DSL
|
5
|
+
include Sauce::RSpec::SeleniumExampleGroup
|
6
|
+
|
7
|
+
context "When calling the #page method" do
|
8
|
+
it "should get access to a Capybara Session object" do
|
9
|
+
page.should be_a_kind_of Capybara::Session
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should not output a deprecation message" do
|
13
|
+
self.should_not_receive(:warn).with(page_deprecation_warning)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not create a new driver" do
|
18
|
+
::Sauce::Selenium2.should_not_receive(:new)
|
19
|
+
visit "http://wwww.google.com"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "The Selenium Directory with Capybara", :js => true do
|
4
|
+
it "should have the same driver as stock webdriver", :js => true do
|
5
|
+
Capybara.current_session.driver.browser.should eq @selenium
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should not create a new driver" do
|
9
|
+
::Sauce::Selenium2.should_not_receive(:new)
|
10
|
+
visit "http://wwww.google.com"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
SimpleCov.root "#{Dir.pwd}/../../../"
|
5
|
+
command_name 'RSpec Integration'
|
6
|
+
use_merging true
|
7
|
+
merge_timeout 6000
|
8
|
+
end
|
9
|
+
|
10
|
+
require "rspec"
|
11
|
+
require "capybara/rspec"
|
12
|
+
require "sauce"
|
13
|
+
require "sauce/capybara"
|
14
|
+
|
15
|
+
class MyRackApp
|
16
|
+
def self.call(env)
|
17
|
+
[200, {}, ["Hello"]]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Capybara.app = MyRackApp
|
22
|
+
|
23
|
+
Sauce.config do |c|
|
24
|
+
c[:browsers] = [
|
25
|
+
["Windows 2008", "iexplore", "9"]
|
26
|
+
]
|
27
|
+
|
28
|
+
c[:sauce_connect_4_executable] = ENV["SAUCE_CONNECT_4_EXECUTABLE"]
|
29
|
+
c[:application_host] = "localhost"
|
30
|
+
end
|
31
|
+
|
32
|
+
def page_deprecation_warning
|
33
|
+
return <<-MESSAGE
|
34
|
+
[DEPRECATED] Using the #page method is deprecated for RSpec tests without Capybara. Please use the #s or #selenium method instead.
|
35
|
+
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.
|
36
|
+
MESSAGE
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Sauce::Config", :sauce => true do
|
4
|
+
it "should have rspec in its tool set", :sauce => true do
|
5
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
6
|
+
capabilities[:client_version].should include "Rspec"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not have test::unit in its tool set", :sauce => true do
|
10
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
11
|
+
capabilities[:client_version].should_not include "Test::Unit"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "sauce"
|
3
|
+
require "sauce/connect"
|
4
|
+
|
5
|
+
Sauce.config do |c|
|
6
|
+
c.browsers = [
|
7
|
+
["Windows 2008", "iexplore", "9"],
|
8
|
+
["Linux", "opera", 12]
|
9
|
+
]
|
10
|
+
|
11
|
+
c[:application_host] = "localhost"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Specs in the Selenium Directory" do
|
15
|
+
it_behaves_like "an integrated spec"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "Specs in the Selenium Directory with the sauce tag", :sauce => true do
|
19
|
+
it_behaves_like "an integrated spec"
|
20
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
SimpleCov.root "#{Dir.pwd}/../../../"
|
5
|
+
command_name 'RSpec Integration'
|
6
|
+
use_merging true
|
7
|
+
merge_timeout 6000
|
8
|
+
end
|
9
|
+
|
10
|
+
require "rspec"
|
11
|
+
require "sauce"
|
12
|
+
|
13
|
+
def page_deprecation_warning
|
14
|
+
return <<-MESSAGE
|
15
|
+
[DEPRECATED] Using the #page method is deprecated for RSpec tests without Capybara. Please use the #s or #selenium method instead.
|
16
|
+
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.
|
17
|
+
MESSAGE
|
18
|
+
end
|
19
|
+
|
20
|
+
shared_examples_for "an integrated spec" do
|
21
|
+
|
22
|
+
before :all do
|
23
|
+
$TAGGED_EXECUTIONS = 0
|
24
|
+
end
|
25
|
+
|
26
|
+
after :all do
|
27
|
+
$TAGGED_EXECUTIONS.should eq 2
|
28
|
+
end
|
29
|
+
|
30
|
+
context "When calling the #page method" do
|
31
|
+
it "should get access to the Webdriver object" do
|
32
|
+
page.should be_a_kind_of Sauce::Selenium2
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should output a deprecation message" do
|
36
|
+
self.should_receive(:warn).with(page_deprecation_warning).and_call_original
|
37
|
+
page
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should be using Sauce Connect" do
|
42
|
+
Sauce::Utilities::Connect.instance_variable_get(:@tunnel).should_not be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should get run on every defined browser" do
|
46
|
+
$TAGGED_EXECUTIONS += 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Sauce.config do |c|
|
51
|
+
c[:sauce_connect_4_executable] = ENV["SAUCE_CONNECT_4_EXECUTABLE"]
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "sauce"
|
3
|
+
require "sauce/connect"
|
4
|
+
|
5
|
+
Sauce.config do |c|
|
6
|
+
c.browsers = [
|
7
|
+
["Windows 2008", "iexplore", "9"],
|
8
|
+
["Linux", "opera", 12]
|
9
|
+
]
|
10
|
+
c[:application_host] = "localhost"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "Specs with the @sauce tag", :sauce => true do
|
14
|
+
it_behaves_like "an integrated spec"
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Specs without the @sauce tag" do
|
18
|
+
before :all do
|
19
|
+
$UNTAGGED_EXECUTIONS = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
after :all do
|
23
|
+
$UNTAGGED_EXECUTIONS.should eq 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should only run once" do
|
27
|
+
$UNTAGGED_EXECUTIONS += 1
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require "sauce/capybara"
|
4
|
+
require "mocha/setup"
|
5
|
+
|
6
|
+
Sauce.config do |c|
|
7
|
+
c[:browsers] = [
|
8
|
+
["Windows 7", "Firefox", "18"],
|
9
|
+
["Linux", "Firefox", "17"]
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
Capybara.default_driver = :sauce
|
14
|
+
|
15
|
+
class CapybaraTestCase < Sauce::TestCase
|
16
|
+
include Capybara::DSL
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
Capybara.reset_sessions!
|
20
|
+
Capybara.use_default_driver
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class CapybaraIntegrationTest < CapybaraTestCase
|
25
|
+
|
26
|
+
# Called after every test method runs. Can be used to tear
|
27
|
+
# down fixture information.
|
28
|
+
|
29
|
+
def test_driver_is_from_the_driver_pool
|
30
|
+
assert_equal Capybara.current_session.driver.browser, selenium
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_capybara_does_not_create_a_new_driver
|
34
|
+
::Sauce::Selenium2.expects(:new).never
|
35
|
+
visit "http://www.wikipedia.org"
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
Sauce.config do |c|
|
4
|
+
c[:browsers] = [
|
5
|
+
["Windows 7", "Firefox", "18"]
|
6
|
+
]
|
7
|
+
c[:sauce_connect_4_executable] = ENV["SAUCE_CONNECT_4_EXECUTABLE"]
|
8
|
+
end
|
9
|
+
|
10
|
+
class IntegrationTest < Sauce::TestCase
|
11
|
+
|
12
|
+
def test_testunit_is_set_in_sauce_config
|
13
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
14
|
+
assert_includes capabilities[:client_version], "Test::Unit"
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_rspec_is_not_set_in_sauce_config
|
18
|
+
capabilities = Sauce.get_config.to_desired_capabilities
|
19
|
+
assert_not_includes capabilities[:client_version], "Rspec"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
SimpleCov.root "#{Dir.pwd}/../../../"
|
5
|
+
command_name 'TestUnit Integration'
|
6
|
+
use_merging true
|
7
|
+
merge_timeout 6000
|
8
|
+
end
|
9
|
+
|
10
|
+
require "rubygems"
|
11
|
+
require "bundler/setup"
|
12
|
+
require "test/unit"
|
13
|
+
require "sauce"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "rspec"
|
2
|
+
require "sauce"
|
3
|
+
require "parallel_tests"
|
4
|
+
|
5
|
+
describe "Sauce Rspec Runner" do
|
6
|
+
describe "#self.tests_in_groups" do
|
7
|
+
it "should return a group for every environment" do
|
8
|
+
Sauce.config do |c|
|
9
|
+
c.browsers = [
|
10
|
+
["Windows 7", "Opera", "10"],
|
11
|
+
["Linux", "Firefox", "19"],
|
12
|
+
["Windows 8", "Chrome", ""]
|
13
|
+
]
|
14
|
+
end
|
15
|
+
|
16
|
+
ParallelTests::Test::Runner.stub(:tests_in_groups).with(anything, anything, anything) {
|
17
|
+
["spec/one_spec", "spec/two_spec"]
|
18
|
+
}
|
19
|
+
test_groups = ParallelTests::Saucerspec::Runner.tests_in_groups ["spec/one_spec.rb"], "3"
|
20
|
+
test_groups.length.should eq 6
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,386 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sauce/capybara'
|
3
|
+
require 'sauce/connect'
|
4
|
+
#require 'capybara/server'
|
5
|
+
|
6
|
+
describe Sauce::Capybara do
|
7
|
+
|
8
|
+
after :each do
|
9
|
+
Sauce::Utilities::Connect.instance_variable_set(:@tunnel, false)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Sauce::Capybara::Driver do
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
::Capybara::Server.any_instance.stub(:boot).and_return(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:app) { proc { |env| [200, {}, ["Hello Sauce!"]]} }
|
19
|
+
let(:driver) { Sauce::Capybara::Driver.new(app) }
|
20
|
+
|
21
|
+
after :each do
|
22
|
+
Capybara.reset_sessions!
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#body" do
|
26
|
+
context "With Capybara 1.x", :capybara_version => [1, "1.9.9"] do
|
27
|
+
it "should not exist in version 2" do
|
28
|
+
driver.should respond_to :base_body
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "With Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
33
|
+
it "should not exist" do
|
34
|
+
driver.should_not respond_to :base_body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#source" do
|
40
|
+
context "With Capybara 1", :capybara_version => [1, "1.9.9"] do
|
41
|
+
it "should exist" do
|
42
|
+
driver.should respond_to :base_source
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
47
|
+
it "should not exist" do
|
48
|
+
driver.should_not respond_to :base_source
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "#html" do
|
54
|
+
context "With Capybara 1.x", :capybara_version => [1, "1.9.9"] do
|
55
|
+
it "should not exist" do
|
56
|
+
driver.should_not respond_to :base_html
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "With Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
61
|
+
it "should exist" do
|
62
|
+
driver.should respond_to :base_html
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#finish' do
|
68
|
+
let(:browser) { double('Sauce::Selenium2 mock') }
|
69
|
+
|
70
|
+
before :each do
|
71
|
+
driver.instance_variable_set(:@browser, browser)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should quit the @browser' do
|
75
|
+
browser.should_receive(:quit)
|
76
|
+
driver.finish!
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should nil out @browser' do
|
80
|
+
browser.stub(:quit)
|
81
|
+
driver.finish!
|
82
|
+
expect(driver.instance_variable_get(:@browser)).to be_nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#rspec_browser' do
|
87
|
+
let(:driver) { Sauce::Capybara::Driver.new(app) }
|
88
|
+
|
89
|
+
before :each do
|
90
|
+
Sauce::Selenium2.stub(:new).and_return(nil)
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with no rspec driver" do
|
94
|
+
|
95
|
+
before :each do
|
96
|
+
Sauce.stub(:driver_pool).and_return({})
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should return nil" do
|
100
|
+
driver.rspec_browser.should be nil
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should set the rspec_driver flag to false" do
|
104
|
+
driver.rspec_browser
|
105
|
+
driver.instance_variable_get(:@using_rspec_browser).should be_false
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
context "with an rspec driver" do
|
111
|
+
let(:mock_driver) {Object.new}
|
112
|
+
before :each do
|
113
|
+
Sauce.stub(:driver_pool).and_return({Thread.current.object_id => mock_driver})
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return the driver" do
|
117
|
+
driver.rspec_browser.should be mock_driver
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should set the rspec_driver flag to true" do
|
121
|
+
driver.rspec_browser
|
122
|
+
driver.instance_variable_get(:@using_rspec_browser).should be_true
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "called after a driver_pool change" do
|
127
|
+
|
128
|
+
context "with no driver present" do
|
129
|
+
let(:mock_driver) {Object.new}
|
130
|
+
|
131
|
+
before (:each) do
|
132
|
+
Sauce.stub(:driver_pool).and_return(
|
133
|
+
{Thread.current.object_id => mock_driver},
|
134
|
+
{Thread.current.object_id => nil}
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should return nil" do
|
139
|
+
driver.rspec_browser.should eq mock_driver
|
140
|
+
driver.rspec_browser.should be nil
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should set rspec_browser flag false" do
|
144
|
+
driver.rspec_browser
|
145
|
+
driver.rspec_browser
|
146
|
+
driver.instance_variable_get(:@using_rspec_browser).should be_false
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe '#browser' do
|
153
|
+
let(:driver) { Sauce::Capybara::Driver.new(app) }
|
154
|
+
|
155
|
+
before :each do
|
156
|
+
# Stub out the selenium driver startup
|
157
|
+
Sauce::Selenium2.stub(:new).and_return(nil)
|
158
|
+
end
|
159
|
+
|
160
|
+
context "when there is a driver in the driver pool" do
|
161
|
+
let(:mock_browser) {Object.new}
|
162
|
+
before :each do
|
163
|
+
Sauce.driver_pool[Thread.current.object_id] = mock_browser
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should use the driver_pools browser" do
|
167
|
+
driver.browser.should eq mock_browser
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'when tunneling is disabled' do
|
172
|
+
it 'should not call #connect_tunnel' do
|
173
|
+
Sauce::Capybara.should_receive(:connect_tunnel).never
|
174
|
+
Sauce.stub(:get_config) {{:start_tunnel => false}}
|
175
|
+
|
176
|
+
driver.browser
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe '#find' do
|
182
|
+
let(:selector) { '#lol' }
|
183
|
+
|
184
|
+
context "with Capybara < 2.1", :capybara_version => [2, "2.0.9"] do
|
185
|
+
|
186
|
+
it "should exist" do
|
187
|
+
driver.respond_to?(:find).should be_true
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'with an environment override' do
|
191
|
+
before :each do
|
192
|
+
ENV['SAUCE_DISABLE_RETRY'] = '1'
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should not retry and raise the error' do
|
196
|
+
driver.should_receive(:base_find).with(selector).and_raise(Selenium::WebDriver::Error::UnknownError)
|
197
|
+
|
198
|
+
expect {
|
199
|
+
driver.find(selector)
|
200
|
+
}.to raise_error(Selenium::WebDriver::Error::UnknownError)
|
201
|
+
end
|
202
|
+
|
203
|
+
after :each do
|
204
|
+
ENV['SAUCE_DISABLE_RETRY'] = nil
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should route through handle_retry' do
|
209
|
+
driver.should_receive(:base_find).with(selector) # BLECH
|
210
|
+
driver.find(selector)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should retry 3 times and then raise' do
|
214
|
+
driver.should_receive(:base_find).with(selector).exactly(4).times.and_raise(Selenium::WebDriver::Error::UnknownError)
|
215
|
+
|
216
|
+
expect {
|
217
|
+
driver.find(selector)
|
218
|
+
}.to raise_error(Selenium::WebDriver::Error::UnknownError)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
context "with Capybara => 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
223
|
+
it "should not be aliased" do
|
224
|
+
driver.respond_to?(:base_find).should be_false
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should not be retried" do
|
228
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "#find_css" do
|
234
|
+
context "with Capybara < 2.1", :capybara_version => [0, "2.0.9"] do
|
235
|
+
it "should not be aliased" do
|
236
|
+
driver.respond_to?(:base_find_css).should be_false
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should not be retried" do
|
240
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find_css
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "with Capybara >= 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
245
|
+
it "should be aliased" do
|
246
|
+
driver.respond_to?(:base_find_css).should be_true
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should be retried" do
|
250
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should include :find_css
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "#find_xpath" do
|
256
|
+
context "with Capybara < 2.1", :capybara_version => [0, "2.0.9"] do
|
257
|
+
it "should not be aliased" do
|
258
|
+
driver.respond_to?(:base_find_xpath).should be_false
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should not be retried" do
|
262
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find_xpath
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
context "with Capybara >= 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
267
|
+
it "should be aliased" do
|
268
|
+
driver.respond_to?(:base_find_xpath).should be_true
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should be retried" do
|
272
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should include :find_xpath
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe '#visit' do
|
278
|
+
it 'should route through #handle_retry' do
|
279
|
+
path = '/lol'
|
280
|
+
driver.should_receive(:base_visit).with(path)
|
281
|
+
driver.visit(path)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
describe '#current_url' do
|
286
|
+
it 'should route through #handle_retry' do
|
287
|
+
url = 'http://lol'
|
288
|
+
driver.should_receive(:base_current_url).and_return(url)
|
289
|
+
driver.current_url.should == url
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe '#within_frame' do
|
294
|
+
it 'should route through #handle_retry and yield block' do
|
295
|
+
driver.should_receive(:base_within_frame).and_yield
|
296
|
+
driver.within_frame do
|
297
|
+
"lol"
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe '#install_hooks' do
|
304
|
+
end
|
305
|
+
|
306
|
+
describe 'used without rspec hooks' do
|
307
|
+
include Capybara::DSL
|
308
|
+
|
309
|
+
before :all do
|
310
|
+
app = proc { |env| [200, {}, ["Hello Sauce!"]]}
|
311
|
+
Capybara.app = app
|
312
|
+
Sauce.driver_pool[Thread.current.object_id] = nil
|
313
|
+
end
|
314
|
+
|
315
|
+
it "should use one of the Sauce Connect ports", :capybara_version => [2, "2.9.9"], :js => true do
|
316
|
+
reset_capybara(2.0)
|
317
|
+
used_port = Capybara.current_session.server.port
|
318
|
+
Sauce::Config::POTENTIAL_PORTS.should include used_port
|
319
|
+
end
|
320
|
+
|
321
|
+
it "should use one of the Sauce Connect ports", :capybara_version => ["1.0.9", "1.9.9"], :js => true do
|
322
|
+
reset_capybara(1.1)
|
323
|
+
used_port = Capybara.current_session.driver.rack_server.port
|
324
|
+
Sauce::Config::POTENTIAL_PORTS.should include used_port
|
325
|
+
end
|
326
|
+
|
327
|
+
it "should use one of the Sauce Connect ports", :capybara_version => ["1.0.0", "1.0.9"], :js => true do
|
328
|
+
reset_capybara(1.0)
|
329
|
+
used_port = Capybara.current_session.driver.rack_server.port
|
330
|
+
Sauce::Config::POTENTIAL_PORTS.should include used_port
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "with start_local_application set false", :capybara_version => ["2.0.0", "2.9.9"] do
|
334
|
+
before do
|
335
|
+
@start_local_application = Sauce::Config.new[:start_local_application]
|
336
|
+
end
|
337
|
+
|
338
|
+
after do
|
339
|
+
Sauce.config do |c|
|
340
|
+
c[:start_local_application] = @start_local_application
|
341
|
+
end
|
342
|
+
end
|
343
|
+
it "should not use Sauce Connect ports" do
|
344
|
+
Sauce.config { |c| c[:start_local_application] = false }
|
345
|
+
reset_capybara(2.0)
|
346
|
+
Capybara.server_port.should eq nil
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
def reset_capybara(capy_version)
|
352
|
+
Capybara.reset_sessions!
|
353
|
+
|
354
|
+
Capybara.configure do |config|
|
355
|
+
case capy_version
|
356
|
+
when 1.0
|
357
|
+
config.server_boot_timeout = 10
|
358
|
+
config.prefer_visible_elements = true
|
359
|
+
config.ignore_hidden_elements = false
|
360
|
+
when 1.1
|
361
|
+
config.server_boot_timeout = 10
|
362
|
+
config.prefer_visible_elements = true
|
363
|
+
config.automatic_reload = true
|
364
|
+
config.ignore_hidden_elements = false
|
365
|
+
when 2.0
|
366
|
+
config.always_include_port = false
|
367
|
+
config.match = :smart
|
368
|
+
config.exact = false
|
369
|
+
config.raise_server_errors = true
|
370
|
+
config.visible_text_only = false
|
371
|
+
config.automatic_reload = true
|
372
|
+
config.ignore_hidden_elements = true
|
373
|
+
config.server_port = nil
|
374
|
+
end
|
375
|
+
|
376
|
+
config.run_server = true
|
377
|
+
config.server {|app, port| Capybara.run_default_server(app, port)}
|
378
|
+
config.default_selector = :css
|
379
|
+
config.default_wait_time = 2
|
380
|
+
config.default_host = "http://www.example.com"
|
381
|
+
|
382
|
+
Sauce::Capybara.configure_capybara
|
383
|
+
Capybara.default_driver = :sauce
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|