capybara 3.3.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +16 -0
- data/README.md +5 -7
- data/lib/capybara.rb +7 -6
- data/lib/capybara/config.rb +1 -1
- data/lib/capybara/dsl.rb +2 -2
- data/lib/capybara/helpers.rb +3 -3
- data/lib/capybara/minitest/spec.rb +3 -3
- data/lib/capybara/node/actions.rb +18 -18
- data/lib/capybara/node/base.rb +1 -1
- data/lib/capybara/node/element.rb +2 -2
- data/lib/capybara/node/finders.rb +6 -6
- data/lib/capybara/node/matchers.rb +5 -5
- data/lib/capybara/node/simple.rb +2 -2
- data/lib/capybara/queries/ancestor_query.rb +1 -1
- data/lib/capybara/queries/base_query.rb +12 -11
- data/lib/capybara/queries/current_path_query.rb +1 -1
- data/lib/capybara/queries/selector_query.rb +39 -15
- data/lib/capybara/queries/sibling_query.rb +1 -1
- data/lib/capybara/queries/text_query.rb +1 -1
- data/lib/capybara/rack_test/browser.rb +7 -7
- data/lib/capybara/rack_test/driver.rb +1 -1
- data/lib/capybara/rack_test/form.rb +7 -7
- data/lib/capybara/rack_test/node.rb +16 -16
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/result.rb +8 -4
- data/lib/capybara/rspec/features.rb +4 -4
- data/lib/capybara/rspec/matchers.rb +6 -6
- data/lib/capybara/selector.rb +106 -90
- data/lib/capybara/selector/css.rb +4 -4
- data/lib/capybara/selector/filter_set.rb +52 -8
- data/lib/capybara/selector/selector.rb +39 -15
- data/lib/capybara/selenium/driver.rb +10 -10
- data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
- data/lib/capybara/selenium/node.rb +9 -10
- data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
- data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
- data/lib/capybara/server.rb +3 -3
- data/lib/capybara/server/animation_disabler.rb +1 -1
- data/lib/capybara/server/middleware.rb +1 -1
- data/lib/capybara/session.rb +23 -19
- data/lib/capybara/session/config.rb +18 -3
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
- data/lib/capybara/spec/session/all_spec.rb +33 -32
- data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
- data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
- data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
- data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
- data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
- data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
- data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
- data/lib/capybara/spec/session/body_spec.rb +6 -6
- data/lib/capybara/spec/session/check_spec.rb +52 -47
- data/lib/capybara/spec/session/choose_spec.rb +32 -32
- data/lib/capybara/spec/session/click_button_spec.rb +103 -103
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
- data/lib/capybara/spec/session/click_link_spec.rb +49 -48
- data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
- data/lib/capybara/spec/session/current_url_spec.rb +26 -27
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
- data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
- data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
- data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
- data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
- data/lib/capybara/spec/session/find_button_spec.rb +23 -23
- data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
- data/lib/capybara/spec/session/find_field_spec.rb +32 -30
- data/lib/capybara/spec/session/find_link_spec.rb +21 -21
- data/lib/capybara/spec/session/find_spec.rb +153 -135
- data/lib/capybara/spec/session/first_spec.rb +41 -41
- data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
- data/lib/capybara/spec/session/go_back_spec.rb +1 -1
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/has_button_spec.rb +13 -13
- data/lib/capybara/spec/session/has_css_spec.rb +133 -131
- data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
- data/lib/capybara/spec/session/has_field_spec.rb +58 -58
- data/lib/capybara/spec/session/has_link_spec.rb +4 -4
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
- data/lib/capybara/spec/session/has_select_spec.rb +43 -43
- data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
- data/lib/capybara/spec/session/has_style_spec.rb +3 -3
- data/lib/capybara/spec/session/has_table_spec.rb +4 -4
- data/lib/capybara/spec/session/has_text_spec.rb +53 -52
- data/lib/capybara/spec/session/has_title_spec.rb +14 -14
- data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
- data/lib/capybara/spec/session/headers_spec.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +6 -6
- data/lib/capybara/spec/session/node_spec.rb +129 -123
- data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
- data/lib/capybara/spec/session/refresh_spec.rb +4 -7
- data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
- data/lib/capybara/spec/session/response_code_spec.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
- data/lib/capybara/spec/session/save_page_spec.rb +37 -37
- data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
- data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
- data/lib/capybara/spec/session/select_spec.rb +81 -81
- data/lib/capybara/spec/session/selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/sibling_spec.rb +9 -9
- data/lib/capybara/spec/session/text_spec.rb +23 -23
- data/lib/capybara/spec/session/title_spec.rb +5 -5
- data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
- data/lib/capybara/spec/session/unselect_spec.rb +37 -37
- data/lib/capybara/spec/session/visit_spec.rb +48 -49
- data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
- data/lib/capybara/spec/session/window/window_spec.rb +4 -4
- data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
- data/lib/capybara/spec/session/within_spec.rb +41 -41
- data/lib/capybara/spec/spec_helper.rb +11 -9
- data/lib/capybara/spec/test_app.rb +18 -17
- data/lib/capybara/spec/views/form.erb +29 -31
- data/lib/capybara/spec/views/with_html.erb +2 -2
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +23 -23
- data/spec/capybara_spec.rb +20 -20
- data/spec/css_splitter_spec.rb +7 -7
- data/spec/dsl_spec.rb +37 -32
- data/spec/filter_set_spec.rb +4 -4
- 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 +4 -4
- data/spec/minitest_spec_spec.rb +23 -23
- data/spec/per_session_config_spec.rb +5 -5
- data/spec/rack_test_spec.rb +44 -44
- data/spec/result_spec.rb +14 -14
- data/spec/rspec/features_spec.rb +13 -13
- data/spec/rspec/scenarios_spec.rb +4 -4
- data/spec/rspec/shared_spec_matchers.rb +282 -281
- data/spec/rspec/views_spec.rb +3 -3
- data/spec/rspec_matchers_spec.rb +10 -10
- data/spec/rspec_spec.rb +29 -29
- data/spec/selector_spec.rb +64 -64
- data/spec/selenium_spec_chrome.rb +14 -22
- data/spec/selenium_spec_chrome_remote.rb +28 -8
- data/spec/selenium_spec_edge.rb +9 -4
- data/spec/selenium_spec_firefox_remote.rb +87 -0
- data/spec/selenium_spec_ie.rb +9 -4
- data/spec/selenium_spec_marionette.rb +42 -18
- data/spec/server_spec.rb +29 -27
- data/spec/session_spec.rb +17 -17
- data/spec/shared_selenium_session.rb +70 -52
- data/spec/spec_helper.rb +1 -1
- metadata +4 -2
@@ -3,19 +3,19 @@
|
|
3
3
|
Capybara::SpecHelper.spec '#has_field' do
|
4
4
|
before { @session.visit('/form') }
|
5
5
|
|
6
|
-
it
|
6
|
+
it 'should be true if the field is on the page' do
|
7
7
|
expect(@session).to have_field('Dog')
|
8
8
|
expect(@session).to have_field('form_description')
|
9
9
|
expect(@session).to have_field('Region')
|
10
10
|
expect(@session).to have_field(:Region)
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'should be false if the field is not on the page' do
|
14
14
|
expect(@session).not_to have_field('Monkey')
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'with value' do
|
18
|
-
it
|
18
|
+
it 'should be true if a field with the given value is on the page' do
|
19
19
|
expect(@session).to have_field('First Name', with: 'John')
|
20
20
|
expect(@session).to have_field('First Name', with: /^Joh/)
|
21
21
|
expect(@session).to have_field('Phone', with: '+1 555 7021')
|
@@ -23,20 +23,20 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
23
23
|
expect(@session).to have_field('Description', with: 'Descriptive text goes here')
|
24
24
|
end
|
25
25
|
|
26
|
-
it
|
26
|
+
it 'should be false if the given field is not on the page' do
|
27
27
|
expect(@session).not_to have_field('First Name', with: 'Peter')
|
28
28
|
expect(@session).not_to have_field('First Name', with: /eter$/)
|
29
29
|
expect(@session).not_to have_field('Wrong Name', with: 'John')
|
30
30
|
expect(@session).not_to have_field('Description', with: 'Monkey')
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should be true after the field has been filled in with the given value' do
|
34
34
|
@session.fill_in('First Name', with: 'Jonas')
|
35
35
|
expect(@session).to have_field('First Name', with: 'Jonas')
|
36
36
|
expect(@session).to have_field('First Name', with: /ona/)
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'should be false after the field has been filled in with a different value' do
|
40
40
|
@session.fill_in('First Name', with: 'Jonas')
|
41
41
|
expect(@session).not_to have_field('First Name', with: 'John')
|
42
42
|
expect(@session).not_to have_field('First Name', with: /John|Paul|George|Ringo/)
|
@@ -44,7 +44,7 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'with type' do
|
47
|
-
it
|
47
|
+
it 'should be true if a field with the given type is on the page' do
|
48
48
|
expect(@session).to have_field('First Name', type: 'text')
|
49
49
|
expect(@session).to have_field('Html5 Email', type: 'email')
|
50
50
|
expect(@session).to have_field('Html5 Multiple Email', type: 'email')
|
@@ -53,7 +53,7 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
53
53
|
expect(@session).to have_field('Languages', type: 'select')
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'should be false if the given field is not on the page' do
|
57
57
|
expect(@session).not_to have_field('First Name', type: 'textarea')
|
58
58
|
expect(@session).not_to have_field('Html5 Email', type: 'tel')
|
59
59
|
expect(@session).not_to have_field('Html5 Multiple Email', type: 'tel')
|
@@ -64,11 +64,11 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
64
64
|
end
|
65
65
|
|
66
66
|
context 'with multiple' do
|
67
|
-
it
|
67
|
+
it 'should be true if a field with the multiple attribute is on the page' do
|
68
68
|
expect(@session).to have_field('Html5 Multiple Email', multiple: true)
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
71
|
+
it 'should be false if a field without the multiple attribute is not on the page' do
|
72
72
|
expect(@session).not_to have_field('Html5 Multiple Email', multiple: false)
|
73
73
|
end
|
74
74
|
end
|
@@ -77,43 +77,43 @@ end
|
|
77
77
|
Capybara::SpecHelper.spec '#has_no_field' do
|
78
78
|
before { @session.visit('/form') }
|
79
79
|
|
80
|
-
it
|
80
|
+
it 'should be false if the field is on the page' do
|
81
81
|
expect(@session).not_to have_no_field('Dog')
|
82
82
|
expect(@session).not_to have_no_field('form_description')
|
83
83
|
expect(@session).not_to have_no_field('Region')
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
86
|
+
it 'should be true if the field is not on the page' do
|
87
87
|
expect(@session).to have_no_field('Monkey')
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'with value' do
|
91
|
-
it
|
91
|
+
it 'should be false if a field with the given value is on the page' do
|
92
92
|
expect(@session).not_to have_no_field('First Name', with: 'John')
|
93
93
|
expect(@session).not_to have_no_field('Phone', with: '+1 555 7021')
|
94
94
|
expect(@session).not_to have_no_field('Street', with: 'Sesame street 66')
|
95
95
|
expect(@session).not_to have_no_field('Description', with: 'Descriptive text goes here')
|
96
96
|
end
|
97
97
|
|
98
|
-
it
|
98
|
+
it 'should be true if the given field is not on the page' do
|
99
99
|
expect(@session).to have_no_field('First Name', with: 'Peter')
|
100
100
|
expect(@session).to have_no_field('Wrong Name', with: 'John')
|
101
101
|
expect(@session).to have_no_field('Description', with: 'Monkey')
|
102
102
|
end
|
103
103
|
|
104
|
-
it
|
104
|
+
it 'should be false after the field has been filled in with the given value' do
|
105
105
|
@session.fill_in('First Name', with: 'Jonas')
|
106
106
|
expect(@session).not_to have_no_field('First Name', with: 'Jonas')
|
107
107
|
end
|
108
108
|
|
109
|
-
it
|
109
|
+
it 'should be true after the field has been filled in with a different value' do
|
110
110
|
@session.fill_in('First Name', with: 'Jonas')
|
111
111
|
expect(@session).to have_no_field('First Name', with: 'John')
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
context 'with type' do
|
116
|
-
it
|
116
|
+
it 'should be false if a field with the given type is on the page' do
|
117
117
|
expect(@session).not_to have_no_field('First Name', type: 'text')
|
118
118
|
expect(@session).not_to have_no_field('Html5 Email', type: 'email')
|
119
119
|
expect(@session).not_to have_no_field('Html5 Tel', type: 'tel')
|
@@ -121,7 +121,7 @@ Capybara::SpecHelper.spec '#has_no_field' do
|
|
121
121
|
expect(@session).not_to have_no_field('Languages', type: 'select')
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
124
|
+
it 'should be true if the given field is not on the page' do
|
125
125
|
expect(@session).to have_no_field('First Name', type: 'textarea')
|
126
126
|
expect(@session).to have_no_field('Html5 Email', type: 'tel')
|
127
127
|
expect(@session).to have_no_field('Description', type: '')
|
@@ -134,56 +134,56 @@ end
|
|
134
134
|
Capybara::SpecHelper.spec '#has_checked_field?' do
|
135
135
|
before { @session.visit('/form') }
|
136
136
|
|
137
|
-
it
|
137
|
+
it 'should be true if a checked field is on the page' do
|
138
138
|
expect(@session).to have_checked_field('gender_female')
|
139
139
|
expect(@session).to have_checked_field('Hamster')
|
140
140
|
end
|
141
141
|
|
142
|
-
it
|
142
|
+
it 'should be true for disabled checkboxes if disabled: true' do
|
143
143
|
expect(@session).to have_checked_field('Disabled Checkbox', disabled: true)
|
144
144
|
end
|
145
145
|
|
146
|
-
it
|
146
|
+
it 'should be false if an unchecked field is on the page' do
|
147
147
|
expect(@session).not_to have_checked_field('form_pets_cat')
|
148
148
|
expect(@session).not_to have_checked_field('Male')
|
149
149
|
end
|
150
150
|
|
151
|
-
it
|
151
|
+
it 'should be false if no field is on the page' do
|
152
152
|
expect(@session).not_to have_checked_field('Does Not Exist')
|
153
153
|
end
|
154
154
|
|
155
|
-
it
|
155
|
+
it 'should be false for disabled checkboxes by default' do
|
156
156
|
expect(@session).not_to have_checked_field('Disabled Checkbox')
|
157
157
|
end
|
158
158
|
|
159
|
-
it
|
159
|
+
it 'should be false for disabled checkboxes if disabled: false' do
|
160
160
|
expect(@session).not_to have_checked_field('Disabled Checkbox', disabled: false)
|
161
161
|
end
|
162
162
|
|
163
|
-
it
|
163
|
+
it 'should be true for disabled checkboxes if disabled: :all' do
|
164
164
|
expect(@session).to have_checked_field('Disabled Checkbox', disabled: :all)
|
165
165
|
end
|
166
166
|
|
167
|
-
it
|
167
|
+
it 'should be true for enabled checkboxes if disabled: :all' do
|
168
168
|
expect(@session).to have_checked_field('gender_female', disabled: :all)
|
169
169
|
end
|
170
170
|
|
171
|
-
it
|
171
|
+
it 'should be true after an unchecked checkbox is checked' do
|
172
172
|
@session.check('form_pets_cat')
|
173
173
|
expect(@session).to have_checked_field('form_pets_cat')
|
174
174
|
end
|
175
175
|
|
176
|
-
it
|
176
|
+
it 'should be false after a checked checkbox is unchecked' do
|
177
177
|
@session.uncheck('form_pets_dog')
|
178
178
|
expect(@session).not_to have_checked_field('form_pets_dog')
|
179
179
|
end
|
180
180
|
|
181
|
-
it
|
181
|
+
it 'should be true after an unchecked radio button is chosen' do
|
182
182
|
@session.choose('gender_male')
|
183
183
|
expect(@session).to have_checked_field('gender_male')
|
184
184
|
end
|
185
185
|
|
186
|
-
it
|
186
|
+
it 'should be false after another radio button in the group is chosen' do
|
187
187
|
@session.choose('gender_male')
|
188
188
|
expect(@session).not_to have_checked_field('gender_female')
|
189
189
|
end
|
@@ -192,29 +192,29 @@ end
|
|
192
192
|
Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
193
193
|
before { @session.visit('/form') }
|
194
194
|
|
195
|
-
it
|
195
|
+
it 'should be false if a checked field is on the page' do
|
196
196
|
expect(@session).not_to have_no_checked_field('gender_female')
|
197
197
|
expect(@session).not_to have_no_checked_field('Hamster')
|
198
198
|
end
|
199
199
|
|
200
|
-
it
|
200
|
+
it 'should be false for disabled checkboxes if disabled: true' do
|
201
201
|
expect(@session).not_to have_no_checked_field('Disabled Checkbox', disabled: true)
|
202
202
|
end
|
203
203
|
|
204
|
-
it
|
204
|
+
it 'should be true if an unchecked field is on the page' do
|
205
205
|
expect(@session).to have_no_checked_field('form_pets_cat')
|
206
206
|
expect(@session).to have_no_checked_field('Male')
|
207
207
|
end
|
208
208
|
|
209
|
-
it
|
209
|
+
it 'should be true if no field is on the page' do
|
210
210
|
expect(@session).to have_no_checked_field('Does Not Exist')
|
211
211
|
end
|
212
212
|
|
213
|
-
it
|
213
|
+
it 'should be true for disabled checkboxes by default' do
|
214
214
|
expect(@session).to have_no_checked_field('Disabled Checkbox')
|
215
215
|
end
|
216
216
|
|
217
|
-
it
|
217
|
+
it 'should be true for disabled checkboxes if disabled: false' do
|
218
218
|
expect(@session).to have_no_checked_field('Disabled Checkbox', disabled: false)
|
219
219
|
end
|
220
220
|
end
|
@@ -222,89 +222,89 @@ end
|
|
222
222
|
Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
223
223
|
before { @session.visit('/form') }
|
224
224
|
|
225
|
-
it
|
225
|
+
it 'should be false if a checked field is on the page' do
|
226
226
|
expect(@session).not_to have_unchecked_field('gender_female')
|
227
227
|
expect(@session).not_to have_unchecked_field('Hamster')
|
228
228
|
end
|
229
229
|
|
230
|
-
it
|
230
|
+
it 'should be true if an unchecked field is on the page' do
|
231
231
|
expect(@session).to have_unchecked_field('form_pets_cat')
|
232
232
|
expect(@session).to have_unchecked_field('Male')
|
233
233
|
end
|
234
234
|
|
235
|
-
it
|
235
|
+
it 'should be true for disabled unchecked fields if disabled: true' do
|
236
236
|
expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
237
237
|
end
|
238
238
|
|
239
|
-
it
|
239
|
+
it 'should be false if no field is on the page' do
|
240
240
|
expect(@session).not_to have_unchecked_field('Does Not Exist')
|
241
241
|
end
|
242
242
|
|
243
|
-
it
|
243
|
+
it 'should be false for disabled unchecked fields by default' do
|
244
244
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
|
245
245
|
end
|
246
246
|
|
247
|
-
it
|
247
|
+
it 'should be false for disabled unchecked fields if disabled: false' do
|
248
248
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
249
249
|
end
|
250
250
|
|
251
|
-
it
|
251
|
+
it 'should be false after an unchecked checkbox is checked' do
|
252
252
|
@session.check('form_pets_cat')
|
253
253
|
expect(@session).not_to have_unchecked_field('form_pets_cat')
|
254
254
|
end
|
255
255
|
|
256
|
-
it
|
256
|
+
it 'should be true after a checked checkbox is unchecked' do
|
257
257
|
@session.uncheck('form_pets_dog')
|
258
258
|
expect(@session).to have_unchecked_field('form_pets_dog')
|
259
259
|
end
|
260
260
|
|
261
|
-
it
|
261
|
+
it 'should be false after an unchecked radio button is chosen' do
|
262
262
|
@session.choose('gender_male')
|
263
263
|
expect(@session).not_to have_unchecked_field('gender_male')
|
264
264
|
end
|
265
265
|
|
266
|
-
it
|
266
|
+
it 'should be true after another radio button in the group is chosen' do
|
267
267
|
@session.choose('gender_male')
|
268
268
|
expect(@session).to have_unchecked_field('gender_female')
|
269
269
|
end
|
270
270
|
|
271
|
-
it
|
272
|
-
expect(@session.has_unchecked_field?(disabled: true, id:
|
273
|
-
expect(@session).to have_unchecked_field(disabled: true, id:
|
271
|
+
it 'should support locator-less usage' do
|
272
|
+
expect(@session.has_unchecked_field?(disabled: true, id: 'form_disabled_unchecked_checkbox')).to be true
|
273
|
+
expect(@session).to have_unchecked_field(disabled: true, id: 'form_disabled_unchecked_checkbox')
|
274
274
|
end
|
275
275
|
end
|
276
276
|
|
277
277
|
Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
278
278
|
before { @session.visit('/form') }
|
279
279
|
|
280
|
-
it
|
280
|
+
it 'should be true if a checked field is on the page' do
|
281
281
|
expect(@session).to have_no_unchecked_field('gender_female')
|
282
282
|
expect(@session).to have_no_unchecked_field('Hamster')
|
283
283
|
end
|
284
284
|
|
285
|
-
it
|
285
|
+
it 'should be false if an unchecked field is on the page' do
|
286
286
|
expect(@session).not_to have_no_unchecked_field('form_pets_cat')
|
287
287
|
expect(@session).not_to have_no_unchecked_field('Male')
|
288
288
|
end
|
289
289
|
|
290
|
-
it
|
290
|
+
it 'should be false for disabled unchecked fields if disabled: true' do
|
291
291
|
expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: true)
|
292
292
|
end
|
293
293
|
|
294
|
-
it
|
294
|
+
it 'should be true if no field is on the page' do
|
295
295
|
expect(@session).to have_no_unchecked_field('Does Not Exist')
|
296
296
|
end
|
297
297
|
|
298
|
-
it
|
298
|
+
it 'should be true for disabled unchecked fields by default' do
|
299
299
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
|
300
300
|
end
|
301
301
|
|
302
|
-
it
|
302
|
+
it 'should be true for disabled unchecked fields if disabled: false' do
|
303
303
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', disabled: false)
|
304
304
|
end
|
305
305
|
|
306
|
-
it
|
307
|
-
expect(@session.has_no_unchecked_field?(disabled: false, id:
|
308
|
-
expect(@session).to have_no_unchecked_field(disabled: false, id:
|
306
|
+
it 'should support locator-less usage' do
|
307
|
+
expect(@session.has_no_unchecked_field?(disabled: false, id: 'form_disabled_unchecked_checkbox')).to eq true
|
308
|
+
expect(@session).to have_no_unchecked_field(disabled: false, id: 'form_disabled_unchecked_checkbox')
|
309
309
|
end
|
310
310
|
end
|
@@ -5,7 +5,7 @@ Capybara::SpecHelper.spec '#has_link?' do
|
|
5
5
|
@session.visit('/with_html')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should be true if the given link is on the page' do
|
9
9
|
expect(@session).to have_link('foo')
|
10
10
|
expect(@session).to have_link('awesome title')
|
11
11
|
expect(@session).to have_link('A link', href: '/with_simple_html')
|
@@ -13,7 +13,7 @@ Capybara::SpecHelper.spec '#has_link?' do
|
|
13
13
|
expect(@session).to have_link('A link', href: %r{/with_simple_html})
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should be false if the given link is not on the page' do
|
17
17
|
expect(@session).not_to have_link('monkey')
|
18
18
|
expect(@session).not_to have_link('A link', href: '/nonexistent-href')
|
19
19
|
expect(@session).not_to have_link('A link', href: /nonexistent/)
|
@@ -25,13 +25,13 @@ Capybara::SpecHelper.spec '#has_no_link?' do
|
|
25
25
|
@session.visit('/with_html')
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'should be false if the given link is on the page' do
|
29
29
|
expect(@session).not_to have_no_link('foo')
|
30
30
|
expect(@session).not_to have_no_link('awesome title')
|
31
31
|
expect(@session).not_to have_no_link('A link', href: '/with_simple_html')
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'should be true if the given link is not on the page' do
|
35
35
|
expect(@session).to have_no_link('monkey')
|
36
36
|
expect(@session).to have_no_link('A link', href: '/nonexistent-href')
|
37
37
|
expect(@session).to have_no_link('A link', href: %r{/nonexistent-href})
|
@@ -5,30 +5,30 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
|
5
5
|
@session.visit('/with_html')
|
6
6
|
end
|
7
7
|
|
8
|
-
it
|
8
|
+
it 'should be false if any of the given locators are on the page' do
|
9
9
|
expect do
|
10
|
-
expect(@session).to have_none_of_selectors(:xpath,
|
10
|
+
expect(@session).to have_none_of_selectors(:xpath, '//p', '//a')
|
11
11
|
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
12
12
|
expect do
|
13
|
-
expect(@session).to have_none_of_selectors(:css,
|
13
|
+
expect(@session).to have_none_of_selectors(:css, 'p a#foo')
|
14
14
|
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
18
|
-
expect(@session).to have_none_of_selectors(:xpath,
|
19
|
-
expect(@session).to have_none_of_selectors(:css,
|
17
|
+
it 'should be true if none of the given locators are on the page' do
|
18
|
+
expect(@session).to have_none_of_selectors(:xpath, '//abbr', '//td')
|
19
|
+
expect(@session).to have_none_of_selectors(:css, 'p a#doesnotexist', 'abbr')
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'should use default selector' do
|
23
23
|
Capybara.default_selector = :css
|
24
|
-
expect(@session).to have_none_of_selectors(
|
24
|
+
expect(@session).to have_none_of_selectors('p a#doesnotexist', 'abbr')
|
25
25
|
expect do
|
26
|
-
expect(@session).to have_none_of_selectors(
|
26
|
+
expect(@session).to have_none_of_selectors('abbr', 'p a#foo')
|
27
27
|
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
28
28
|
end
|
29
29
|
|
30
|
-
context
|
31
|
-
it
|
30
|
+
context 'should respect scopes' do
|
31
|
+
it 'when used with `within`' do
|
32
32
|
@session.within "//p[@id='first']" do
|
33
33
|
expect do
|
34
34
|
expect(@session).to have_none_of_selectors(".//a[@id='foo']")
|
@@ -37,7 +37,7 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'when called on an element' do
|
41
41
|
el = @session.find "//p[@id='first']"
|
42
42
|
expect do
|
43
43
|
expect(el).to have_none_of_selectors(".//a[@id='foo']")
|
@@ -46,33 +46,33 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
context
|
50
|
-
it
|
49
|
+
context 'with options' do
|
50
|
+
it 'should apply the options to all locators' do
|
51
51
|
expect do
|
52
|
-
expect(@session).to have_none_of_selectors(
|
52
|
+
expect(@session).to have_none_of_selectors('//p//a', text: 'Redirect')
|
53
53
|
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
54
|
-
expect(@session).to have_none_of_selectors(
|
54
|
+
expect(@session).to have_none_of_selectors('//p', text: 'Doesnotexist')
|
55
55
|
end
|
56
56
|
|
57
|
-
it
|
57
|
+
it 'should discard all matches where the given regexp is matched' do
|
58
58
|
expect do
|
59
|
-
expect(@session).to have_none_of_selectors(
|
59
|
+
expect(@session).to have_none_of_selectors('//p//a', text: /re[dab]i/i, count: 1)
|
60
60
|
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
61
|
-
expect(@session).to have_none_of_selectors(
|
61
|
+
expect(@session).to have_none_of_selectors('//p//a', text: /Red$/)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
context
|
66
|
-
it
|
65
|
+
context 'with wait', requires: [:js] do
|
66
|
+
it 'should not find elements if they appear after given wait duration' do
|
67
67
|
@session.visit('/with_js')
|
68
68
|
@session.click_link('Click me')
|
69
|
-
expect(@session).to have_none_of_selectors(:css,
|
69
|
+
expect(@session).to have_none_of_selectors(:css, '#new_field', 'a#has-been-clicked', wait: 0.1)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
it
|
73
|
+
it 'cannot be negated' do
|
74
74
|
expect do
|
75
|
-
expect(@session).not_to have_none_of_selectors(:css,
|
75
|
+
expect(@session).not_to have_none_of_selectors(:css, 'p a#foo', 'h2#h2one', 'h2#h2two')
|
76
76
|
end.to raise_error ArgumentError
|
77
77
|
end
|
78
78
|
end
|