sauce 2.4.2 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sauce/capybara.rb +15 -2
- data/lib/sauce/config.rb +25 -1
- data/lib/sauce/version.rb +6 -1
- data/spec/integration/rspec/spec/spec_helper.rb +1 -0
- data/spec/sauce/capybara_spec.rb +82 -21
- data/spec/sauce/config_spec.rb +66 -0
- data/spec/spec_helper.rb +7 -5
- metadata +20 -4
data/lib/sauce/capybara.rb
CHANGED
@@ -53,7 +53,6 @@ module Sauce
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
alias :base_find :find
|
57
56
|
alias :base_visit :visit
|
58
57
|
alias :base_current_url :current_url
|
59
58
|
alias :base_reset! :reset!
|
@@ -63,11 +62,20 @@ module Sauce
|
|
63
62
|
alias :base_execute_script :execute_script
|
64
63
|
alias :base_evaluate_script :evaluate_script
|
65
64
|
|
66
|
-
@methods_to_retry = [
|
65
|
+
@methods_to_retry = [:visit, :current_url, :reset!,
|
67
66
|
:within_frame, :within_window, :find_window, :source,
|
68
67
|
:execute_script, :evaluate_script
|
69
68
|
]
|
70
69
|
|
70
|
+
if method_defined? :find
|
71
|
+
alias :base_find :find
|
72
|
+
@methods_to_retry += [:find]
|
73
|
+
else
|
74
|
+
alias :base_find_css :find_css
|
75
|
+
alias :base_find_xpath :find_xpath
|
76
|
+
@methods_to_retry += [:find_css, :find_xpath]
|
77
|
+
end
|
78
|
+
|
71
79
|
if Gem::Version.new(::Capybara::VERSION) < Gem::Version.new(2)
|
72
80
|
alias :base_body :body
|
73
81
|
alias :base_source :source
|
@@ -122,6 +130,11 @@ module Sauce
|
|
122
130
|
@browser = nil
|
123
131
|
$sauce_tunnel.disconnect if $sauce_tunnel
|
124
132
|
end
|
133
|
+
|
134
|
+
def render(path)
|
135
|
+
browser.save_screenshot path
|
136
|
+
end
|
137
|
+
|
125
138
|
end
|
126
139
|
end
|
127
140
|
end
|
data/lib/sauce/config.rb
CHANGED
@@ -113,7 +113,8 @@ module Sauce
|
|
113
113
|
:browserName => BROWSERS[browser] || browser,
|
114
114
|
:version => browser_version,
|
115
115
|
:platform => PLATFORMS[os] || os,
|
116
|
-
:name => @opts[:job_name]
|
116
|
+
:name => @opts[:job_name],
|
117
|
+
:client_version => client_version
|
117
118
|
}.update(@opts.reject {|k, v| [:browser, :browser_version, :os, :job_name].include? k})
|
118
119
|
end
|
119
120
|
|
@@ -180,8 +181,31 @@ module Sauce
|
|
180
181
|
@opts[:port]
|
181
182
|
end
|
182
183
|
|
184
|
+
def tools
|
185
|
+
tools = []
|
186
|
+
tools << "Rspec" if is_defined? "RSpec"
|
187
|
+
tools << "Capybara" if is_defined? "Capybara"
|
188
|
+
tools << "Cucumber" if is_defined? "Cucumber"
|
189
|
+
tools << "Test::Unit" if is_defined?("Test", "Unit")
|
190
|
+
tools
|
191
|
+
end
|
192
|
+
|
193
|
+
# Only here to be stubbed for testing. Gross.
|
194
|
+
def is_defined? (top_mod, sub_mod = nil)
|
195
|
+
return_value = Object.const_defined? top_mod
|
196
|
+
unless !return_value || sub_mod.nil?
|
197
|
+
return_value = Object.const_get(top_mod).const_defined? sub_mod
|
198
|
+
end
|
199
|
+
|
200
|
+
return_value
|
201
|
+
end
|
202
|
+
|
183
203
|
private
|
184
204
|
|
205
|
+
def client_version
|
206
|
+
"Ruby: #{RUBY_ENGINE} #{RUBY_VERSION} (#{RUBY_PLATFORM}) Sauce gem: #{Sauce.version} Tools: #{tools.to_s}"
|
207
|
+
end
|
208
|
+
|
185
209
|
def load_options_from_environment
|
186
210
|
return extract_options_from_hash(ENV)
|
187
211
|
end
|
data/lib/sauce/version.rb
CHANGED
data/spec/sauce/capybara_spec.rb
CHANGED
@@ -43,13 +43,13 @@ describe Sauce::Capybara do
|
|
43
43
|
let(:driver) { Sauce::Capybara::Driver.new(app) }
|
44
44
|
|
45
45
|
describe "#body" do
|
46
|
-
context "With Capybara 1.x", :capybara_version => 1 do
|
46
|
+
context "With Capybara 1.x", :capybara_version => [1, "1.9.9"] do
|
47
47
|
it "should not exist in version 2" do
|
48
48
|
driver.should respond_to :base_body
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
context "With Capybara 2.x", :capybara_version => 2 do
|
52
|
+
context "With Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
53
53
|
it "should not exist" do
|
54
54
|
driver.should_not respond_to :base_body
|
55
55
|
end
|
@@ -57,13 +57,13 @@ describe Sauce::Capybara do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "#source" do
|
60
|
-
context "With Capybara 1", :capybara_version => 1 do
|
60
|
+
context "With Capybara 1", :capybara_version => [1, "1.9.9"] do
|
61
61
|
it "should exist" do
|
62
62
|
driver.should respond_to :base_source
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context "with Capybara 2.x", :capybara_version => 2 do
|
66
|
+
context "with Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
67
67
|
it "should not exist" do
|
68
68
|
driver.should_not respond_to :base_source
|
69
69
|
end
|
@@ -71,13 +71,13 @@ describe Sauce::Capybara do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
describe "#html" do
|
74
|
-
context "With Capybara 1.x", :capybara_version => 1 do
|
74
|
+
context "With Capybara 1.x", :capybara_version => [1, "1.9.9"] do
|
75
75
|
it "should not exist" do
|
76
76
|
driver.should_not respond_to :base_html
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
context "With Capybara 2.x", :capybara_version => 2 do
|
80
|
+
context "With Capybara 2.x", :capybara_version => [2, "2.9.9"] do
|
81
81
|
it "should exist" do
|
82
82
|
driver.should respond_to :base_html
|
83
83
|
end
|
@@ -201,35 +201,96 @@ describe Sauce::Capybara do
|
|
201
201
|
describe '#find' do
|
202
202
|
let(:selector) { '#lol' }
|
203
203
|
|
204
|
-
context
|
205
|
-
|
206
|
-
|
204
|
+
context "with Capybara < 2.1", :capybara_version => [2, "2.0.9"] do
|
205
|
+
|
206
|
+
it "should exist" do
|
207
|
+
driver.respond_to?(:find).should be_true
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'with an environment override' do
|
211
|
+
before :each do
|
212
|
+
ENV['SAUCE_DISABLE_RETRY'] = '1'
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should not retry and raise the error' do
|
216
|
+
driver.should_receive(:base_find).with(selector).and_raise(Selenium::WebDriver::Error::UnknownError)
|
217
|
+
|
218
|
+
expect {
|
219
|
+
driver.find(selector)
|
220
|
+
}.to raise_error(Selenium::WebDriver::Error::UnknownError)
|
221
|
+
end
|
222
|
+
|
223
|
+
after :each do
|
224
|
+
ENV['SAUCE_DISABLE_RETRY'] = nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should route through handle_retry' do
|
229
|
+
driver.should_receive(:base_find).with(selector) # BLECH
|
230
|
+
driver.find(selector)
|
207
231
|
end
|
208
232
|
|
209
|
-
it 'should
|
210
|
-
driver.should_receive(:base_find).with(selector).and_raise(Selenium::WebDriver::Error::UnknownError)
|
233
|
+
it 'should retry 3 times and then raise' do
|
234
|
+
driver.should_receive(:base_find).with(selector).exactly(4).times.and_raise(Selenium::WebDriver::Error::UnknownError)
|
211
235
|
|
212
236
|
expect {
|
213
237
|
driver.find(selector)
|
214
238
|
}.to raise_error(Selenium::WebDriver::Error::UnknownError)
|
215
239
|
end
|
240
|
+
end
|
241
|
+
|
242
|
+
context "with Capybara => 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
243
|
+
it "should not be aliased" do
|
244
|
+
driver.respond_to?(:base_find).should be_false
|
245
|
+
end
|
216
246
|
|
217
|
-
|
218
|
-
|
247
|
+
it "should not be retried" do
|
248
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find
|
219
249
|
end
|
220
250
|
end
|
251
|
+
end
|
221
252
|
|
222
|
-
|
223
|
-
|
224
|
-
|
253
|
+
describe "#find_css" do
|
254
|
+
context "with Capybara < 2.1", :capybara_version => [0, "2.0.9"] do
|
255
|
+
it "should not be aliased" do
|
256
|
+
driver.respond_to?(:base_find_css).should be_false
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should not be retried" do
|
260
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find_css
|
261
|
+
end
|
225
262
|
end
|
226
263
|
|
227
|
-
|
228
|
-
|
264
|
+
context "with Capybara >= 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
265
|
+
it "should be aliased" do
|
266
|
+
driver.respond_to?(:base_find_css).should be_true
|
267
|
+
end
|
229
268
|
|
230
|
-
|
231
|
-
|
232
|
-
|
269
|
+
it "should be retried" do
|
270
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should include :find_css
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe "#find_xpath" do
|
276
|
+
context "with Capybara < 2.1", :capybara_version => [0, "2.0.9"] do
|
277
|
+
it "should not be aliased" do
|
278
|
+
driver.respond_to?(:base_find_xpath).should be_false
|
279
|
+
end
|
280
|
+
|
281
|
+
it "should not be retried" do
|
282
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should_not include :find_xpath
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
context "with Capybara >= 2.1", :capybara_version => ["2.1", "2.9.9"] do
|
287
|
+
it "should be aliased" do
|
288
|
+
driver.respond_to?(:base_find_xpath).should be_true
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should be retried" do
|
292
|
+
Sauce::Capybara::Driver.instance_variable_get(:@methods_to_retry).should include :find_xpath
|
293
|
+
end
|
233
294
|
end
|
234
295
|
end
|
235
296
|
|
data/spec/sauce/config_spec.rb
CHANGED
@@ -195,6 +195,72 @@ describe Sauce::Config do
|
|
195
195
|
config.to_desired_capabilities[:platform].should == 'VISTA'
|
196
196
|
end
|
197
197
|
end
|
198
|
+
|
199
|
+
context 'client_version' do
|
200
|
+
let(:config) {Sauce::Config.new()}
|
201
|
+
|
202
|
+
it 'should include the Ruby engine' do
|
203
|
+
config.to_desired_capabilities[:client_version].should include RUBY_ENGINE
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should include the ruby platform" do
|
207
|
+
config.to_desired_capabilities[:client_version].should include RUBY_PLATFORM
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should include the ruby version" do
|
211
|
+
config.to_desired_capabilities[:client_version].should include RUBY_VERSION
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should include the gem version" do
|
215
|
+
config.to_desired_capabilities[:client_version].should include Sauce.version
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should include a bracketed array of tools in use" do
|
219
|
+
config.to_desired_capabilities[:client_version].should include config.tools.to_s
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#tools" do
|
224
|
+
let(:config) {Sauce::Config.new}
|
225
|
+
|
226
|
+
before :each do
|
227
|
+
config.stub(:is_defined?).and_call_original
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should include rspec if present" do
|
231
|
+
config.tools.should include "Rspec"
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should include capybara" do
|
235
|
+
config.stub(:is_defined?).with("Capybara") {true}
|
236
|
+
config.tools.should include "Capybara"
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should not include capybara when absent" do
|
240
|
+
config.stub(:is_defined?).with("Capybara") {false}
|
241
|
+
config.tools.should_not include "Capybara"
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should not include cucumber when not present" do
|
245
|
+
config.stub(:is_defined?).with("Cucumber") {false}
|
246
|
+
config.tools.should_not include "Cucumber"
|
247
|
+
end
|
248
|
+
|
249
|
+
it "should include cucumber when present" do
|
250
|
+
config.stub(:is_defined?).with("Cucumber") {true}
|
251
|
+
config.tools.should include "Cucumber"
|
252
|
+
end
|
253
|
+
|
254
|
+
it "should include test::unit if present" do
|
255
|
+
config.stub(:is_defined?).with("Test","Unit") {true}
|
256
|
+
config.tools.should include "Test::Unit"
|
257
|
+
end
|
258
|
+
|
259
|
+
it "should not include test::unit if absent" do
|
260
|
+
config.stub(:is_defined?).with("Test", "Unit") {false}
|
261
|
+
config.tools.should_not include "Test::Unit"
|
262
|
+
end
|
263
|
+
end
|
198
264
|
end
|
199
265
|
|
200
266
|
context 'configuring Sauce' do
|
data/spec/spec_helper.rb
CHANGED
@@ -8,9 +8,11 @@ require 'sauce'
|
|
8
8
|
require 'capybara'
|
9
9
|
|
10
10
|
RSpec.configure do |c|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
c.filter_run_excluding :capybara_version => lambda { |capybara_version_range|
|
12
|
+
actual_version = Gem::Version.new Capybara::VERSION
|
13
|
+
lower_bound = Gem::Version.new capybara_version_range[0]
|
14
|
+
upper_bound = Gem::Version.new capybara_version_range[1]
|
15
|
+
|
16
|
+
!actual_version.between?(lower_bound, upper_bound)
|
17
|
+
}
|
16
18
|
end
|
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.4.
|
4
|
+
version: 2.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,8 +14,24 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2013-04-
|
17
|
+
date: 2013-04-20 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: capybara
|
21
|
+
requirement: !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
type: :development
|
28
|
+
prerelease: false
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.1.0
|
19
35
|
- !ruby/object:Gem::Dependency
|
20
36
|
name: net-http-persistent
|
21
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
226
|
version: '0'
|
211
227
|
segments:
|
212
228
|
- 0
|
213
|
-
hash: -
|
229
|
+
hash: -4599655559509497330
|
214
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
231
|
none: false
|
216
232
|
requirements:
|
@@ -219,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
235
|
version: '0'
|
220
236
|
segments:
|
221
237
|
- 0
|
222
|
-
hash: -
|
238
|
+
hash: -4599655559509497330
|
223
239
|
requirements: []
|
224
240
|
rubyforge_project:
|
225
241
|
rubygems_version: 1.8.25
|