capybara 2.5.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yard/templates_custom/default/class/html/selectors.erb +38 -0
- data/.yard/templates_custom/default/class/html/setup.rb +17 -0
- data/.yard/yard_extensions.rb +78 -0
- data/.yardopts +1 -0
- data/History.md +413 -10
- data/License.txt +1 -1
- data/README.md +237 -130
- data/lib/capybara/config.rb +132 -0
- data/lib/capybara/cucumber.rb +3 -1
- data/lib/capybara/driver/base.rb +27 -6
- data/lib/capybara/driver/node.rb +14 -5
- data/lib/capybara/dsl.rb +2 -3
- data/lib/capybara/helpers.rb +13 -65
- data/lib/capybara/minitest/spec.rb +177 -0
- data/lib/capybara/minitest.rb +278 -0
- data/lib/capybara/node/actions.rb +180 -24
- data/lib/capybara/node/base.rb +17 -5
- data/lib/capybara/node/document.rb +5 -0
- data/lib/capybara/node/document_matchers.rb +15 -14
- data/lib/capybara/node/element.rb +55 -7
- data/lib/capybara/node/finders.rb +179 -67
- data/lib/capybara/node/matchers.rb +301 -105
- data/lib/capybara/node/simple.rb +15 -4
- data/lib/capybara/queries/ancestor_query.rb +25 -0
- data/lib/capybara/queries/base_query.rb +69 -3
- data/lib/capybara/queries/current_path_query.rb +17 -8
- data/lib/capybara/queries/match_query.rb +19 -0
- data/lib/capybara/queries/selector_query.rb +251 -0
- data/lib/capybara/queries/sibling_query.rb +25 -0
- data/lib/capybara/queries/text_query.rb +67 -16
- data/lib/capybara/queries/title_query.rb +4 -2
- data/lib/capybara/query.rb +3 -131
- data/lib/capybara/rack_test/browser.rb +14 -5
- data/lib/capybara/rack_test/css_handlers.rb +1 -0
- data/lib/capybara/rack_test/driver.rb +15 -8
- data/lib/capybara/rack_test/form.rb +34 -12
- data/lib/capybara/rack_test/node.rb +29 -12
- data/lib/capybara/rails.rb +3 -3
- data/lib/capybara/result.rb +104 -9
- data/lib/capybara/rspec/compound.rb +95 -0
- data/lib/capybara/rspec/features.rb +17 -6
- data/lib/capybara/rspec/matcher_proxies.rb +45 -0
- data/lib/capybara/rspec/matchers.rb +199 -80
- data/lib/capybara/rspec.rb +4 -2
- data/lib/capybara/selector/css.rb +30 -0
- data/lib/capybara/selector/filter.rb +20 -0
- data/lib/capybara/selector/filter_set.rb +74 -0
- data/lib/capybara/selector/filters/base.rb +33 -0
- data/lib/capybara/selector/filters/expression_filter.rb +40 -0
- data/lib/capybara/selector/filters/node_filter.rb +27 -0
- data/lib/capybara/selector/selector.rb +276 -0
- data/lib/capybara/selector.rb +452 -157
- data/lib/capybara/selenium/driver.rb +282 -81
- data/lib/capybara/selenium/node.rb +144 -46
- data/lib/capybara/server.rb +59 -16
- data/lib/capybara/session/config.rb +114 -0
- data/lib/capybara/session/matchers.rb +29 -19
- data/lib/capybara/session.rb +378 -143
- data/lib/capybara/spec/fixtures/no_extension +1 -0
- data/lib/capybara/spec/public/jquery-ui.js +13 -791
- data/lib/capybara/spec/public/jquery.js +4 -9045
- data/lib/capybara/spec/public/test.js +45 -11
- data/lib/capybara/spec/session/accept_alert_spec.rb +30 -7
- data/lib/capybara/spec/session/accept_confirm_spec.rb +14 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +35 -6
- data/lib/capybara/spec/session/all_spec.rb +45 -32
- data/lib/capybara/spec/session/ancestor_spec.rb +85 -0
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +110 -0
- data/lib/capybara/spec/session/assert_current_path.rb +15 -2
- data/lib/capybara/spec/session/assert_selector.rb +29 -28
- data/lib/capybara/spec/session/assert_text.rb +59 -20
- data/lib/capybara/spec/session/assert_title.rb +25 -11
- data/lib/capybara/spec/session/attach_file_spec.rb +42 -4
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +90 -14
- data/lib/capybara/spec/session/choose_spec.rb +31 -5
- data/lib/capybara/spec/session/click_button_spec.rb +20 -9
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +15 -9
- data/lib/capybara/spec/session/click_link_spec.rb +39 -15
- data/lib/capybara/spec/session/current_scope_spec.rb +2 -1
- data/lib/capybara/spec/session/current_url_spec.rb +12 -3
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +6 -5
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +4 -3
- data/lib/capybara/spec/session/element/assert_match_selector.rb +36 -0
- data/lib/capybara/spec/session/element/match_css_spec.rb +23 -0
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +23 -0
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +106 -0
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +22 -0
- data/lib/capybara/spec/session/evaluate_script_spec.rb +23 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +22 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +50 -32
- data/lib/capybara/spec/session/find_button_spec.rb +43 -2
- data/lib/capybara/spec/session/find_by_id_spec.rb +3 -2
- data/lib/capybara/spec/session/find_field_spec.rb +42 -6
- data/lib/capybara/spec/session/find_link_spec.rb +22 -3
- data/lib/capybara/spec/session/find_spec.rb +103 -57
- data/lib/capybara/spec/session/first_spec.rb +34 -18
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +103 -0
- data/lib/capybara/spec/session/{within_frame_spec.rb → frame/within_frame_spec.rb} +44 -2
- data/lib/capybara/spec/session/go_back_spec.rb +2 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +2 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +69 -0
- data/lib/capybara/spec/session/has_button_spec.rb +17 -8
- data/lib/capybara/spec/session/has_css_spec.rb +85 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +91 -7
- data/lib/capybara/spec/session/has_field_spec.rb +93 -58
- data/lib/capybara/spec/session/has_link_spec.rb +9 -8
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +76 -0
- data/lib/capybara/spec/session/has_select_spec.rb +159 -59
- data/lib/capybara/spec/session/has_selector_spec.rb +64 -28
- data/lib/capybara/spec/session/has_table_spec.rb +1 -0
- data/lib/capybara/spec/session/has_text_spec.rb +27 -12
- data/lib/capybara/spec/session/has_title_spec.rb +22 -4
- data/lib/capybara/spec/session/has_xpath_spec.rb +32 -29
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +4 -3
- data/lib/capybara/spec/session/node_spec.rb +198 -38
- data/lib/capybara/spec/session/refresh_spec.rb +28 -0
- data/lib/capybara/spec/session/reset_session_spec.rb +46 -5
- data/lib/capybara/spec/session/response_code.rb +2 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -5
- data/lib/capybara/spec/session/save_page_spec.rb +34 -2
- data/lib/capybara/spec/session/save_screenshot_spec.rb +31 -1
- data/lib/capybara/spec/session/screenshot_spec.rb +4 -2
- data/lib/capybara/spec/session/select_spec.rb +34 -32
- data/lib/capybara/spec/session/selectors_spec.rb +65 -0
- data/lib/capybara/spec/session/sibling_spec.rb +52 -0
- data/lib/capybara/spec/session/text_spec.rb +4 -4
- data/lib/capybara/spec/session/title_spec.rb +2 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +42 -2
- data/lib/capybara/spec/session/unselect_spec.rb +17 -16
- data/lib/capybara/spec/session/visit_spec.rb +77 -2
- data/lib/capybara/spec/session/window/become_closed_spec.rb +12 -11
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -11
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +7 -4
- data/lib/capybara/spec/session/window/window_spec.rb +36 -29
- data/lib/capybara/spec/session/window/windows_spec.rb +1 -0
- data/lib/capybara/spec/session/window/within_window_spec.rb +31 -7
- data/lib/capybara/spec/session/within_spec.rb +14 -6
- data/lib/capybara/spec/spec_helper.rb +37 -4
- data/lib/capybara/spec/test_app.rb +15 -3
- data/lib/capybara/spec/views/buttons.erb +1 -0
- data/lib/capybara/spec/views/fieldsets.erb +2 -1
- data/lib/capybara/spec/views/form.erb +169 -9
- data/lib/capybara/spec/views/frame_child.erb +10 -2
- data/lib/capybara/spec/views/frame_one.erb +2 -1
- data/lib/capybara/spec/views/frame_parent.erb +3 -2
- data/lib/capybara/spec/views/frame_two.erb +2 -1
- data/lib/capybara/spec/views/header_links.erb +1 -0
- data/lib/capybara/spec/views/host_links.erb +1 -0
- data/lib/capybara/spec/views/initial_alert.erb +10 -0
- data/lib/capybara/spec/views/path.erb +1 -0
- data/lib/capybara/spec/views/popup_one.erb +1 -0
- data/lib/capybara/spec/views/popup_two.erb +1 -0
- data/lib/capybara/spec/views/postback.erb +2 -1
- data/lib/capybara/spec/views/tables.erb +1 -0
- data/lib/capybara/spec/views/with_base_tag.erb +1 -0
- data/lib/capybara/spec/views/with_count.erb +2 -1
- data/lib/capybara/spec/views/with_fixed_header_footer.erb +17 -0
- data/lib/capybara/spec/views/with_hover.erb +7 -1
- data/lib/capybara/spec/views/with_html.erb +40 -2
- data/lib/capybara/spec/views/with_html_entities.erb +1 -0
- data/lib/capybara/spec/views/with_js.erb +32 -1
- data/lib/capybara/spec/views/with_scope.erb +1 -0
- data/lib/capybara/spec/views/with_simple_html.erb +2 -1
- data/lib/capybara/spec/views/with_slow_unload.erb +17 -0
- data/lib/capybara/spec/views/with_title.erb +2 -1
- data/lib/capybara/spec/views/with_unload_alert.erb +14 -0
- data/lib/capybara/spec/views/with_windows.erb +7 -0
- data/lib/capybara/spec/views/within_frames.erb +3 -2
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +20 -3
- data/lib/capybara.rb +189 -93
- data/spec/basic_node_spec.rb +7 -6
- data/spec/capybara_spec.rb +90 -4
- data/spec/dsl_spec.rb +3 -1
- data/spec/filter_set_spec.rb +28 -0
- data/spec/fixtures/capybara.csv +1 -0
- data/spec/fixtures/selenium_driver_rspec_failure.rb +5 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +5 -1
- data/spec/minitest_spec.rb +130 -0
- data/spec/minitest_spec_spec.rb +135 -0
- data/spec/per_session_config_spec.rb +67 -0
- data/spec/rack_test_spec.rb +50 -7
- data/spec/result_spec.rb +76 -0
- data/spec/rspec/features_spec.rb +21 -8
- data/spec/rspec/scenarios_spec.rb +21 -0
- data/spec/rspec/{matchers_spec.rb → shared_spec_matchers.rb} +160 -54
- data/spec/rspec/views_spec.rb +5 -0
- data/spec/rspec_matchers_spec.rb +46 -0
- data/spec/rspec_spec.rb +79 -1
- data/spec/selector_spec.rb +199 -0
- data/spec/selenium_spec_chrome.rb +54 -9
- data/spec/selenium_spec_firefox.rb +68 -0
- data/spec/selenium_spec_marionette.rb +127 -0
- data/spec/server_spec.rb +102 -14
- data/spec/session_spec.rb +54 -0
- data/spec/shared_selenium_session.rb +215 -0
- data/spec/spec_helper.rb +7 -0
- metadata +140 -15
- data/spec/selenium_spec.rb +0 -128
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
Capybara::SpecHelper.spec '#has_field' do
|
2
3
|
before { @session.visit('/form') }
|
3
4
|
|
@@ -14,44 +15,60 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
14
15
|
|
15
16
|
context 'with value' do
|
16
17
|
it "should be true if a field with the given value is on the page" do
|
17
|
-
expect(@session).to have_field('First Name', :
|
18
|
-
expect(@session).to have_field('
|
19
|
-
expect(@session).to have_field('
|
20
|
-
expect(@session).to have_field('
|
18
|
+
expect(@session).to have_field('First Name', with: 'John')
|
19
|
+
expect(@session).to have_field('First Name', with: /^Joh/)
|
20
|
+
expect(@session).to have_field('Phone', with: '+1 555 7021')
|
21
|
+
expect(@session).to have_field('Street', with: 'Sesame street 66')
|
22
|
+
expect(@session).to have_field('Description', with: 'Descriptive text goes here')
|
21
23
|
end
|
22
24
|
|
23
25
|
it "should be false if the given field is not on the page" do
|
24
|
-
expect(@session).not_to have_field('First Name', :
|
25
|
-
expect(@session).not_to have_field('
|
26
|
-
expect(@session).not_to have_field('
|
26
|
+
expect(@session).not_to have_field('First Name', with: 'Peter')
|
27
|
+
expect(@session).not_to have_field('First Name', with: /eter$/)
|
28
|
+
expect(@session).not_to have_field('Wrong Name', with: 'John')
|
29
|
+
expect(@session).not_to have_field('Description', with: 'Monkey')
|
27
30
|
end
|
28
31
|
|
29
32
|
it "should be true after the field has been filled in with the given value" do
|
30
|
-
@session.fill_in('First Name', :
|
31
|
-
expect(@session).to have_field('First Name', :
|
33
|
+
@session.fill_in('First Name', with: 'Jonas')
|
34
|
+
expect(@session).to have_field('First Name', with: 'Jonas')
|
35
|
+
expect(@session).to have_field('First Name', with: /ona/)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "should be false after the field has been filled in with a different value" do
|
35
|
-
@session.fill_in('First Name', :
|
36
|
-
expect(@session).not_to have_field('First Name', :
|
39
|
+
@session.fill_in('First Name', with: 'Jonas')
|
40
|
+
expect(@session).not_to have_field('First Name', with: 'John')
|
41
|
+
expect(@session).not_to have_field('First Name', with: /John|Paul|George|Ringo/)
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
40
45
|
context 'with type' do
|
41
46
|
it "should be true if a field with the given type is on the page" do
|
42
|
-
expect(@session).to have_field('First Name', :
|
43
|
-
expect(@session).to have_field('Html5 Email', :
|
44
|
-
expect(@session).to have_field('Html5
|
45
|
-
expect(@session).to have_field('
|
46
|
-
expect(@session).to have_field('
|
47
|
+
expect(@session).to have_field('First Name', type: 'text')
|
48
|
+
expect(@session).to have_field('Html5 Email', type: 'email')
|
49
|
+
expect(@session).to have_field('Html5 Multiple Email', type: 'email')
|
50
|
+
expect(@session).to have_field('Html5 Tel', type: 'tel')
|
51
|
+
expect(@session).to have_field('Description', type: 'textarea')
|
52
|
+
expect(@session).to have_field('Languages', type: 'select')
|
47
53
|
end
|
48
54
|
|
49
55
|
it "should be false if the given field is not on the page" do
|
50
|
-
expect(@session).not_to have_field('First Name', :
|
51
|
-
expect(@session).not_to have_field('Html5 Email', :
|
52
|
-
expect(@session).not_to have_field('
|
53
|
-
expect(@session).not_to have_field('Description', :
|
54
|
-
expect(@session).not_to have_field('
|
56
|
+
expect(@session).not_to have_field('First Name', type: 'textarea')
|
57
|
+
expect(@session).not_to have_field('Html5 Email', type: 'tel')
|
58
|
+
expect(@session).not_to have_field('Html5 Multiple Email', type: 'tel')
|
59
|
+
expect(@session).not_to have_field('Description', type: '')
|
60
|
+
expect(@session).not_to have_field('Description', type: 'email')
|
61
|
+
expect(@session).not_to have_field('Languages', type: 'textarea')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with multiple' do
|
66
|
+
it "should be true if a field with the multiple attribute is on the page" do
|
67
|
+
expect(@session).to have_field('Html5 Multiple Email', multiple: true)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be false if a field without the multiple attribute is not on the page" do
|
71
|
+
expect(@session).not_to have_field('Html5 Multiple Email', multiple: false)
|
55
72
|
end
|
56
73
|
end
|
57
74
|
end
|
@@ -71,44 +88,44 @@ Capybara::SpecHelper.spec '#has_no_field' do
|
|
71
88
|
|
72
89
|
context 'with value' do
|
73
90
|
it "should be false if a field with the given value is on the page" do
|
74
|
-
expect(@session).not_to have_no_field('First Name', :
|
75
|
-
expect(@session).not_to have_no_field('Phone', :
|
76
|
-
expect(@session).not_to have_no_field('Street', :
|
77
|
-
expect(@session).not_to have_no_field('Description', :
|
91
|
+
expect(@session).not_to have_no_field('First Name', with: 'John')
|
92
|
+
expect(@session).not_to have_no_field('Phone', with: '+1 555 7021')
|
93
|
+
expect(@session).not_to have_no_field('Street', with: 'Sesame street 66')
|
94
|
+
expect(@session).not_to have_no_field('Description', with: 'Descriptive text goes here')
|
78
95
|
end
|
79
96
|
|
80
97
|
it "should be true if the given field is not on the page" do
|
81
|
-
expect(@session).to have_no_field('First Name', :
|
82
|
-
expect(@session).to have_no_field('Wrong Name', :
|
83
|
-
expect(@session).to have_no_field('Description', :
|
98
|
+
expect(@session).to have_no_field('First Name', with: 'Peter')
|
99
|
+
expect(@session).to have_no_field('Wrong Name', with: 'John')
|
100
|
+
expect(@session).to have_no_field('Description', with: 'Monkey')
|
84
101
|
end
|
85
102
|
|
86
103
|
it "should be false after the field has been filled in with the given value" do
|
87
|
-
@session.fill_in('First Name', :
|
88
|
-
expect(@session).not_to have_no_field('First Name', :
|
104
|
+
@session.fill_in('First Name', with: 'Jonas')
|
105
|
+
expect(@session).not_to have_no_field('First Name', with: 'Jonas')
|
89
106
|
end
|
90
107
|
|
91
108
|
it "should be true after the field has been filled in with a different value" do
|
92
|
-
@session.fill_in('First Name', :
|
93
|
-
expect(@session).to have_no_field('First Name', :
|
109
|
+
@session.fill_in('First Name', with: 'Jonas')
|
110
|
+
expect(@session).to have_no_field('First Name', with: 'John')
|
94
111
|
end
|
95
112
|
end
|
96
113
|
|
97
114
|
context 'with type' do
|
98
115
|
it "should be false if a field with the given type is on the page" do
|
99
|
-
expect(@session).not_to have_no_field('First Name', :
|
100
|
-
expect(@session).not_to have_no_field('Html5 Email', :
|
101
|
-
expect(@session).not_to have_no_field('Html5 Tel', :
|
102
|
-
expect(@session).not_to have_no_field('Description', :
|
103
|
-
expect(@session).not_to have_no_field('Languages', :
|
116
|
+
expect(@session).not_to have_no_field('First Name', type: 'text')
|
117
|
+
expect(@session).not_to have_no_field('Html5 Email', type: 'email')
|
118
|
+
expect(@session).not_to have_no_field('Html5 Tel', type: 'tel')
|
119
|
+
expect(@session).not_to have_no_field('Description', type: 'textarea')
|
120
|
+
expect(@session).not_to have_no_field('Languages', type: 'select')
|
104
121
|
end
|
105
122
|
|
106
123
|
it "should be true if the given field is not on the page" do
|
107
|
-
expect(@session).to have_no_field('First Name', :
|
108
|
-
expect(@session).to have_no_field('Html5 Email', :
|
109
|
-
expect(@session).to have_no_field('Description', :
|
110
|
-
expect(@session).to have_no_field('Description', :
|
111
|
-
expect(@session).to have_no_field('Languages', :
|
124
|
+
expect(@session).to have_no_field('First Name', type: 'textarea')
|
125
|
+
expect(@session).to have_no_field('Html5 Email', type: 'tel')
|
126
|
+
expect(@session).to have_no_field('Description', type: '')
|
127
|
+
expect(@session).to have_no_field('Description', type: 'email')
|
128
|
+
expect(@session).to have_no_field('Languages', type: 'textarea')
|
112
129
|
end
|
113
130
|
end
|
114
131
|
end
|
@@ -121,8 +138,8 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
121
138
|
expect(@session).to have_checked_field('Hamster')
|
122
139
|
end
|
123
140
|
|
124
|
-
it "should be true for disabled checkboxes if :
|
125
|
-
expect(@session).to have_checked_field('Disabled Checkbox', :
|
141
|
+
it "should be true for disabled checkboxes if disabled: true" do
|
142
|
+
expect(@session).to have_checked_field('Disabled Checkbox', disabled: true)
|
126
143
|
end
|
127
144
|
|
128
145
|
it "should be false if an unchecked field is on the page" do
|
@@ -138,8 +155,16 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
138
155
|
expect(@session).not_to have_checked_field('Disabled Checkbox')
|
139
156
|
end
|
140
157
|
|
141
|
-
it "should be false for disabled checkboxes if :
|
142
|
-
expect(@session).not_to have_checked_field('Disabled Checkbox', :
|
158
|
+
it "should be false for disabled checkboxes if disabled: false" do
|
159
|
+
expect(@session).not_to have_checked_field('Disabled Checkbox', disabled: false)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be true for disabled checkboxes if disabled: :all" do
|
163
|
+
expect(@session).to have_checked_field('Disabled Checkbox', disabled: :all)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should be true for enabled checkboxes if disabled: :all" do
|
167
|
+
expect(@session).to have_checked_field('gender_female', disabled: :all)
|
143
168
|
end
|
144
169
|
|
145
170
|
it "should be true after an unchecked checkbox is checked" do
|
@@ -171,8 +196,8 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
171
196
|
expect(@session).not_to have_no_checked_field('Hamster')
|
172
197
|
end
|
173
198
|
|
174
|
-
it "should be false for disabled checkboxes if :
|
175
|
-
expect(@session).not_to have_no_checked_field('Disabled Checkbox', :
|
199
|
+
it "should be false for disabled checkboxes if disabled: true" do
|
200
|
+
expect(@session).not_to have_no_checked_field('Disabled Checkbox', disabled: true)
|
176
201
|
end
|
177
202
|
|
178
203
|
it "should be true if an unchecked field is on the page" do
|
@@ -188,8 +213,8 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
188
213
|
expect(@session).to have_no_checked_field('Disabled Checkbox')
|
189
214
|
end
|
190
215
|
|
191
|
-
it "should be true for disabled checkboxes if :
|
192
|
-
expect(@session).to have_no_checked_field('Disabled Checkbox', :
|
216
|
+
it "should be true for disabled checkboxes if disabled: false" do
|
217
|
+
expect(@session).to have_no_checked_field('Disabled Checkbox', disabled: false)
|
193
218
|
end
|
194
219
|
end
|
195
220
|
|
@@ -206,8 +231,8 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
206
231
|
expect(@session).to have_unchecked_field('Male')
|
207
232
|
end
|
208
233
|
|
209
|
-
it "should be true for disabled unchecked fields if :
|
210
|
-
expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', :
|
234
|
+
it "should be true for disabled unchecked fields if disabled: true" do
|
235
|
+
expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
211
236
|
end
|
212
237
|
|
213
238
|
it "should be false if no field is on the page" do
|
@@ -218,8 +243,8 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
218
243
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
|
219
244
|
end
|
220
245
|
|
221
|
-
it "should be false for disabled unchecked fields if :
|
222
|
-
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', :
|
246
|
+
it "should be false for disabled unchecked fields if disabled: false" do
|
247
|
+
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
223
248
|
end
|
224
249
|
|
225
250
|
it "should be false after an unchecked checkbox is checked" do
|
@@ -241,6 +266,11 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
241
266
|
@session.choose('gender_male')
|
242
267
|
expect(@session).to have_unchecked_field('gender_female')
|
243
268
|
end
|
269
|
+
|
270
|
+
it "should support locator-less usage" do
|
271
|
+
expect(@session.has_unchecked_field?(disabled: true, id: "form_disabled_unchecked_checkbox"))
|
272
|
+
expect(@session).to have_unchecked_field(disabled: true, id: "form_disabled_unchecked_checkbox" )
|
273
|
+
end
|
244
274
|
end
|
245
275
|
|
246
276
|
Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
@@ -256,8 +286,8 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
256
286
|
expect(@session).not_to have_no_unchecked_field('Male')
|
257
287
|
end
|
258
288
|
|
259
|
-
it "should be false for disabled unchecked fields if :
|
260
|
-
expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', :
|
289
|
+
it "should be false for disabled unchecked fields if disabled: true" do
|
290
|
+
expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
261
291
|
end
|
262
292
|
|
263
293
|
it "should be true if no field is on the page" do
|
@@ -268,7 +298,12 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
268
298
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
|
269
299
|
end
|
270
300
|
|
271
|
-
it "should be true for disabled unchecked fields if :
|
272
|
-
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', :
|
301
|
+
it "should be true for disabled unchecked fields if disabled: false" do
|
302
|
+
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
303
|
+
end
|
304
|
+
|
305
|
+
it "should support locator-less usage" do
|
306
|
+
expect(@session.has_no_unchecked_field?(disabled: false, id: "form_disabled_unchecked_checkbox")).to eq true
|
307
|
+
expect(@session).to have_no_unchecked_field(disabled: false, id: "form_disabled_unchecked_checkbox" )
|
273
308
|
end
|
274
309
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
Capybara::SpecHelper.spec '#has_link?' do
|
2
3
|
before do
|
3
4
|
@session.visit('/with_html')
|
@@ -6,15 +7,15 @@ Capybara::SpecHelper.spec '#has_link?' do
|
|
6
7
|
it "should be true if the given link is on the page" do
|
7
8
|
expect(@session).to have_link('foo')
|
8
9
|
expect(@session).to have_link('awesome title')
|
9
|
-
expect(@session).to have_link('A link', :
|
10
|
-
expect(@session).to have_link(:'A link', :
|
11
|
-
expect(@session).to have_link('A link', :
|
10
|
+
expect(@session).to have_link('A link', href: '/with_simple_html')
|
11
|
+
expect(@session).to have_link(:'A link', href: :'/with_simple_html')
|
12
|
+
expect(@session).to have_link('A link', href: /\/with_simple_html/)
|
12
13
|
end
|
13
14
|
|
14
15
|
it "should be false if the given link is not on the page" do
|
15
16
|
expect(@session).not_to have_link('monkey')
|
16
|
-
expect(@session).not_to have_link('A link', :
|
17
|
-
expect(@session).not_to have_link('A link', :
|
17
|
+
expect(@session).not_to have_link('A link', href: '/nonexistent-href')
|
18
|
+
expect(@session).not_to have_link('A link', href: /nonexistent/)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -26,12 +27,12 @@ Capybara::SpecHelper.spec '#has_no_link?' do
|
|
26
27
|
it "should be false if the given link is on the page" do
|
27
28
|
expect(@session).not_to have_no_link('foo')
|
28
29
|
expect(@session).not_to have_no_link('awesome title')
|
29
|
-
expect(@session).not_to have_no_link('A link', :
|
30
|
+
expect(@session).not_to have_no_link('A link', href: '/with_simple_html')
|
30
31
|
end
|
31
32
|
|
32
33
|
it "should be true if the given link is not on the page" do
|
33
34
|
expect(@session).to have_no_link('monkey')
|
34
|
-
expect(@session).to have_no_link('A link', :
|
35
|
-
expect(@session).to have_no_link('A link', :
|
35
|
+
expect(@session).to have_no_link('A link', href: '/nonexistent-href')
|
36
|
+
expect(@session).to have_no_link('A link', href: /\/nonexistent-href/)
|
36
37
|
end
|
37
38
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
2
|
+
before do
|
3
|
+
@session.visit('/with_html')
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should be false if any of the given locators are on the page" do
|
7
|
+
expect {
|
8
|
+
expect(@session).to have_none_of_selectors(:xpath, "//p", "//a")
|
9
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
10
|
+
expect {
|
11
|
+
expect(@session).to have_none_of_selectors(:css, "p a#foo")
|
12
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be true if none of the given locators are on the page" do
|
16
|
+
expect(@session).to have_none_of_selectors(:xpath, "//abbr", "//td" )
|
17
|
+
expect(@session).to have_none_of_selectors(:css, "p a#doesnotexist", "abbr")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should use default selector" do
|
21
|
+
Capybara.default_selector = :css
|
22
|
+
expect(@session).to have_none_of_selectors("p a#doesnotexist", "abbr")
|
23
|
+
expect {
|
24
|
+
expect(@session).to have_none_of_selectors("abbr", "p a#foo")
|
25
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
26
|
+
end
|
27
|
+
|
28
|
+
context "should respect scopes" do
|
29
|
+
it "when used with `within`" do
|
30
|
+
@session.within "//p[@id='first']" do
|
31
|
+
expect {
|
32
|
+
expect(@session).to have_none_of_selectors(".//a[@id='foo']")
|
33
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
34
|
+
expect(@session).to have_none_of_selectors(".//a[@id='red']")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "when called on an element" do
|
39
|
+
el = @session.find "//p[@id='first']"
|
40
|
+
expect {
|
41
|
+
expect(el).to have_none_of_selectors(".//a[@id='foo']")
|
42
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
43
|
+
expect(el).to have_none_of_selectors(".//a[@id='red']")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with options" do
|
48
|
+
it "should apply the options to all locators" do
|
49
|
+
expect {
|
50
|
+
expect(@session).to have_none_of_selectors("//p//a", text: "Redirect")
|
51
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
52
|
+
expect(@session).to have_none_of_selectors("//p", text: "Doesnotexist")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should discard all matches where the given regexp is matched" do
|
56
|
+
expect {
|
57
|
+
expect(@session).to have_none_of_selectors("//p//a", text: /re[dab]i/i, count: 1)
|
58
|
+
}.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
59
|
+
expect(@session).to have_none_of_selectors("//p//a", text: /Red$/)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "with wait", requires: [:js] do
|
64
|
+
it "should not find elements if they appear after given wait duration" do
|
65
|
+
@session.visit('/with_js')
|
66
|
+
@session.click_link('Click me')
|
67
|
+
expect(@session).to have_none_of_selectors(:css, "#new_field", "a#has-been-clicked", wait: 0.1)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "cannot be negated" do
|
72
|
+
expect {
|
73
|
+
expect(@session).not_to have_none_of_selectors(:css, "p a#foo", "h2#h2one", "h2#h2two")
|
74
|
+
}.to raise_error ArgumentError
|
75
|
+
end
|
76
|
+
end
|