Skip to content

Commit d72bfdb

Browse files
committed
New Ferrum release compatibility
1 parent a2967cd commit d72bfdb

File tree

4 files changed

+56
-33
lines changed

4 files changed

+56
-33
lines changed

cuprite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
1919
s.required_ruby_version = ">= 2.3.0"
2020

2121
s.add_runtime_dependency "capybara", ">= 2.1", "< 4"
22-
s.add_runtime_dependency "ferrum", "~> 0.6.0"
22+
s.add_runtime_dependency "ferrum", "~> 0.7.0"
2323

2424
s.add_development_dependency "image_size", "~> 2.0"
2525
s.add_development_dependency "pdf-reader", "~> 2.1"

spec/integration/driver_spec.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,6 @@ def create_screenshot(file, *args)
525525
expect(@driver.evaluate_script("window.result")).to eq(3)
526526
end
527527

528-
it "operates a timeout when communicating with browser" do
529-
begin
530-
prev_timeout = @driver.timeout
531-
@driver.timeout = 0.1
532-
expect { @driver.visit(session_url("/cuprite/really_slow")) }.to raise_error(Ferrum::TimeoutError)
533-
ensure
534-
@driver.timeout = prev_timeout
535-
end
536-
end
537-
538528
it "supports stopping the session", skip: Ferrum.windows? do
539529
driver = Capybara::Cuprite::Driver.new(nil)
540530
pid = driver.browser.process.pid
@@ -671,27 +661,41 @@ def create_screenshot(file, *args)
671661
)
672662
end
673663

674-
it "reports open resource requests", skip: true do
675-
old_timeout = @session.driver.timeout
664+
it "operates a timeout when communicating with browser" do
676665
begin
666+
old_timeout = @driver.timeout
667+
@driver.timeout = 0.1
668+
expect {
669+
@driver.visit(session_url("/cuprite/really_slow"))
670+
}.to raise_error(
671+
Ferrum::StatusError,
672+
%r{there are still pending connections: http://.*/cuprite/really_slow}
673+
)
674+
ensure
675+
@driver.timeout = old_timeout
676+
end
677+
end
678+
679+
it "reports open resource requests" do
680+
begin
681+
old_timeout = @session.driver.timeout
677682
@session.driver.timeout = 2
678-
expect do
683+
expect {
679684
@session.visit("/cuprite/visit_timeout")
680-
end.to raise_error(Ferrum::StatusError, %r{resources still waiting http://.*/cuprite/really_slow})
685+
}.to raise_error(
686+
Ferrum::StatusError,
687+
%r{there are still pending connections: http://.*/cuprite/really_slow}
688+
)
681689
ensure
682690
@session.driver.timeout = old_timeout
683691
end
684692
end
685693

686-
it "does not report open resources where there are none", skip: true do
694+
it "does not report open resources where there are none" do
687695
old_timeout = @session.driver.timeout
688696
begin
689-
@session.driver.timeout = 2
690-
expect do
691-
@session.visit("/cuprite/really_slow")
692-
end.to raise_error(Ferrum::StatusError) { |error|
693-
expect(error.message).not_to include("resources still waiting")
694-
}
697+
@session.driver.timeout = 4
698+
expect { @session.visit("/cuprite/really_slow") }.not_to raise_error
695699
ensure
696700
@session.driver.timeout = old_timeout
697701
end

spec/spec_helper.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
Capybara.register_driver(:cuprite) do |app|
1616
options = {}
1717
options.merge!(inspector: true) if ENV["INSPECTOR"]
18-
options.merge!(logger: StringIO.new)
18+
options.merge!(logger: StringIO.new) if ENV["TRAVIS"]
1919
driver = Capybara::Cuprite::Driver.new(app, options)
20-
puts driver.browser.process.cmd.join(" ")
21-
puts `"#{driver.browser.process.path}" -version --headless --no-gpu`
20+
process = driver.browser.process
21+
22+
puts "Browser: #{process.browser_version}"
23+
puts "Protocol: #{process.protocol_version}"
24+
puts "V8: #{process.v8_version}"
25+
puts "Webkit: #{process.webkit_version}"
26+
2227
driver
2328
end
2429

@@ -42,6 +47,13 @@ module TestSessions
4247
node #drag_to HTML5 should HTML5 drag and drop when scrolling needed
4348
node #drag_to HTML5 should drag HTML5 default draggable elements
4449
node #drag_to HTML5 should drag HTML5 default draggable element child
50+
node #drag_to should simulate a single held down modifier key
51+
node #drag_to should simulate multiple held down modifier keys
52+
node #drag_to should support key aliases
53+
node #drag_to HTML5 should preserve clientX/Y from last dragover event
54+
node #drag_to HTML5 should simulate a single held down modifier key
55+
node #drag_to HTML5 should simulate multiple held down modifier keys
56+
node #drag_to HTML5 should support key aliases
4557
node Element#drop can drop a file
4658
node Element#drop can drop multiple files
4759
node Element#drop can drop strings
@@ -76,18 +88,25 @@ module TestSessions
7688
metadata[:skip] = true if metadata[:full_description].match(/#{regexes}/)
7789
end
7890

79-
config.before do
80-
session = @session || TestSessions::Cuprite
81-
session.driver.browser.logger.truncate(0)
82-
session.driver.browser.logger.rewind
83-
end
91+
config.around do |example|
92+
if ENV["TRAVIS"]
93+
session = @session || TestSessions::Cuprite
94+
session.driver.browser.logger.truncate(0)
95+
session.driver.browser.logger.rewind
96+
end
97+
98+
example.run
8499

85-
config.after do |example|
86-
if example.exception
100+
if ENV["TRAVIS"] && example.exception
87101
session = @session || TestSessions::Cuprite
88102
raise session.driver.browser.logger.string
89103
end
90104
end
91105

106+
config.after do
107+
FileUtils.rm_rf(CUPRITE_ROOT + "/screenshots")
108+
FileUtils.rm_rf(CUPRITE_ROOT + "/save_path_tmp")
109+
end
110+
92111
Capybara::SpecHelper.configure(config)
93112
end

spec/support/views/with_different_resources.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</head>
66

77
<body>
8-
<img src="unexist.png">
8+
<img src="/cuprite/unexist.png">
99

1010
<a href="/cuprite/redirect">Do redirect</a>
1111
<a href="/cuprite/status/201">Go to 201</a>

0 commit comments

Comments
 (0)