capybara 2.18.0 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +26 -1
- data/README.md +12 -12
- data/lib/capybara.rb +13 -25
- data/lib/capybara/config.rb +11 -57
- data/lib/capybara/cucumber.rb +2 -3
- data/lib/capybara/driver/base.rb +5 -16
- data/lib/capybara/driver/node.rb +5 -4
- data/lib/capybara/dsl.rb +1 -0
- data/lib/capybara/helpers.rb +16 -28
- data/lib/capybara/minitest.rb +139 -138
- data/lib/capybara/minitest/spec.rb +15 -14
- data/lib/capybara/node/actions.rb +59 -81
- data/lib/capybara/node/base.rb +11 -18
- data/lib/capybara/node/document.rb +2 -2
- data/lib/capybara/node/document_matchers.rb +8 -8
- data/lib/capybara/node/element.rb +30 -40
- data/lib/capybara/node/finders.rb +62 -70
- data/lib/capybara/node/matchers.rb +48 -71
- data/lib/capybara/node/simple.rb +11 -17
- data/lib/capybara/queries/ancestor_query.rb +4 -6
- data/lib/capybara/queries/base_query.rb +18 -17
- data/lib/capybara/queries/current_path_query.rb +8 -24
- data/lib/capybara/queries/match_query.rb +3 -7
- data/lib/capybara/queries/selector_query.rb +92 -95
- data/lib/capybara/queries/sibling_query.rb +4 -4
- data/lib/capybara/queries/text_query.rb +37 -34
- data/lib/capybara/queries/title_query.rb +8 -11
- data/lib/capybara/rack_test/browser.rb +15 -18
- data/lib/capybara/rack_test/css_handlers.rb +6 -4
- data/lib/capybara/rack_test/driver.rb +6 -10
- data/lib/capybara/rack_test/form.rb +50 -40
- data/lib/capybara/rack_test/node.rb +70 -56
- data/lib/capybara/rails.rb +2 -6
- data/lib/capybara/result.rb +22 -22
- data/lib/capybara/rspec.rb +5 -10
- data/lib/capybara/rspec/compound.rb +5 -10
- data/lib/capybara/rspec/features.rb +17 -48
- data/lib/capybara/rspec/matcher_proxies.rb +31 -15
- data/lib/capybara/rspec/matchers.rb +70 -60
- data/lib/capybara/selector.rb +129 -117
- data/lib/capybara/selector/css.rb +6 -11
- data/lib/capybara/selector/filter.rb +1 -17
- data/lib/capybara/selector/filter_set.rb +17 -14
- data/lib/capybara/selector/filters/base.rb +7 -6
- data/lib/capybara/selector/filters/expression_filter.rb +6 -23
- data/lib/capybara/selector/filters/node_filter.rb +2 -12
- data/lib/capybara/selector/selector.rb +27 -33
- data/lib/capybara/selenium/driver.rb +113 -127
- data/lib/capybara/selenium/node.rb +148 -113
- data/lib/capybara/server.rb +3 -2
- data/lib/capybara/session.rb +137 -223
- data/lib/capybara/session/config.rb +47 -67
- data/lib/capybara/session/matchers.rb +8 -7
- data/lib/capybara/spec/public/test.js +26 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
- data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
- data/lib/capybara/spec/session/accept_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/all_spec.rb +31 -18
- data/lib/capybara/spec/session/ancestor_spec.rb +2 -4
- data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
- data/lib/capybara/spec/session/assert_current_path.rb +12 -11
- data/lib/capybara/spec/session/assert_selector.rb +1 -0
- data/lib/capybara/spec/session/assert_text.rb +18 -17
- data/lib/capybara/spec/session/assert_title.rb +1 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +14 -13
- data/lib/capybara/spec/session/body_spec.rb +1 -0
- data/lib/capybara/spec/session/check_spec.rb +7 -6
- data/lib/capybara/spec/session/choose_spec.rb +5 -4
- data/lib/capybara/spec/session/click_button_spec.rb +20 -28
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
- data/lib/capybara/spec/session/click_link_spec.rb +8 -7
- data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
- data/lib/capybara/spec/session/current_url_spec.rb +7 -6
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
- data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
- data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
- data/lib/capybara/spec/session/evaluate_async_script_spec.rb +3 -2
- data/lib/capybara/spec/session/evaluate_script_spec.rb +4 -3
- data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
- data/lib/capybara/spec/session/fill_in_spec.rb +6 -5
- data/lib/capybara/spec/session/find_button_spec.rb +4 -3
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
- data/lib/capybara/spec/session/find_field_spec.rb +8 -14
- data/lib/capybara/spec/session/find_link_spec.rb +6 -5
- data/lib/capybara/spec/session/find_spec.rb +37 -31
- data/lib/capybara/spec/session/first_spec.rb +60 -33
- data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
- data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
- data/lib/capybara/spec/session/go_back_spec.rb +1 -0
- data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
- data/lib/capybara/spec/session/has_all_selectors_spec.rb +15 -15
- data/lib/capybara/spec/session/has_button_spec.rb +2 -1
- data/lib/capybara/spec/session/has_css_spec.rb +3 -2
- data/lib/capybara/spec/session/has_current_path_spec.rb +12 -28
- data/lib/capybara/spec/session/has_field_spec.rb +4 -3
- data/lib/capybara/spec/session/has_link_spec.rb +1 -0
- data/lib/capybara/spec/session/has_none_selectors_spec.rb +17 -17
- data/lib/capybara/spec/session/has_select_spec.rb +30 -29
- data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
- data/lib/capybara/spec/session/has_table_spec.rb +2 -1
- data/lib/capybara/spec/session/has_text_spec.rb +6 -5
- data/lib/capybara/spec/session/has_title_spec.rb +1 -0
- data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
- data/lib/capybara/spec/session/headers.rb +2 -1
- data/lib/capybara/spec/session/html_spec.rb +1 -0
- data/lib/capybara/spec/session/node_spec.rb +91 -56
- data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
- data/lib/capybara/spec/session/refresh_spec.rb +4 -2
- data/lib/capybara/spec/session/reset_session_spec.rb +1 -0
- data/lib/capybara/spec/session/response_code.rb +1 -0
- 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 -11
- data/lib/capybara/spec/session/save_page_spec.rb +1 -17
- data/lib/capybara/spec/session/save_screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +20 -20
- data/lib/capybara/spec/session/selectors_spec.rb +2 -2
- data/lib/capybara/spec/session/sibling_spec.rb +1 -1
- data/lib/capybara/spec/session/text_spec.rb +1 -0
- data/lib/capybara/spec/session/title_spec.rb +1 -1
- data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
- data/lib/capybara/spec/session/unselect_spec.rb +6 -5
- data/lib/capybara/spec/session/visit_spec.rb +9 -3
- data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
- 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 +2 -1
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
- data/lib/capybara/spec/session/window/window_spec.rb +12 -12
- data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
- data/lib/capybara/spec/session/window/within_window_spec.rb +13 -68
- data/lib/capybara/spec/session/within_spec.rb +1 -0
- data/lib/capybara/spec/spec_helper.rb +26 -18
- data/lib/capybara/spec/test_app.rb +8 -9
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/spec/views/with_html.erb +3 -1
- data/lib/capybara/spec/views/within_frames.erb +4 -1
- data/lib/capybara/version.rb +2 -1
- data/lib/capybara/window.rb +6 -10
- data/spec/basic_node_spec.rb +1 -0
- data/spec/capybara_spec.rb +9 -32
- data/spec/dsl_spec.rb +5 -13
- data/spec/filter_set_spec.rb +5 -4
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
- data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
- data/spec/minitest_spec.rb +4 -3
- data/spec/minitest_spec_spec.rb +3 -2
- data/spec/per_session_config_spec.rb +9 -8
- data/spec/rack_test_spec.rb +21 -20
- data/spec/result_spec.rb +17 -16
- data/spec/rspec/features_spec.rb +17 -14
- data/spec/rspec/scenarios_spec.rb +5 -7
- data/spec/rspec/shared_spec_matchers.rb +96 -99
- data/spec/rspec/views_spec.rb +2 -1
- data/spec/rspec_matchers_spec.rb +19 -2
- data/spec/rspec_spec.rb +11 -15
- data/spec/selector_spec.rb +5 -6
- data/spec/selenium_spec_chrome.rb +7 -4
- data/spec/selenium_spec_marionette.rb +26 -12
- data/spec/server_spec.rb +33 -33
- data/spec/session_spec.rb +2 -1
- data/spec/shared_selenium_session.rb +27 -21
- data/spec/spec_helper.rb +2 -5
- metadata +66 -87
- data/lib/capybara/query.rb +0 -7
- data/spec/selenium_spec_firefox.rb +0 -68
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_button?' do
|
3
4
|
before do
|
4
5
|
@session.visit('/form')
|
@@ -7,7 +8,7 @@ Capybara::SpecHelper.spec '#has_button?' do
|
|
7
8
|
it "should be true if the given button is on the page" do
|
8
9
|
expect(@session).to have_button('med')
|
9
10
|
expect(@session).to have_button('crap321')
|
10
|
-
expect(@session).to have_button(:
|
11
|
+
expect(@session).to have_button(:crap321)
|
11
12
|
end
|
12
13
|
|
13
14
|
it "should be true for disabled buttons if disabled: true" do
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_css?' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
@@ -36,7 +37,7 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|
36
37
|
end
|
37
38
|
|
38
39
|
it "should be false if the content occurs more or fewer times than range" do
|
39
|
-
expect(@session).not_to have_css("p", between: 6..11
|
40
|
+
expect(@session).not_to have_css("p", between: 6..11)
|
40
41
|
expect(@session).not_to have_css("p a#foo", between: 4..7)
|
41
42
|
expect(@session).not_to have_css("p a.doesnotexist", between: 3..8)
|
42
43
|
end
|
@@ -162,7 +163,7 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
it "should be true if the content occurs more or fewer times than range" do
|
165
|
-
expect(@session).to have_no_css("p", between: 6..11
|
166
|
+
expect(@session).to have_no_css("p", between: 6..11)
|
166
167
|
expect(@session).to have_no_css("p a#foo", between: 4..7)
|
167
168
|
expect(@session).to have_no_css("p a.doesnotexist", between: 3..8)
|
168
169
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_current_path?' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_js')
|
@@ -65,7 +66,7 @@ Capybara::SpecHelper.spec '#has_current_path?' do
|
|
65
66
|
|
66
67
|
it "should default to full url if value is a url" do
|
67
68
|
url = @session.current_url
|
68
|
-
expect(url).to match
|
69
|
+
expect(url).to match(/with_js$/)
|
69
70
|
expect(@session).to have_current_path(url)
|
70
71
|
expect(@session).not_to have_current_path("http://www.not_example.com/with_js")
|
71
72
|
end
|
@@ -73,36 +74,24 @@ Capybara::SpecHelper.spec '#has_current_path?' do
|
|
73
74
|
it "should ignore the query" do
|
74
75
|
@session.visit('/with_js?test=test')
|
75
76
|
expect(@session).to have_current_path('/with_js?test=test')
|
76
|
-
expect(@session).to have_current_path('/with_js', only_path: true)
|
77
77
|
expect(@session).to have_current_path('/with_js', ignore_query: true)
|
78
78
|
uri = ::Addressable::URI.parse(@session.current_url)
|
79
79
|
uri.query = nil
|
80
80
|
expect(@session).to have_current_path(uri.to_s, ignore_query: true)
|
81
81
|
end
|
82
82
|
|
83
|
-
it "should not allow url and only_path at the same time" do
|
84
|
-
expect {
|
85
|
-
expect(@session).to have_current_path('/with_js', url: true, only_path: true)
|
86
|
-
}.to raise_error ArgumentError
|
87
|
-
end
|
88
|
-
|
89
83
|
it "should not raise an exception if the current_url is nil" do
|
90
84
|
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
91
85
|
|
92
|
-
# Without
|
93
|
-
expect
|
86
|
+
# Without ignore_query option
|
87
|
+
expect do
|
94
88
|
expect(@session).to have_current_path(nil)
|
95
|
-
|
96
|
-
|
97
|
-
# With only_path option
|
98
|
-
expect {
|
99
|
-
expect(@session).to have_current_path(nil, only_path: true)
|
100
|
-
}.not_to raise_exception
|
89
|
+
end.not_to raise_exception
|
101
90
|
|
102
91
|
# With ignore_query option
|
103
|
-
expect
|
92
|
+
expect do
|
104
93
|
expect(@session).to have_current_path(nil, ignore_query: true)
|
105
|
-
|
94
|
+
end.not_to raise_exception
|
106
95
|
end
|
107
96
|
end
|
108
97
|
|
@@ -134,19 +123,14 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do
|
|
134
123
|
it "should not raise an exception if the current_url is nil" do
|
135
124
|
allow_any_instance_of(Capybara::Session).to receive(:current_url) { nil }
|
136
125
|
|
137
|
-
# Without
|
138
|
-
expect
|
126
|
+
# Without ignore_query option
|
127
|
+
expect do
|
139
128
|
expect(@session).not_to have_current_path('/with_js')
|
140
|
-
|
141
|
-
|
142
|
-
# With only_path option
|
143
|
-
expect {
|
144
|
-
expect(@session).not_to have_current_path('/with_js', only_path: true)
|
145
|
-
}. not_to raise_exception
|
129
|
+
end. not_to raise_exception
|
146
130
|
|
147
131
|
# With ignore_query option
|
148
|
-
expect
|
132
|
+
expect do
|
149
133
|
expect(@session).not_to have_current_path('/with_js', ignore_query: true)
|
150
|
-
|
134
|
+
end. not_to raise_exception
|
151
135
|
end
|
152
136
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_field' do
|
3
4
|
before { @session.visit('/form') }
|
4
5
|
|
@@ -6,7 +7,7 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
6
7
|
expect(@session).to have_field('Dog')
|
7
8
|
expect(@session).to have_field('form_description')
|
8
9
|
expect(@session).to have_field('Region')
|
9
|
-
expect(@session).to have_field(:
|
10
|
+
expect(@session).to have_field(:Region)
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should be false if the field is not on the page" do
|
@@ -269,7 +270,7 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
269
270
|
|
270
271
|
it "should support locator-less usage" do
|
271
272
|
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
|
+
expect(@session).to have_unchecked_field(disabled: true, id: "form_disabled_unchecked_checkbox")
|
273
274
|
end
|
274
275
|
end
|
275
276
|
|
@@ -304,6 +305,6 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
304
305
|
|
305
306
|
it "should support locator-less usage" do
|
306
307
|
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"
|
308
|
+
expect(@session).to have_no_unchecked_field(disabled: false, id: "form_disabled_unchecked_checkbox")
|
308
309
|
end
|
309
310
|
end
|
@@ -4,58 +4,58 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be false if any of the given locators are on the page" do
|
7
|
-
expect
|
7
|
+
expect do
|
8
8
|
expect(@session).to have_none_of_selectors(:xpath, "//p", "//a")
|
9
|
-
|
10
|
-
expect
|
9
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
10
|
+
expect do
|
11
11
|
expect(@session).to have_none_of_selectors(:css, "p a#foo")
|
12
|
-
|
12
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
13
13
|
end
|
14
14
|
|
15
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"
|
16
|
+
expect(@session).to have_none_of_selectors(:xpath, "//abbr", "//td")
|
17
17
|
expect(@session).to have_none_of_selectors(:css, "p a#doesnotexist", "abbr")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should use default selector" do
|
21
21
|
Capybara.default_selector = :css
|
22
22
|
expect(@session).to have_none_of_selectors("p a#doesnotexist", "abbr")
|
23
|
-
expect
|
23
|
+
expect do
|
24
24
|
expect(@session).to have_none_of_selectors("abbr", "p a#foo")
|
25
|
-
|
25
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
26
26
|
end
|
27
27
|
|
28
28
|
context "should respect scopes" do
|
29
29
|
it "when used with `within`" do
|
30
30
|
@session.within "//p[@id='first']" do
|
31
|
-
expect
|
31
|
+
expect do
|
32
32
|
expect(@session).to have_none_of_selectors(".//a[@id='foo']")
|
33
|
-
|
33
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
34
34
|
expect(@session).to have_none_of_selectors(".//a[@id='red']")
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
it "when called on an element" do
|
39
39
|
el = @session.find "//p[@id='first']"
|
40
|
-
expect
|
40
|
+
expect do
|
41
41
|
expect(el).to have_none_of_selectors(".//a[@id='foo']")
|
42
|
-
|
42
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
43
43
|
expect(el).to have_none_of_selectors(".//a[@id='red']")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
context "with options" do
|
48
48
|
it "should apply the options to all locators" do
|
49
|
-
expect
|
49
|
+
expect do
|
50
50
|
expect(@session).to have_none_of_selectors("//p//a", text: "Redirect")
|
51
|
-
|
51
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
52
52
|
expect(@session).to have_none_of_selectors("//p", text: "Doesnotexist")
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should discard all matches where the given regexp is matched" do
|
56
|
-
expect
|
56
|
+
expect do
|
57
57
|
expect(@session).to have_none_of_selectors("//p//a", text: /re[dab]i/i, count: 1)
|
58
|
-
|
58
|
+
end.to raise_error ::RSpec::Expectations::ExpectationNotMetError
|
59
59
|
expect(@session).to have_none_of_selectors("//p//a", text: /Red$/)
|
60
60
|
end
|
61
61
|
end
|
@@ -69,8 +69,8 @@ Capybara::SpecHelper.spec '#have_none_of_selectors' do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "cannot be negated" do
|
72
|
-
expect
|
72
|
+
expect do
|
73
73
|
expect(@session).not_to have_none_of_selectors(:css, "p a#foo", "h2#h2one", "h2#h2two")
|
74
|
-
|
74
|
+
end.to raise_error ArgumentError
|
75
75
|
end
|
76
76
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_select?' do
|
3
4
|
before { @session.visit('/form') }
|
4
5
|
|
@@ -6,7 +7,7 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
6
7
|
expect(@session).to have_select('Locale')
|
7
8
|
expect(@session).to have_select('form_region')
|
8
9
|
expect(@session).to have_select('Languages')
|
9
|
-
expect(@session).to have_select(:
|
10
|
+
expect(@session).to have_select(:Languages)
|
10
11
|
end
|
11
12
|
|
12
13
|
it "should be false if the field is not on the page" do
|
@@ -33,7 +34,7 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
33
34
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
34
35
|
])
|
35
36
|
expect(@session).not_to have_select('Underwear', selected: [
|
36
|
-
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
37
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons"
|
37
38
|
])
|
38
39
|
end
|
39
40
|
|
@@ -69,25 +70,25 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
69
70
|
|
70
71
|
context 'with partial select' do
|
71
72
|
it "should be true if a field with the given partial values is on the page" do
|
72
|
-
expect(@session).to have_select('Underwear', with_selected: [
|
73
|
+
expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
73
74
|
end
|
74
75
|
|
75
76
|
it "should be false if a field with the given partial values is not on the page" do
|
76
|
-
expect(@session).not_to have_select('Underwear', with_selected: [
|
77
|
+
expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
77
78
|
end
|
78
79
|
|
79
80
|
it "should be true after the given partial value is selected" do
|
80
81
|
@session.select('Boxers', from: 'Underwear')
|
81
|
-
expect(@session).to have_select('Underwear', with_selected: [
|
82
|
+
expect(@session).to have_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
82
83
|
end
|
83
84
|
|
84
85
|
it "should be false after one of the given partial values is unselected" do
|
85
86
|
@session.unselect('Briefs', from: 'Underwear')
|
86
|
-
expect(@session).not_to have_select('Underwear', with_selected: [
|
87
|
+
expect(@session).not_to have_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
87
88
|
end
|
88
89
|
|
89
90
|
it "should be true even when the selected values are invisible, regardless of the select's visibility" do
|
90
|
-
expect(@session).to have_select('Dessert', visible: false, with_options: [
|
91
|
+
expect(@session).to have_select('Dessert', visible: false, with_options: %w[Pudding Tiramisu])
|
91
92
|
expect(@session).to have_select('Cake', with_selected: ['Chocolate Cake', 'Sponge Cake'])
|
92
93
|
end
|
93
94
|
|
@@ -99,7 +100,7 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
99
100
|
|
100
101
|
context 'with exact options' do
|
101
102
|
it "should be true if a field with the given options is on the page" do
|
102
|
-
expect(@session).to have_select('Region', options: [
|
103
|
+
expect(@session).to have_select('Region', options: %w[Norway Sweden Finland])
|
103
104
|
expect(@session).to have_select('Tendency', options: [])
|
104
105
|
end
|
105
106
|
|
@@ -107,29 +108,29 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
107
108
|
expect(@session).not_to have_select('Locale', options: ['Swedish'])
|
108
109
|
expect(@session).not_to have_select('Does not exist', options: ['John'])
|
109
110
|
expect(@session).not_to have_select('City', options: ['London', 'Made up city'])
|
110
|
-
expect(@session).not_to have_select('Region', options: [
|
111
|
-
expect(@session).not_to have_select('Region', options: [
|
111
|
+
expect(@session).not_to have_select('Region', options: %w[Norway Sweden])
|
112
|
+
expect(@session).not_to have_select('Region', options: %w[Norway Norway Norway])
|
112
113
|
end
|
113
114
|
|
114
115
|
it "should be true even when the options are invisible, if the select itself is invisible" do
|
115
|
-
expect(@session).to have_select("Icecream", visible: false, options: [
|
116
|
+
expect(@session).to have_select("Icecream", visible: false, options: %w[Chocolate Vanilla Strawberry])
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
120
|
context 'with partial options' do
|
120
121
|
it "should be true if a field with the given partial options is on the page" do
|
121
|
-
expect(@session).to have_select('Region', with_options: [
|
122
|
+
expect(@session).to have_select('Region', with_options: %w[Norway Sweden])
|
122
123
|
expect(@session).to have_select('City', with_options: ['London'])
|
123
124
|
end
|
124
125
|
|
125
126
|
it "should be false if a field with the given partial options is not on the page" do
|
126
127
|
expect(@session).not_to have_select('Locale', with_options: ['Uruguayan'])
|
127
128
|
expect(@session).not_to have_select('Does not exist', with_options: ['John'])
|
128
|
-
expect(@session).not_to have_select('Region', with_options: [
|
129
|
+
expect(@session).not_to have_select('Region', with_options: %w[Norway Sweden Finland Latvia])
|
129
130
|
end
|
130
131
|
|
131
132
|
it "should be true even when the options are invisible, if the select itself is invisible" do
|
132
|
-
expect(@session).to have_select("Icecream", visible: false, with_options: [
|
133
|
+
expect(@session).to have_select("Icecream", visible: false, with_options: %w[Vanilla Strawberry])
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
@@ -151,9 +152,9 @@ Capybara::SpecHelper.spec '#has_select?' do
|
|
151
152
|
end
|
152
153
|
|
153
154
|
it "should support locator-less usage" do
|
154
|
-
expect(@session.has_select?(with_options: [
|
155
|
+
expect(@session.has_select?(with_options: %w[Norway Sweden])).to eq true
|
155
156
|
expect(@session).to have_select(with_options: ['London'])
|
156
|
-
expect(@session.has_select?(with_selected: [
|
157
|
+
expect(@session.has_select?(with_selected: %w[Commando Boxerbriefs])).to eq true
|
157
158
|
expect(@session).to have_select(with_selected: ['Briefs'])
|
158
159
|
end
|
159
160
|
end
|
@@ -191,7 +192,7 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
191
192
|
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
192
193
|
])
|
193
194
|
expect(@session).to have_no_select('Underwear', selected: [
|
194
|
-
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
195
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons"
|
195
196
|
])
|
196
197
|
end
|
197
198
|
|
@@ -222,21 +223,21 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
222
223
|
|
223
224
|
context 'with partial select' do
|
224
225
|
it "should be false if a field with the given partial values is on the page" do
|
225
|
-
expect(@session).not_to have_no_select('Underwear', with_selected: [
|
226
|
+
expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
226
227
|
end
|
227
228
|
|
228
229
|
it "should be true if a field with the given partial values is not on the page" do
|
229
|
-
expect(@session).to have_no_select('Underwear', with_selected: [
|
230
|
+
expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
230
231
|
end
|
231
232
|
|
232
233
|
it "should be false after the given partial value is selected" do
|
233
234
|
@session.select('Boxers', from: 'Underwear')
|
234
|
-
expect(@session).not_to have_no_select('Underwear', with_selected: [
|
235
|
+
expect(@session).not_to have_no_select('Underwear', with_selected: %w[Boxerbriefs Boxers])
|
235
236
|
end
|
236
237
|
|
237
238
|
it "should be true after one of the given partial values is unselected" do
|
238
239
|
@session.unselect('Briefs', from: 'Underwear')
|
239
|
-
expect(@session).to have_no_select('Underwear', with_selected: [
|
240
|
+
expect(@session).to have_no_select('Underwear', with_selected: %w[Boxerbriefs Briefs])
|
240
241
|
end
|
241
242
|
|
242
243
|
it "should support non array partial values" do
|
@@ -247,35 +248,35 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|
247
248
|
|
248
249
|
context 'with exact options' do
|
249
250
|
it "should be false if a field with the given options is on the page" do
|
250
|
-
expect(@session).not_to have_no_select('Region', options: [
|
251
|
+
expect(@session).not_to have_no_select('Region', options: %w[Norway Sweden Finland])
|
251
252
|
end
|
252
253
|
|
253
254
|
it "should be true if the given field is not on the page" do
|
254
255
|
expect(@session).to have_no_select('Locale', options: ['Swedish'])
|
255
256
|
expect(@session).to have_no_select('Does not exist', options: ['John'])
|
256
257
|
expect(@session).to have_no_select('City', options: ['London', 'Made up city'])
|
257
|
-
expect(@session).to have_no_select('Region', options: [
|
258
|
-
expect(@session).to have_no_select('Region', options: [
|
258
|
+
expect(@session).to have_no_select('Region', options: %w[Norway Sweden])
|
259
|
+
expect(@session).to have_no_select('Region', options: %w[Norway Norway Norway])
|
259
260
|
end
|
260
261
|
end
|
261
262
|
|
262
263
|
context 'with partial options' do
|
263
264
|
it "should be false if a field with the given partial options is on the page" do
|
264
|
-
expect(@session).not_to have_no_select('Region', with_options: [
|
265
|
+
expect(@session).not_to have_no_select('Region', with_options: %w[Norway Sweden])
|
265
266
|
expect(@session).not_to have_no_select('City', with_options: ['London'])
|
266
267
|
end
|
267
268
|
|
268
269
|
it "should be true if a field with the given partial options is not on the page" do
|
269
270
|
expect(@session).to have_no_select('Locale', with_options: ['Uruguayan'])
|
270
271
|
expect(@session).to have_no_select('Does not exist', with_options: ['John'])
|
271
|
-
expect(@session).to have_no_select('Region', with_options: [
|
272
|
+
expect(@session).to have_no_select('Region', with_options: %w[Norway Sweden Finland Latvia])
|
272
273
|
end
|
273
274
|
end
|
274
275
|
|
275
276
|
it "should support locator-less usage" do
|
276
|
-
expect(@session.has_no_select?(with_options: [
|
277
|
-
expect(@session).to have_no_select(with_options: ['New London']
|
277
|
+
expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to eq true
|
278
|
+
expect(@session).to have_no_select(with_options: ['New London'])
|
278
279
|
expect(@session.has_no_select?(with_selected: ['Boxers'])).to eq true
|
279
|
-
expect(@session).to have_no_select(with_selected: [
|
280
|
+
expect(@session).to have_no_select(with_selected: %w[Commando Boxers])
|
280
281
|
end
|
281
282
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
Capybara::SpecHelper.spec '#has_selector?' do
|
3
4
|
before do
|
4
5
|
@session.visit('/with_html')
|
@@ -72,9 +73,10 @@ Capybara::SpecHelper.spec '#has_selector?' do
|
|
72
73
|
expect(@session).not_to have_selector("//p//a", text: /Red$/)
|
73
74
|
end
|
74
75
|
|
75
|
-
it "should
|
76
|
-
|
77
|
-
|
76
|
+
it "should raise when extra parameters passed" do
|
77
|
+
expect do
|
78
|
+
expect(@session).to have_selector(:css, "p a#foo", 'extra')
|
79
|
+
end.to raise_error ArgumentError, /extra/
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
@@ -131,7 +133,6 @@ Capybara::SpecHelper.spec '#has_no_selector?' do
|
|
131
133
|
end
|
132
134
|
|
133
135
|
it "should accept a filter block" do
|
134
|
-
skip "RSpec < 3 doesn't pass the block along to the matcher for the Builtin::Has matcher" if rspec2?
|
135
136
|
expect(@session).to have_no_selector(:css, "a#foo") { |el| el[:id] != "foo" }
|
136
137
|
end
|
137
138
|
|