Skip to content

Commit 5a2b01d

Browse files
committed
Drop capybara 2 support
1 parent 7449c40 commit 5a2b01d

File tree

8 files changed

+22
-75
lines changed

8 files changed

+22
-75
lines changed

.github/gemfiles/capybara-2.x.gemfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
gemfile: [capybara-2.x, capybara-3.x, ferrum-master, websocket-driver-6.x]
15+
gemfile: [capybara-3.x, websocket-driver-6.x, ferrum-master]
1616
ruby: [2.5, 2.6, 2.7]
1717

1818
runs-on: ubuntu-latest

cuprite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
2424

2525
s.required_ruby_version = ">= 2.5.0"
2626

27-
s.add_runtime_dependency "capybara", ">= 2.1", "< 4"
27+
s.add_runtime_dependency "capybara", "~> 3.0"
2828
s.add_runtime_dependency "ferrum", "~> 0.11.0"
2929

3030
s.add_development_dependency "image_size", "~> 3.0"

lib/capybara/cuprite/browser.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ def window_handles
7979
def within_window(locator = nil, &block)
8080
original = window_handle
8181

82-
if Capybara::VERSION.to_f < 3.0
83-
target_id = window_handles.find do |target_id|
84-
page = attach_page(target_id)
85-
locator == page.frame_name
86-
end
87-
locator = target_id if target_id
88-
end
89-
9082
if window_handles.include?(locator)
9183
switch_to_window(locator)
9284
yield

lib/capybara/cuprite/driver.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ def visit(url)
4444
end
4545

4646
def current_url
47-
if Capybara::VERSION.to_f < 3.0
48-
frame_url
49-
else
50-
browser.current_url
51-
end
47+
browser.current_url
5248
end
5349

5450
def frame_url
@@ -65,11 +61,7 @@ def source
6561
end
6662

6763
def title
68-
if Capybara::VERSION.to_f < 3.0
69-
frame_title
70-
else
71-
browser.title
72-
end
64+
browser.title
7365
end
7466

7567
def frame_title

lib/capybara/cuprite/node.rb

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,11 @@ def all_text
5454
end
5555

5656
def visible_text
57-
if Capybara::VERSION.to_f < 3.0
58-
filter_text(command(:visible_text))
59-
else
60-
command(:visible_text).to_s
61-
.gsub(/\A[[:space:]&&[^\u00a0]]+/, "")
62-
.gsub(/[[:space:]&&[^\u00a0]]+\z/, "")
63-
.gsub(/\n+/, "\n")
64-
.tr("\u00a0", " ")
65-
end
57+
command(:visible_text).to_s
58+
.gsub(/\A[[:space:]&&[^\u00a0]]+/, "")
59+
.gsub(/[[:space:]&&[^\u00a0]]+\z/, "")
60+
.gsub(/\n+/, "\n")
61+
.tr("\u00a0", " ")
6662
end
6763

6864
def property(name)
@@ -236,15 +232,11 @@ def prepare_and_click(mode, name, keys, options)
236232
end
237233

238234
def filter_text(text)
239-
if Capybara::VERSION.to_f < 3
240-
Capybara::Helpers.normalize_whitespace(text.to_s)
241-
else
242-
text.gsub(/[\u200b\u200e\u200f]/, "")
243-
.gsub(/[\ \n\f\t\v\u2028\u2029]+/, " ")
244-
.gsub(/\A[[:space:]&&[^\u00a0]]+/, "")
245-
.gsub(/[[:space:]&&[^\u00a0]]+\z/, "")
246-
.tr("\u00a0", " ")
247-
end
235+
text.gsub(/[\u200b\u200e\u200f]/, "")
236+
.gsub(/[\ \n\f\t\v\u2028\u2029]+/, " ")
237+
.gsub(/\A[[:space:]&&[^\u00a0]]+/, "")
238+
.gsub(/[[:space:]&&[^\u00a0]]+\z/, "")
239+
.tr("\u00a0", " ")
248240
end
249241

250242
def scroll_element_to_location(element, location)

spec/features/driver_spec.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,12 +1561,7 @@ def create_screenshot(file, *args)
15611561

15621562
@session.within_frame(0) do
15631563
expect(@session.driver.frame_url).to end_with("/cuprite/slow")
1564-
if Capybara::VERSION.to_f < 3.0
1565-
expect(@session.driver.current_url).to end_with("/cuprite/slow")
1566-
else
1567-
# current_url is required to return the top level browsing context in Capybara 3
15681564
expect(@session.driver.current_url).to end_with("/cuprite/frames")
1569-
end
15701565
end
15711566
expect(@session.driver.frame_url).to end_with("/cuprite/frames")
15721567
expect(@session.driver.current_url).to end_with("/cuprite/frames")

spec/features/session_spec.rb

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,9 @@
532532
end
533533
end
534534

535-
if Capybara::VERSION.to_f < 3.0
536-
it "returns BR as a space in #text" do
537-
@session.visit "/cuprite/simple"
538-
expect(@session.find(:css, "#break").text).to eq("Foo Bar")
539-
end
540-
else
541-
it "returns BR as new line in #text" do
542-
@session.visit "/cuprite/simple"
543-
expect(@session.find(:css, "#break").text).to eq("Foo\nBar")
544-
end
535+
it "returns BR as new line in #text" do
536+
@session.visit "/cuprite/simple"
537+
expect(@session.find(:css, "#break").text).to eq("Foo\nBar")
545538
end
546539

547540
it "handles hash changes" do
@@ -871,22 +864,12 @@
871864
expect(@session.find(:css, "#bar").text).to eq "bar"
872865
end
873866

874-
if Capybara::VERSION.to_f < 3.0
875-
it "gets text stripped whitespace and nbsp" do
876-
expect(@session.find(:css, "#baz").text).to eq "baz"
877-
end
878-
879-
it "gets text stripped whitespace, nbsp and unicode whitespace" do
880-
expect(@session.find(:css, "#qux").text).to eq "qux"
881-
end
882-
else
883-
it "gets text stripped whitespace and then converts nbsp to space" do
884-
expect(@session.find(:css, "#baz").text).to eq " baz "
885-
end
867+
it "gets text stripped whitespace and then converts nbsp to space" do
868+
expect(@session.find(:css, "#baz").text).to eq " baz "
869+
end
886870

887-
it "gets text stripped whitespace" do
888-
expect(@session.find(:css, "#qux").text).to eq " \u3000 qux \u3000 "
889-
end
871+
it "gets text stripped whitespace" do
872+
expect(@session.find(:css, "#qux").text).to eq " \u3000 qux \u3000 "
890873
end
891874
end
892875

0 commit comments

Comments
 (0)