capybara 3.23.0 → 3.35.3
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 +4 -4
- data/History.md +264 -11
- data/README.md +10 -6
- data/lib/capybara.rb +20 -8
- data/lib/capybara/config.rb +10 -8
- data/lib/capybara/cucumber.rb +1 -1
- data/lib/capybara/driver/base.rb +4 -0
- data/lib/capybara/driver/node.rb +4 -0
- data/lib/capybara/dsl.rb +10 -2
- data/lib/capybara/helpers.rb +28 -2
- data/lib/capybara/minitest.rb +232 -144
- data/lib/capybara/minitest/spec.rb +156 -97
- data/lib/capybara/node/actions.rb +36 -36
- data/lib/capybara/node/base.rb +6 -6
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +3 -3
- data/lib/capybara/node/element.rb +77 -33
- data/lib/capybara/node/finders.rb +24 -17
- data/lib/capybara/node/matchers.rb +79 -64
- data/lib/capybara/node/simple.rb +11 -4
- data/lib/capybara/queries/ancestor_query.rb +6 -10
- data/lib/capybara/queries/base_query.rb +2 -1
- data/lib/capybara/queries/current_path_query.rb +14 -4
- data/lib/capybara/queries/selector_query.rb +259 -23
- data/lib/capybara/queries/sibling_query.rb +5 -11
- data/lib/capybara/queries/style_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +13 -1
- data/lib/capybara/rack_test/browser.rb +13 -4
- data/lib/capybara/rack_test/driver.rb +2 -1
- data/lib/capybara/rack_test/form.rb +2 -2
- data/lib/capybara/rack_test/node.rb +42 -6
- data/lib/capybara/registration_container.rb +44 -0
- data/lib/capybara/registrations/drivers.rb +18 -12
- data/lib/capybara/registrations/patches/puma_ssl.rb +29 -0
- data/lib/capybara/registrations/servers.rb +9 -2
- data/lib/capybara/result.rb +39 -19
- data/lib/capybara/rspec.rb +2 -0
- data/lib/capybara/rspec/matcher_proxies.rb +5 -5
- data/lib/capybara/rspec/matchers.rb +97 -74
- data/lib/capybara/rspec/matchers/base.rb +19 -6
- data/lib/capybara/rspec/matchers/count_sugar.rb +2 -1
- data/lib/capybara/rspec/matchers/have_ancestor.rb +5 -7
- data/lib/capybara/rspec/matchers/have_current_path.rb +2 -2
- data/lib/capybara/rspec/matchers/have_selector.rb +15 -10
- data/lib/capybara/rspec/matchers/have_sibling.rb +4 -7
- data/lib/capybara/rspec/matchers/have_text.rb +4 -7
- data/lib/capybara/rspec/matchers/have_title.rb +2 -2
- data/lib/capybara/rspec/matchers/match_selector.rb +3 -3
- data/lib/capybara/rspec/matchers/match_style.rb +7 -2
- data/lib/capybara/rspec/matchers/spatial_sugar.rb +39 -0
- data/lib/capybara/selector.rb +46 -19
- data/lib/capybara/selector/builders/css_builder.rb +10 -6
- data/lib/capybara/selector/builders/xpath_builder.rb +4 -2
- data/lib/capybara/selector/css.rb +1 -1
- data/lib/capybara/selector/definition.rb +13 -11
- data/lib/capybara/selector/definition/button.rb +32 -15
- data/lib/capybara/selector/definition/checkbox.rb +2 -2
- data/lib/capybara/selector/definition/css.rb +3 -1
- data/lib/capybara/selector/definition/datalist_input.rb +2 -2
- data/lib/capybara/selector/definition/datalist_option.rb +1 -1
- data/lib/capybara/selector/definition/element.rb +3 -2
- data/lib/capybara/selector/definition/field.rb +1 -1
- data/lib/capybara/selector/definition/file_field.rb +1 -1
- data/lib/capybara/selector/definition/fillable_field.rb +2 -2
- data/lib/capybara/selector/definition/label.rb +5 -3
- data/lib/capybara/selector/definition/link.rb +8 -0
- data/lib/capybara/selector/definition/option.rb +1 -1
- data/lib/capybara/selector/definition/radio_button.rb +2 -2
- data/lib/capybara/selector/definition/select.rb +33 -14
- data/lib/capybara/selector/definition/table.rb +6 -3
- data/lib/capybara/selector/definition/table_row.rb +2 -2
- data/lib/capybara/selector/filter_set.rb +13 -11
- data/lib/capybara/selector/filters/base.rb +6 -1
- data/lib/capybara/selector/filters/locator_filter.rb +1 -1
- data/lib/capybara/selector/regexp_disassembler.rb +7 -0
- data/lib/capybara/selector/selector.rb +13 -3
- data/lib/capybara/selenium/atoms/getAttribute.min.js +1 -1
- data/lib/capybara/selenium/atoms/isDisplayed.min.js +1 -1
- data/lib/capybara/selenium/atoms/src/getAttribute.js +1 -1
- data/lib/capybara/selenium/atoms/src/isDisplayed.js +10 -10
- data/lib/capybara/selenium/driver.rb +86 -24
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +24 -21
- data/lib/capybara/selenium/driver_specializations/edge_driver.rb +21 -19
- data/lib/capybara/selenium/driver_specializations/firefox_driver.rb +17 -1
- data/lib/capybara/selenium/driver_specializations/safari_driver.rb +0 -4
- data/lib/capybara/selenium/extensions/file_input_click_emulation.rb +34 -0
- data/lib/capybara/selenium/extensions/find.rb +37 -26
- data/lib/capybara/selenium/extensions/html5_drag.rb +55 -11
- data/lib/capybara/selenium/extensions/modifier_keys_stack.rb +28 -0
- data/lib/capybara/selenium/extensions/scroll.rb +8 -10
- data/lib/capybara/selenium/logger_suppressor.rb +8 -2
- data/lib/capybara/selenium/node.rb +160 -40
- data/lib/capybara/selenium/nodes/chrome_node.rb +72 -12
- data/lib/capybara/selenium/nodes/edge_node.rb +32 -14
- data/lib/capybara/selenium/nodes/firefox_node.rb +28 -32
- data/lib/capybara/selenium/nodes/safari_node.rb +5 -29
- data/lib/capybara/selenium/patches/action_pauser.rb +26 -0
- data/lib/capybara/selenium/patches/atoms.rb +4 -4
- data/lib/capybara/selenium/patches/is_displayed.rb +16 -0
- data/lib/capybara/selenium/patches/logs.rb +32 -7
- data/lib/capybara/server.rb +19 -3
- data/lib/capybara/server/animation_disabler.rb +8 -3
- data/lib/capybara/server/checker.rb +1 -1
- data/lib/capybara/server/middleware.rb +22 -10
- data/lib/capybara/session.rb +66 -40
- data/lib/capybara/session/config.rb +11 -3
- data/lib/capybara/session/matchers.rb +11 -11
- data/lib/capybara/spec/public/offset.js +6 -0
- data/lib/capybara/spec/public/test.js +75 -7
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -1
- data/lib/capybara/spec/session/all_spec.rb +60 -5
- data/lib/capybara/spec/session/ancestor_spec.rb +5 -0
- data/lib/capybara/spec/session/assert_text_spec.rb +9 -5
- data/lib/capybara/spec/session/check_spec.rb +6 -0
- data/lib/capybara/spec/session/click_button_spec.rb +16 -0
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +9 -0
- data/lib/capybara/spec/session/current_url_spec.rb +11 -1
- data/lib/capybara/spec/session/fill_in_spec.rb +29 -0
- data/lib/capybara/spec/session/find_spec.rb +55 -0
- data/lib/capybara/spec/session/has_ancestor_spec.rb +2 -0
- data/lib/capybara/spec/session/has_button_spec.rb +51 -0
- data/lib/capybara/spec/session/has_css_spec.rb +26 -4
- data/lib/capybara/spec/session/has_current_path_spec.rb +15 -2
- data/lib/capybara/spec/session/has_field_spec.rb +34 -0
- data/lib/capybara/spec/session/has_select_spec.rb +32 -4
- data/lib/capybara/spec/session/has_selector_spec.rb +4 -4
- data/lib/capybara/spec/session/has_table_spec.rb +51 -5
- data/lib/capybara/spec/session/has_text_spec.rb +30 -0
- data/lib/capybara/spec/session/html_spec.rb +1 -1
- data/lib/capybara/spec/session/matches_style_spec.rb +2 -2
- data/lib/capybara/spec/session/node_spec.rb +394 -9
- data/lib/capybara/spec/session/refresh_spec.rb +2 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +4 -4
- data/lib/capybara/spec/session/save_screenshot_spec.rb +4 -15
- data/lib/capybara/spec/session/selectors_spec.rb +16 -3
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +1 -1
- data/lib/capybara/spec/session/window/window_spec.rb +8 -8
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -1
- data/lib/capybara/spec/spec_helper.rb +14 -14
- data/lib/capybara/spec/test_app.rb +27 -21
- data/lib/capybara/spec/views/form.erb +47 -4
- data/lib/capybara/spec/views/offset.erb +32 -0
- data/lib/capybara/spec/views/spatial.erb +31 -0
- data/lib/capybara/spec/views/with_animation.erb +37 -1
- data/lib/capybara/spec/views/with_dragula.erb +24 -0
- data/lib/capybara/spec/views/with_html.erb +24 -2
- data/lib/capybara/spec/views/with_jquery_animation.erb +24 -0
- data/lib/capybara/spec/views/with_js.erb +4 -1
- data/lib/capybara/spec/views/with_jstree.erb +26 -0
- data/lib/capybara/spec/views/with_sortable_js.erb +1 -1
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +3 -7
- data/spec/basic_node_spec.rb +15 -14
- data/spec/capybara_spec.rb +28 -28
- data/spec/dsl_spec.rb +16 -3
- data/spec/filter_set_spec.rb +5 -5
- data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
- data/spec/minitest_spec.rb +3 -2
- data/spec/minitest_spec_spec.rb +46 -46
- data/spec/rack_test_spec.rb +38 -15
- data/spec/regexp_dissassembler_spec.rb +52 -38
- data/spec/result_spec.rb +43 -32
- data/spec/rspec/features_spec.rb +4 -1
- data/spec/rspec/scenarios_spec.rb +4 -0
- data/spec/rspec/shared_spec_matchers.rb +68 -56
- data/spec/rspec_spec.rb +9 -5
- data/spec/selector_spec.rb +32 -17
- data/spec/selenium_spec_chrome.rb +78 -11
- data/spec/selenium_spec_chrome_remote.rb +23 -6
- data/spec/selenium_spec_edge.rb +15 -12
- data/spec/selenium_spec_firefox.rb +24 -19
- data/spec/selenium_spec_firefox_remote.rb +0 -8
- data/spec/selenium_spec_ie.rb +1 -6
- data/spec/server_spec.rb +106 -44
- data/spec/session_spec.rb +5 -5
- data/spec/shared_selenium_node.rb +56 -2
- data/spec/shared_selenium_session.rb +122 -15
- data/spec/spec_helper.rb +2 -2
- metadata +63 -17
- data/lib/capybara/spec/session/source_spec.rb +0 -0
data/spec/dsl_spec.rb
CHANGED
@@ -8,7 +8,7 @@ class TestClass
|
|
8
8
|
end
|
9
9
|
|
10
10
|
Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
|
11
|
-
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll
|
11
|
+
js modals screenshot frames windows send_keys server hover about_scheme psc download css driver scroll spatial html_validation shadow_dom
|
12
12
|
] do |example|
|
13
13
|
case example.metadata[:full_description]
|
14
14
|
when /has_css\? should support case insensitive :class and :id options/
|
@@ -19,6 +19,10 @@ Capybara::SpecHelper.run_specs TestClass.new, 'DSL', capybara_skip: %i[
|
|
19
19
|
end
|
20
20
|
|
21
21
|
RSpec.describe Capybara::DSL do
|
22
|
+
before do
|
23
|
+
Capybara.use_default_driver
|
24
|
+
end
|
25
|
+
|
22
26
|
after do
|
23
27
|
Capybara.session_name = nil
|
24
28
|
Capybara.default_driver = nil
|
@@ -92,7 +96,7 @@ RSpec.describe Capybara::DSL do
|
|
92
96
|
driver_before_block = Capybara.current_driver
|
93
97
|
begin
|
94
98
|
Capybara.using_driver(:selenium) { raise 'ohnoes!' }
|
95
|
-
rescue Exception # rubocop:disable Lint/RescueException,Lint/
|
99
|
+
rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
|
96
100
|
end
|
97
101
|
expect(Capybara.current_driver).to eq(driver_before_block)
|
98
102
|
end
|
@@ -208,7 +212,7 @@ RSpec.describe Capybara::DSL do
|
|
208
212
|
Capybara.using_session(:raise) do
|
209
213
|
raise
|
210
214
|
end
|
211
|
-
rescue Exception # rubocop:disable Lint/RescueException,Lint/
|
215
|
+
rescue Exception # rubocop:disable Lint/RescueException,Lint/SuppressedException
|
212
216
|
end
|
213
217
|
expect(Capybara.session_name).to eq(:default)
|
214
218
|
end
|
@@ -238,6 +242,15 @@ RSpec.describe Capybara::DSL do
|
|
238
242
|
end
|
239
243
|
expect(Capybara.current_session).to eq(original_session)
|
240
244
|
end
|
245
|
+
|
246
|
+
it 'should pass the new session if block accepts' do
|
247
|
+
original_session = Capybara.current_session
|
248
|
+
Capybara.using_session(:administrator) do |admin_session, prev_session|
|
249
|
+
expect(admin_session).to be(Capybara.current_session)
|
250
|
+
expect(prev_session).to be(original_session)
|
251
|
+
expect(prev_session).not_to be(admin_session)
|
252
|
+
end
|
253
|
+
end
|
241
254
|
end
|
242
255
|
|
243
256
|
describe '#session_name' do
|
data/spec/filter_set_spec.rb
CHANGED
@@ -4,11 +4,11 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
RSpec.describe Capybara::Selector::FilterSet do
|
6
6
|
after do
|
7
|
-
|
7
|
+
described_class.remove(:test)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'allows node filters' do
|
11
|
-
fs =
|
11
|
+
fs = described_class.add(:test) do
|
12
12
|
node_filter(:node_test, :boolean) { |_node, _value| true }
|
13
13
|
expression_filter(:expression_test, :boolean) { |_expr, _value| true }
|
14
14
|
end
|
@@ -18,7 +18,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'allows expression filters' do
|
21
|
-
fs =
|
21
|
+
fs = described_class.add(:test) do
|
22
22
|
node_filter(:node_test, :boolean) { |_node, _value| true }
|
23
23
|
expression_filter(:expression_test, :boolean) { |_expr, _value| true }
|
24
24
|
end
|
@@ -28,7 +28,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'allows node filter and expression filter with the same name' do
|
31
|
-
fs =
|
31
|
+
fs = described_class.add(:test) do
|
32
32
|
node_filter(:test, :boolean) { |_node, _value| true }
|
33
33
|
expression_filter(:test, :boolean) { |_expr, _value| true }
|
34
34
|
end
|
@@ -37,7 +37,7 @@ RSpec.describe Capybara::Selector::FilterSet do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'allows `filter` as an alias of `node_filter`' do
|
40
|
-
fs =
|
40
|
+
fs = described_class.add(:test) do
|
41
41
|
filter(:node_test, :boolean) { |_node, _value| true }
|
42
42
|
end
|
43
43
|
|
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
|
6
6
|
RSpec.describe Capybara::Selenium::Driver do
|
7
7
|
it 'should exit with a non-zero exit status' do
|
8
8
|
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
9
|
-
browser =
|
9
|
+
browser = described_class.new(TestApp, options).browser
|
10
10
|
expect(browser).to be_truthy
|
11
11
|
expect(true).to eq(false) # rubocop:disable RSpec/ExpectActual
|
12
12
|
end
|
@@ -6,7 +6,7 @@ require 'selenium-webdriver'
|
|
6
6
|
RSpec.describe Capybara::Selenium::Driver do
|
7
7
|
it 'should exit with a zero exit status' do
|
8
8
|
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
|
9
|
-
browser =
|
9
|
+
browser = described_class.new(TestApp, **options).browser
|
10
10
|
expect(browser).to be_truthy
|
11
11
|
expect(true).to eq(true) # rubocop:disable RSpec/ExpectActual
|
12
12
|
end
|
data/spec/minitest_spec.rb
CHANGED
@@ -16,7 +16,7 @@ class MinitestTest < Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_assert_text
|
19
|
-
assert_text('Form')
|
19
|
+
assert_text('Form', normalize_ws: false)
|
20
20
|
assert_no_text('Not on the page')
|
21
21
|
refute_text('Also Not on the page')
|
22
22
|
end
|
@@ -30,6 +30,7 @@ class MinitestTest < Minitest::Test
|
|
30
30
|
|
31
31
|
def test_assert_current_path
|
32
32
|
assert_current_path('/form')
|
33
|
+
assert_current_path('/form') { |url| url.query.nil? }
|
33
34
|
assert_no_current_path('/not_form')
|
34
35
|
refute_current_path('/not_form')
|
35
36
|
end
|
@@ -158,6 +159,6 @@ RSpec.describe 'capybara/minitest' do
|
|
158
159
|
reporter.start
|
159
160
|
MinitestTest.run reporter, {}
|
160
161
|
reporter.report
|
161
|
-
expect(output.string).to include('22 runs,
|
162
|
+
expect(output.string).to include('22 runs, 53 assertions, 0 failures, 0 errors, 1 skips')
|
162
163
|
end
|
163
164
|
end
|
data/spec/minitest_spec_spec.rb
CHANGED
@@ -17,125 +17,125 @@ class MinitestSpecTest < Minitest::Spec
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'supports text expectations' do
|
20
|
-
page.must_have_text('Form', minimum: 1)
|
21
|
-
page.wont_have_text('Not a form')
|
20
|
+
_(page).must_have_text('Form', minimum: 1)
|
21
|
+
_(page).wont_have_text('Not a form')
|
22
22
|
form = find(:css, 'form', text: 'Title')
|
23
|
-
form.must_have_text('Customer Email')
|
24
|
-
form.wont_have_text('Some other email')
|
23
|
+
_(form).must_have_text('Customer Email')
|
24
|
+
_(form).wont_have_text('Some other email')
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'supports current_path expectations' do
|
28
|
-
page.must_have_current_path('/form')
|
29
|
-
page.wont_have_current_path('/form2')
|
28
|
+
_(page).must_have_current_path('/form')
|
29
|
+
_(page).wont_have_current_path('/form2')
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'supports title expectations' do
|
33
33
|
visit('/with_title')
|
34
|
-
page.must_have_title('Test Title')
|
35
|
-
page.wont_have_title('Not the title')
|
34
|
+
_(page).must_have_title('Test Title')
|
35
|
+
_(page).wont_have_title('Not the title')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'supports xpath expectations' do
|
39
|
-
page.must_have_xpath('.//input[@id="customer_email"]')
|
40
|
-
page.wont_have_xpath('.//select[@id="not_form_title"]')
|
41
|
-
page.wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
|
39
|
+
_(page).must_have_xpath('.//input[@id="customer_email"]')
|
40
|
+
_(page).wont_have_xpath('.//select[@id="not_form_title"]')
|
41
|
+
_(page).wont_have_xpath('.//input[@id="customer_email"]') { |el| el[:id] == 'not_customer_email' }
|
42
42
|
select = find(:select, 'form_title')
|
43
|
-
select.must_have_xpath('.//option[@class="title"]')
|
44
|
-
select.must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
|
45
|
-
select.wont_have_xpath('.//input[@id="customer_email"]')
|
43
|
+
_(select).must_have_xpath('.//option[@class="title"]')
|
44
|
+
_(select).must_have_xpath('.//option', count: 1) { |option| option[:class] != 'title' && !option.disabled? }
|
45
|
+
_(select).wont_have_xpath('.//input[@id="customer_email"]')
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'support css expectations' do
|
49
|
-
page.must_have_css('input#customer_email')
|
50
|
-
page.wont_have_css('select#not_form_title')
|
49
|
+
_(page).must_have_css('input#customer_email')
|
50
|
+
_(page).wont_have_css('select#not_form_title')
|
51
51
|
el = find(:select, 'form_title')
|
52
|
-
el.must_have_css('option.title')
|
53
|
-
el.wont_have_css('input#customer_email')
|
52
|
+
_(el).must_have_css('option.title')
|
53
|
+
_(el).wont_have_css('input#customer_email')
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'supports link expectations' do
|
57
57
|
visit('/with_html')
|
58
|
-
page.must_have_link('A link')
|
59
|
-
page.wont_have_link('Not on page')
|
58
|
+
_(page).must_have_link('A link')
|
59
|
+
_(page).wont_have_link('Not on page')
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'supports button expectations' do
|
63
|
-
page.must_have_button('fresh_btn')
|
64
|
-
page.wont_have_button('not_btn')
|
63
|
+
_(page).must_have_button('fresh_btn')
|
64
|
+
_(page).wont_have_button('not_btn')
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'supports field expectations' do
|
68
|
-
page.must_have_field('customer_email')
|
69
|
-
page.wont_have_field('not_on_the_form')
|
68
|
+
_(page).must_have_field('customer_email')
|
69
|
+
_(page).wont_have_field('not_on_the_form')
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'supports select expectations' do
|
73
|
-
page.must_have_select('form_title')
|
74
|
-
page.wont_have_select('not_form_title')
|
73
|
+
_(page).must_have_select('form_title')
|
74
|
+
_(page).wont_have_select('not_form_title')
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'supports checked_field expectations' do
|
78
|
-
page.must_have_checked_field('form_pets_dog')
|
79
|
-
page.wont_have_checked_field('form_pets_cat')
|
78
|
+
_(page).must_have_checked_field('form_pets_dog')
|
79
|
+
_(page).wont_have_checked_field('form_pets_cat')
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'supports unchecked_field expectations' do
|
83
|
-
page.must_have_unchecked_field('form_pets_cat')
|
84
|
-
page.wont_have_unchecked_field('form_pets_dog')
|
83
|
+
_(page).must_have_unchecked_field('form_pets_cat')
|
84
|
+
_(page).wont_have_unchecked_field('form_pets_dog')
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'supports table expectations' do
|
88
88
|
visit('/tables')
|
89
|
-
page.must_have_table('agent_table')
|
90
|
-
page.wont_have_table('not_on_form')
|
89
|
+
_(page).must_have_table('agent_table')
|
90
|
+
_(page).wont_have_table('not_on_form')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'supports all_of_selectors expectations' do
|
94
|
-
page.must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
|
94
|
+
_(page).must_have_all_of_selectors(:css, 'select#form_other_title', 'input#form_last_name')
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'supports none_of_selectors expectations' do
|
98
|
-
page.must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
|
98
|
+
_(page).must_have_none_of_selectors(:css, 'input#not_on_page', 'input#also_not_on_page')
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'supports any_of_selectors expectations' do
|
102
|
-
page.must_have_any_of_selectors(:css, 'select#form_other_title', 'input#not_on_page')
|
102
|
+
_(page).must_have_any_of_selectors(:css, 'select#form_other_title', 'input#not_on_page')
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'supports match_selector expectations' do
|
106
|
-
find(:field, 'customer_email').must_match_selector(:field, 'customer_email')
|
107
|
-
find(:select, 'form_title').wont_match_selector(:field, 'customer_email')
|
106
|
+
_(find(:field, 'customer_email')).must_match_selector(:field, 'customer_email')
|
107
|
+
_(find(:select, 'form_title')).wont_match_selector(:field, 'customer_email')
|
108
108
|
end
|
109
109
|
|
110
110
|
it 'supports match_css expectations' do
|
111
|
-
find(:select, 'form_title').must_match_css('select#form_title')
|
112
|
-
find(:select, 'form_title').wont_match_css('select#form_other_title')
|
111
|
+
_(find(:select, 'form_title')).must_match_css('select#form_title')
|
112
|
+
_(find(:select, 'form_title')).wont_match_css('select#form_other_title')
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'supports match_xpath expectations' do
|
116
|
-
find(:select, 'form_title').must_match_xpath('.//select[@id="form_title"]')
|
117
|
-
find(:select, 'form_title').wont_match_xpath('.//select[@id="not_on_page"]')
|
116
|
+
_(find(:select, 'form_title')).must_match_xpath('.//select[@id="form_title"]')
|
117
|
+
_(find(:select, 'form_title')).wont_match_xpath('.//select[@id="not_on_page"]')
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'handles failures' do
|
121
|
-
page.must_have_select('non_existing_form_title')
|
121
|
+
_(page).must_have_select('non_existing_form_title')
|
122
122
|
end
|
123
123
|
|
124
124
|
it 'supports style expectations' do
|
125
125
|
skip "Rack test doesn't support style" if Capybara.current_driver == :rack_test
|
126
126
|
visit('/with_html')
|
127
|
-
find(:css, '#second').must_have_style('display' => 'inline') # deprecated
|
128
|
-
find(:css, '#second').must_match_style('display' => 'inline')
|
127
|
+
_(find(:css, '#second')).must_have_style('display' => 'inline') # deprecated
|
128
|
+
_(find(:css, '#second')).must_match_style('display' => 'inline')
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'supports ancestor expectations' do
|
132
132
|
option = find(:option, 'Finnish')
|
133
|
-
option.must_have_ancestor(:css, '#form_locale')
|
133
|
+
_(option).must_have_ancestor(:css, '#form_locale')
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'supports sibling expectations' do
|
137
137
|
option = find(:css, '#form_title').find(:option, 'Mrs')
|
138
|
-
option.must_have_sibling(:option, 'Mr')
|
138
|
+
_(option).must_have_sibling(:option, 'Mr')
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
data/spec/rack_test_spec.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
nokogumbo_required = begin
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
require 'nokogumbo'
|
6
|
+
true
|
7
|
+
rescue LoadError
|
8
|
+
false
|
9
|
+
end
|
10
10
|
|
11
11
|
module TestSessions
|
12
12
|
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
@@ -25,6 +25,9 @@ skipped_tests = %i[
|
|
25
25
|
download
|
26
26
|
css
|
27
27
|
scroll
|
28
|
+
spatial
|
29
|
+
html_validation
|
30
|
+
shadow_dom
|
28
31
|
]
|
29
32
|
Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip: skipped_tests do |example|
|
30
33
|
case example.metadata[:full_description]
|
@@ -36,6 +39,7 @@ Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip
|
|
36
39
|
end
|
37
40
|
|
38
41
|
RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
42
|
+
include Capybara::RSpecMatchers
|
39
43
|
context 'with rack test driver' do
|
40
44
|
let(:session) { TestSessions::RackTest }
|
41
45
|
|
@@ -81,7 +85,6 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|
81
85
|
describe '#fill_in' do
|
82
86
|
it 'should warn that :fill_options are not supported' do
|
83
87
|
session.visit '/with_html'
|
84
|
-
|
85
88
|
expect { session.fill_in 'test_field', with: 'not_monkey', fill_options: { random: true } }.to \
|
86
89
|
output(/^Options passed to Node#set but the RackTest driver doesn't support any - ignoring/).to_stderr
|
87
90
|
expect(session).to have_field('test_field', with: 'not_monkey')
|
@@ -127,6 +130,26 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
|
|
127
130
|
session.find(:label, 'Female').click
|
128
131
|
expect(session).to have_unchecked_field('gender_male')
|
129
132
|
end
|
133
|
+
|
134
|
+
it 'should rewrite the forms action query for get submission' do
|
135
|
+
session.visit('/form')
|
136
|
+
session.click_button('mediocre')
|
137
|
+
expect(session).not_to have_current_path(/foo|bar/)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should rewrite the submit buttons formaction query for get submission' do
|
141
|
+
session.visit('/form')
|
142
|
+
session.click_button('mediocre2')
|
143
|
+
expect(session).not_to have_current_path(/foo|bar/)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#send_keys' do
|
149
|
+
it 'raises an UnsupportedMethodError' do
|
150
|
+
session.visit('/form')
|
151
|
+
|
152
|
+
expect { session.send_keys(:tab) }.to raise_error(Capybara::NotSupportedByDriverError)
|
130
153
|
end
|
131
154
|
end
|
132
155
|
|
@@ -155,27 +178,27 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
155
178
|
|
156
179
|
describe ':headers option' do
|
157
180
|
it 'should always set headers' do
|
158
|
-
driver =
|
181
|
+
driver = described_class.new(TestApp, headers: { 'HTTP_FOO' => 'foobar' })
|
159
182
|
driver.visit('/get_header')
|
160
183
|
expect(driver.html).to include('foobar')
|
161
184
|
end
|
162
185
|
|
163
186
|
it 'should keep headers on link clicks' do
|
164
|
-
driver =
|
187
|
+
driver = described_class.new(TestApp, headers: { 'HTTP_FOO' => 'foobar' })
|
165
188
|
driver.visit('/header_links')
|
166
189
|
driver.find_xpath('.//a').first.click
|
167
190
|
expect(driver.html).to include('foobar')
|
168
191
|
end
|
169
192
|
|
170
193
|
it 'should keep headers on form submit' do
|
171
|
-
driver =
|
194
|
+
driver = described_class.new(TestApp, headers: { 'HTTP_FOO' => 'foobar' })
|
172
195
|
driver.visit('/header_links')
|
173
196
|
driver.find_xpath('.//input').first.click
|
174
197
|
expect(driver.html).to include('foobar')
|
175
198
|
end
|
176
199
|
|
177
200
|
it 'should keep headers on redirects' do
|
178
|
-
driver =
|
201
|
+
driver = described_class.new(TestApp, headers: { 'HTTP_FOO' => 'foobar' })
|
179
202
|
driver.visit('/get_header_via_redirect')
|
180
203
|
expect(driver.html).to include('foobar')
|
181
204
|
end
|
@@ -183,7 +206,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
183
206
|
|
184
207
|
describe ':follow_redirects option' do
|
185
208
|
it 'defaults to following redirects' do
|
186
|
-
driver =
|
209
|
+
driver = described_class.new(TestApp)
|
187
210
|
|
188
211
|
driver.visit('/redirect')
|
189
212
|
expect(driver.response.header['Location']).to be_nil
|
@@ -191,7 +214,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
191
214
|
end
|
192
215
|
|
193
216
|
it 'is possible to not follow redirects' do
|
194
|
-
driver =
|
217
|
+
driver = described_class.new(TestApp, follow_redirects: false)
|
195
218
|
|
196
219
|
driver.visit('/redirect')
|
197
220
|
expect(driver.response.header['Location']).to match %r{/redirect_again$}
|
@@ -201,7 +224,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
201
224
|
|
202
225
|
describe ':redirect_limit option' do
|
203
226
|
context 'with default redirect limit' do
|
204
|
-
let(:driver) {
|
227
|
+
let(:driver) { described_class.new(TestApp) }
|
205
228
|
|
206
229
|
it 'should follow 5 redirects' do
|
207
230
|
driver.visit('/redirect/5/times')
|
@@ -216,7 +239,7 @@ RSpec.describe Capybara::RackTest::Driver do
|
|
216
239
|
end
|
217
240
|
|
218
241
|
context 'with 21 redirect limit' do
|
219
|
-
let(:driver) {
|
242
|
+
let(:driver) { described_class.new(TestApp, redirect_limit: 21) }
|
220
243
|
|
221
244
|
it 'should follow 21 redirects' do
|
222
245
|
driver.visit('/redirect/21/times')
|
@@ -251,6 +274,6 @@ RSpec.describe Capybara::RackTest::CSSHandlers do
|
|
251
274
|
include CSSHandlerIncludeTester
|
252
275
|
|
253
276
|
it 'should not be extended by global includes' do
|
254
|
-
expect(
|
277
|
+
expect(described_class.new).not_to respond_to(:dont_extend_css_handler)
|
255
278
|
end
|
256
279
|
end
|