sauce 2.5.1 → 2.5.2
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 +8 -8
- data/lib/sauce/capybara.rb +4 -15
- data/lib/sauce/utilities.rb +33 -0
- data/lib/sauce/version.rb +1 -1
- data/spec/sauce/capybara_spec.rb +6 -14
- data/spec/sauce/cucumber_spec.rb +51 -0
- data/spec/sauce/utilities_spec.rb +82 -0
- data/spec/spec_helper.rb +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjE4ZWNmYmY5YTI3NDNjM2IzYTg3M2EwYWVmOGEwM2EzZmFiMTA3Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmZiN2M0NWZkYzE2NjAxMmYxZDY0NDgyYzYzNzM3OGI0YjcwNmQyMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmRiZDYxZWE0ZTIxNTg1ZTFiNTZiYWRlMDYxZTA0Yjg2MTBhN2U5ZTdlMjVh
|
10
|
+
NDY3ZThkMzhlZWI4ZjNiOTdlMDBmMGM1ZTYyZTg0YTIyYjViNjRhYTZiYmYw
|
11
|
+
MzQyMjVjNjZlY2FkYzhiOWZlNDE5Y2I1M2ZlZjM5Mzg0ZmQ3MTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjExNmMxMDQxMDA0NDA5NDM0ZjhiMWI2YmUzOGVkZmE1OTY0ZWFkYTcwYWUz
|
14
|
+
ODFjY2ZlMzNmY2M0YzRiNzcyMDYyOGRhY2Q0MmRhZTE4YmRiNDdjODg5YjVj
|
15
|
+
ZGM5OTA4N2MzNWVlZDEzZDA2YjgyYTRkYjZkZTMzOTYwYTMwYzg=
|
data/lib/sauce/capybara.rb
CHANGED
@@ -4,26 +4,15 @@ require 'sauce/config'
|
|
4
4
|
require 'sauce/selenium'
|
5
5
|
require 'sauce/version'
|
6
6
|
|
7
|
+
require 'sauce/utilities'
|
8
|
+
|
7
9
|
|
8
10
|
$sauce_tunnel = nil
|
9
11
|
|
10
12
|
module Sauce
|
11
13
|
module Capybara
|
12
14
|
def connect_tunnel(options={})
|
13
|
-
|
14
|
-
require 'sauce/connect'
|
15
|
-
rescue LoadError
|
16
|
-
puts 'Please install the `sauce-connect` gem if you intend on using Sauce Connect with your tests!'
|
17
|
-
raise
|
18
|
-
end
|
19
|
-
|
20
|
-
unless $sauce_tunnel.nil?
|
21
|
-
return $sauce_tunnel
|
22
|
-
end
|
23
|
-
$sauce_tunnel = Sauce::Connect.new(options)
|
24
|
-
$sauce_tunnel.connect
|
25
|
-
$sauce_tunnel.wait_until_ready
|
26
|
-
$sauce_tunnel
|
15
|
+
Sauce::Utilities::Connect.start(options)
|
27
16
|
end
|
28
17
|
module_function :connect_tunnel
|
29
18
|
|
@@ -129,7 +118,7 @@ module Sauce
|
|
129
118
|
def finish!
|
130
119
|
@browser.quit if existing_browser?
|
131
120
|
@browser = nil
|
132
|
-
|
121
|
+
Sauce::Utilities::Connect.close
|
133
122
|
end
|
134
123
|
|
135
124
|
def render(path)
|
data/lib/sauce/utilities.rb
CHANGED
@@ -31,6 +31,39 @@ module Sauce
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
class Connect
|
35
|
+
|
36
|
+
def self.start(options={})
|
37
|
+
begin
|
38
|
+
require "sauce/connect"
|
39
|
+
rescue LoadError => e
|
40
|
+
STDERR.puts <<-ERROR
|
41
|
+
Please install the `sauce-connect` gem if you intend on using Sauce Connect with your tests!
|
42
|
+
|
43
|
+
If you don't wish to use Sauce Connect, set [:start_tunnel] to false:
|
44
|
+
Sauce.config do |config|
|
45
|
+
config[:start_tunnel] = false
|
46
|
+
end
|
47
|
+
ERROR
|
48
|
+
exit(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
unless @tunnel
|
52
|
+
@tunnel = Sauce::Connect.new options
|
53
|
+
@tunnel.connect
|
54
|
+
@tunnel.wait_until_ready
|
55
|
+
end
|
56
|
+
@tunnel
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.close
|
60
|
+
if @tunnel
|
61
|
+
@tunnel.disconnect
|
62
|
+
@tunnel = nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
34
67
|
class RailsServer
|
35
68
|
include Sauce::Utilities
|
36
69
|
|
data/lib/sauce/version.rb
CHANGED
data/spec/sauce/capybara_spec.rb
CHANGED
@@ -3,11 +3,12 @@ require 'sauce/capybara'
|
|
3
3
|
require 'sauce/connect'
|
4
4
|
|
5
5
|
describe Sauce::Capybara do
|
6
|
-
describe '#connect_tunnel' do
|
7
|
-
before :each do
|
8
|
-
$sauce_tunnel = nil
|
9
|
-
end
|
10
6
|
|
7
|
+
after :each do
|
8
|
+
Sauce::Utilities::Connect.instance_variable_set(:@tunnel, false)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#connect_tunnel' do
|
11
12
|
let(:connector) do
|
12
13
|
connector = double()
|
13
14
|
connector.should_receive(:connect)
|
@@ -15,13 +16,8 @@ describe Sauce::Capybara do
|
|
15
16
|
connector
|
16
17
|
end
|
17
18
|
|
18
|
-
it 'should not do anything if the sauce tunnel exists' do
|
19
|
-
$sauce_tunnel = 1337
|
20
|
-
Sauce::Capybara.connect_tunnel.should == 1337
|
21
|
-
end
|
22
|
-
|
23
19
|
it 'should connect if the tunnel is not connected' do
|
24
|
-
Sauce::Connect.should_receive(:new).and_return(connector)
|
20
|
+
Sauce::Connect.should_receive(:new).with(anything).and_return(connector)
|
25
21
|
|
26
22
|
Sauce::Capybara.connect_tunnel
|
27
23
|
end
|
@@ -31,10 +27,6 @@ describe Sauce::Capybara do
|
|
31
27
|
hash_including(:quiet => true)).and_return(connector)
|
32
28
|
Sauce::Capybara.connect_tunnel(:quiet => true)
|
33
29
|
end
|
34
|
-
|
35
|
-
after :each do
|
36
|
-
$sauce_tunnel = nil
|
37
|
-
end
|
38
30
|
end
|
39
31
|
|
40
32
|
describe Sauce::Capybara::Driver do
|
data/spec/sauce/cucumber_spec.rb
CHANGED
@@ -9,6 +9,10 @@ module Sauce::Capybara
|
|
9
9
|
include Sauce::Capybara::Cucumber
|
10
10
|
include Sauce::Cucumber::SpecHelper
|
11
11
|
|
12
|
+
before :each do
|
13
|
+
Sauce::Utilities::Connect.stub!(:start) {}
|
14
|
+
end
|
15
|
+
|
12
16
|
describe '#use_sauce_driver' do
|
13
17
|
before :each do
|
14
18
|
::Capybara.current_driver = :test
|
@@ -109,6 +113,53 @@ module Sauce::Capybara
|
|
109
113
|
|
110
114
|
end
|
111
115
|
|
116
|
+
context "when using sauce/connect" do
|
117
|
+
let(:feature) do
|
118
|
+
"""
|
119
|
+
Feature: A dummy feature
|
120
|
+
@selenium
|
121
|
+
Scenario: A dummy scenario
|
122
|
+
Given a scenario
|
123
|
+
When I raise no exceptions
|
124
|
+
"""
|
125
|
+
end
|
126
|
+
|
127
|
+
before :each do
|
128
|
+
Sauce::Utilities::Connect.rspec_reset
|
129
|
+
|
130
|
+
Sauce.config do |c|
|
131
|
+
c[:start_tunnel] = true
|
132
|
+
end
|
133
|
+
$ran_scenario = nil
|
134
|
+
end
|
135
|
+
|
136
|
+
after :all do
|
137
|
+
Sauce::Utilities::Connect.stub!(:start) {}
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should have set up a tunnel' do
|
141
|
+
define_steps do
|
142
|
+
Given /^a scenario$/ do
|
143
|
+
end
|
144
|
+
When /^I raise no exceptions$/ do
|
145
|
+
$ran_scenario = true
|
146
|
+
end
|
147
|
+
# Set up and invoke our defined Around hook
|
148
|
+
Around('@selenium') do |scenario, block|
|
149
|
+
# We need to fully reference the module function here due to a
|
150
|
+
# change in scoping that will happen to this block courtesy of
|
151
|
+
# define_steps
|
152
|
+
Sauce::Capybara::Cucumber.around_hook(scenario, block)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Make sure we actually configure ourselves
|
157
|
+
Sauce::Utilities::Connect.should_receive(:start).and_return {true}
|
158
|
+
run_defined_feature feature
|
159
|
+
$ran_scenario.should be true
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
112
163
|
context 'with a correct scenario' do
|
113
164
|
let(:feature) do
|
114
165
|
"""
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Sauce::Utilities::Connect" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@mock_tunnel = double(Sauce::Connect.new)
|
7
|
+
end
|
8
|
+
|
9
|
+
after :each do
|
10
|
+
Sauce::Utilities::Connect.instance_variable_set(:@tunnel, nil)
|
11
|
+
end
|
12
|
+
describe "##start" do
|
13
|
+
it "should call Sauce Connect when included" do
|
14
|
+
@mock_tunnel.stub(:connect).and_return true
|
15
|
+
@mock_tunnel.stub(:wait_until_ready).and_return true
|
16
|
+
Sauce::Connect.should_receive(:new).with(anything) {@mock_tunnel}
|
17
|
+
Sauce::Utilities::Connect.start
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should throw an exception when Sauce Connect is not included" do
|
21
|
+
Object.should_receive(:require).with("sauce/connect").and_raise LoadError
|
22
|
+
|
23
|
+
lambda {Sauce::Utilities::Connect.start}.should raise_error SystemExit
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should connect the new tunnel" do
|
27
|
+
Sauce::Connect.rspec_reset
|
28
|
+
@mock_tunnel.should_receive(:connect).with().and_return(true)
|
29
|
+
@mock_tunnel.should_receive(:wait_until_ready).and_return(true)
|
30
|
+
|
31
|
+
Sauce::Connect.stub!(:new).with(anything).and_return @mock_tunnel
|
32
|
+
|
33
|
+
Sauce::Utilities::Connect.start
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return the tunnel when done" do
|
37
|
+
@mock_tunnel.stub(:connect).and_return true
|
38
|
+
@mock_tunnel.stub(:wait_until_ready).and_return true
|
39
|
+
Sauce::Connect.should_receive(:new).with(anything) {@mock_tunnel}
|
40
|
+
tunnel = Sauce::Utilities::Connect.start
|
41
|
+
tunnel.should be @mock_tunnel
|
42
|
+
end
|
43
|
+
|
44
|
+
it "only opens one tunnel" do
|
45
|
+
@mock_tunnel.stub(:connect).and_return true
|
46
|
+
@mock_tunnel.stub(:wait_until_ready).and_return true
|
47
|
+
Sauce::Connect.should_receive(:new).with(anything) {@mock_tunnel}
|
48
|
+
tunnel = Sauce::Utilities::Connect.start
|
49
|
+
|
50
|
+
tunnel_2 = Sauce::Utilities::Connect.start
|
51
|
+
|
52
|
+
tunnel.should be tunnel_2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#close" do
|
57
|
+
it "makes the tunnel nil when terminated" do
|
58
|
+
@mock_tunnel.stub(:connect).and_return true
|
59
|
+
@mock_tunnel.stub(:wait_until_ready).and_return true
|
60
|
+
@mock_tunnel.should_receive(:disconnect).and_return true
|
61
|
+
Sauce::Connect.stub(:new).with(anything) {@mock_tunnel}
|
62
|
+
Sauce::Utilities::Connect.start
|
63
|
+
|
64
|
+
Sauce::Utilities::Connect.close
|
65
|
+
Sauce::Utilities::Connect.instance_variable_get(:@tunnel).should be nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it "calls disconnect" do
|
69
|
+
@mock_tunnel.stub(:connect).and_return true
|
70
|
+
@mock_tunnel.stub(:wait_until_ready).and_return true
|
71
|
+
@mock_tunnel.should_receive(:disconnect).and_return true
|
72
|
+
Sauce::Connect.stub(:new).with(anything) {@mock_tunnel}
|
73
|
+
tunnel = Sauce::Utilities::Connect.start
|
74
|
+
|
75
|
+
Sauce::Utilities::Connect.close
|
76
|
+
end
|
77
|
+
|
78
|
+
it "does not error if no tunnel exists" do
|
79
|
+
Sauce::Utilities::Connect.close
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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: 2.5.
|
4
|
+
version: 2.5.2
|
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-06-
|
16
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: capybara
|
@@ -29,6 +29,20 @@ dependencies:
|
|
29
29
|
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
31
|
version: 2.1.0
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: rspec
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
32
46
|
- !ruby/object:Gem::Dependency
|
33
47
|
name: net-http-persistent
|
34
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +222,7 @@ files:
|
|
208
222
|
- spec/sauce/jasmine_spec.rb
|
209
223
|
- spec/sauce/selenium_spec.rb
|
210
224
|
- spec/sauce/test_unit_spec.rb
|
225
|
+
- spec/sauce/utilities_spec.rb
|
211
226
|
- spec/spec_helper.rb
|
212
227
|
- bin/sauce
|
213
228
|
homepage: http://github.com/sauce-labs/sauce_ruby
|
@@ -250,4 +265,5 @@ test_files:
|
|
250
265
|
- spec/sauce/jasmine_spec.rb
|
251
266
|
- spec/sauce/selenium_spec.rb
|
252
267
|
- spec/sauce/test_unit_spec.rb
|
268
|
+
- spec/sauce/utilities_spec.rb
|
253
269
|
- spec/spec_helper.rb
|