capybara 2.9.2 → 2.10.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 +10 -1
- data/README.md +34 -27
- data/lib/capybara.rb +2 -2
- data/lib/capybara/node/actions.rb +3 -3
- data/lib/capybara/node/base.rb +2 -2
- data/lib/capybara/node/element.rb +1 -1
- data/lib/capybara/node/finders.rb +37 -32
- data/lib/capybara/node/matchers.rb +187 -171
- data/lib/capybara/queries/selector_query.rb +11 -14
- data/lib/capybara/rack_test/driver.rb +3 -3
- data/lib/capybara/rails.rb +1 -1
- data/lib/capybara/rspec/features.rb +1 -1
- data/lib/capybara/rspec/matchers.rb +31 -22
- data/lib/capybara/selector.rb +2 -2
- data/lib/capybara/selector/selector.rb +22 -0
- data/lib/capybara/session.rb +4 -4
- data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
- data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
- data/lib/capybara/spec/session/all_spec.rb +27 -27
- data/lib/capybara/spec/session/assert_current_path.rb +2 -2
- data/lib/capybara/spec/session/assert_selector.rb +28 -28
- data/lib/capybara/spec/session/assert_text.rb +20 -20
- data/lib/capybara/spec/session/assert_title.rb +2 -2
- data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
- data/lib/capybara/spec/session/check_spec.rb +5 -5
- data/lib/capybara/spec/session/choose_spec.rb +4 -4
- data/lib/capybara/spec/session/click_button_spec.rb +18 -5
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
- data/lib/capybara/spec/session/click_link_spec.rb +13 -13
- data/lib/capybara/spec/session/current_url_spec.rb +2 -2
- data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
- data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
- data/lib/capybara/spec/session/element/matches_selector_spec.rb +15 -8
- data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
- data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
- data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
- data/lib/capybara/spec/session/find_button_spec.rb +5 -5
- data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
- data/lib/capybara/spec/session/find_field_spec.rb +11 -7
- data/lib/capybara/spec/session/find_link_spec.rb +2 -2
- data/lib/capybara/spec/session/find_spec.rb +52 -48
- data/lib/capybara/spec/session/first_spec.rb +9 -9
- 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_button_spec.rb +12 -12
- data/lib/capybara/spec/session/has_css_spec.rb +73 -73
- data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
- data/lib/capybara/spec/session/has_field_spec.rb +78 -68
- data/lib/capybara/spec/session/has_link_spec.rb +8 -8
- data/lib/capybara/spec/session/has_select_spec.rb +70 -61
- data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
- data/lib/capybara/spec/session/has_text_spec.rb +6 -6
- data/lib/capybara/spec/session/has_title_spec.rb +2 -2
- data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +3 -3
- data/lib/capybara/spec/session/node_spec.rb +15 -15
- data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
- data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
- data/lib/capybara/spec/session/select_spec.rb +30 -30
- data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +2 -2
- data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
- data/lib/capybara/spec/session/within_spec.rb +6 -6
- data/lib/capybara/spec/spec_helper.rb +1 -1
- data/lib/capybara/spec/test_app.rb +1 -1
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +5 -5
- data/spec/capybara_spec.rb +1 -1
- data/spec/dsl_spec.rb +1 -1
- data/spec/rack_test_spec.rb +7 -7
- data/spec/rspec/matchers_spec.rb +6 -6
- data/spec/rspec_spec.rb +1 -1
- data/spec/selector_spec.rb +13 -0
- data/spec/selenium_firefox_spec.rb +1 -1
- data/spec/selenium_spec_chrome.rb +1 -1
- data/spec/shared_selenium_session.rb +10 -10
- metadata +2 -2
@@ -43,27 +43,27 @@ Capybara::SpecHelper.spec '#first' do
|
|
43
43
|
|
44
44
|
context "with visible filter" do
|
45
45
|
it "should only find visible nodes when true" do
|
46
|
-
expect(@session.first(:css, "a#invisible", :
|
46
|
+
expect(@session.first(:css, "a#invisible", visible: true)).to be_nil
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should find nodes regardless of whether they are invisible when false" do
|
50
|
-
expect(@session.first(:css, "a#invisible", :
|
51
|
-
expect(@session.first(:css, "a#visible", :
|
50
|
+
expect(@session.first(:css, "a#invisible", visible: false)).not_to be_nil
|
51
|
+
expect(@session.first(:css, "a#visible", visible: false)).not_to be_nil
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should find nodes regardless of whether they are invisible when :all" do
|
55
|
-
expect(@session.first(:css, "a#invisible", :
|
56
|
-
expect(@session.first(:css, "a#visible", :
|
55
|
+
expect(@session.first(:css, "a#invisible", visible: :all)).not_to be_nil
|
56
|
+
expect(@session.first(:css, "a#visible", visible: :all)).not_to be_nil
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should find only hidden nodes when :hidden" do
|
60
|
-
expect(@session.first(:css, "a#invisible", :
|
61
|
-
expect(@session.first(:css, "a#visible", :
|
60
|
+
expect(@session.first(:css, "a#invisible", visible: :hidden)).not_to be_nil
|
61
|
+
expect(@session.first(:css, "a#visible", visible: :hidden)).to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should find only visible nodes when :visible" do
|
65
|
-
expect(@session.first(:css, "a#invisible", :
|
66
|
-
expect(@session.first(:css, "a#visible", :
|
65
|
+
expect(@session.first(:css, "a#invisible", visible: :visible)).to be_nil
|
66
|
+
expect(@session.first(:css, "a#visible", visible: :visible)).not_to be_nil
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should default to Capybara.ignore_hidden_elements" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
Capybara::SpecHelper.spec '#go_back', :
|
2
|
+
Capybara::SpecHelper.spec '#go_back', requires: [:js] do
|
3
3
|
it "should fetch a response from the driver from the previous page" do
|
4
4
|
@session.visit('/')
|
5
5
|
expect(@session).to have_content('Hello world!')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
Capybara::SpecHelper.spec '#go_forward', :
|
2
|
+
Capybara::SpecHelper.spec '#go_forward', requires: [:js] do
|
3
3
|
it "should fetch a response from the driver from the previous page" do
|
4
4
|
@session.visit('/')
|
5
5
|
expect(@session).to have_content('Hello world!')
|
@@ -10,8 +10,8 @@ Capybara::SpecHelper.spec '#has_button?' do
|
|
10
10
|
expect(@session).to have_button(:'crap321')
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should be true for disabled buttons if :
|
14
|
-
expect(@session).to have_button('Disabled button', :
|
13
|
+
it "should be true for disabled buttons if disabled: true" do
|
14
|
+
expect(@session).to have_button('Disabled button', disabled: true)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should be false if the given button is not on the page" do
|
@@ -22,16 +22,16 @@ Capybara::SpecHelper.spec '#has_button?' do
|
|
22
22
|
expect(@session).not_to have_button('Disabled button')
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should be false for disabled buttons if :
|
26
|
-
expect(@session).not_to have_button('Disabled button', :
|
25
|
+
it "should be false for disabled buttons if disabled: false" do
|
26
|
+
expect(@session).not_to have_button('Disabled button', disabled: false)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should be true for disabled buttons if :
|
30
|
-
expect(@session).to have_button('Disabled button', :
|
29
|
+
it "should be true for disabled buttons if disabled: :all" do
|
30
|
+
expect(@session).to have_button('Disabled button', disabled: :all)
|
31
31
|
end
|
32
32
|
|
33
|
-
it "should be true for enabled buttons if :
|
34
|
-
expect(@session).to have_button('med', :
|
33
|
+
it "should be true for enabled buttons if disabled: :all" do
|
34
|
+
expect(@session).to have_button('med', disabled: :all)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -45,8 +45,8 @@ Capybara::SpecHelper.spec '#has_no_button?' do
|
|
45
45
|
expect(@session).not_to have_no_button('crap321')
|
46
46
|
end
|
47
47
|
|
48
|
-
it "should be true for disabled buttons if :
|
49
|
-
expect(@session).not_to have_no_button('Disabled button', :
|
48
|
+
it "should be true for disabled buttons if disabled: true" do
|
49
|
+
expect(@session).not_to have_no_button('Disabled button', disabled: true)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should be false if the given button is not on the page" do
|
@@ -57,7 +57,7 @@ Capybara::SpecHelper.spec '#has_no_button?' do
|
|
57
57
|
expect(@session).to have_no_button('Disabled button')
|
58
58
|
end
|
59
59
|
|
60
|
-
it "should be false for disabled buttons if :
|
61
|
-
expect(@session).to have_no_button('Disabled button', :
|
60
|
+
it "should be false for disabled buttons if disabled: false" do
|
61
|
+
expect(@session).to have_no_button('Disabled button', disabled: false)
|
62
62
|
end
|
63
63
|
end
|
@@ -22,7 +22,7 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
it "should wait for content to appear", :
|
25
|
+
it "should wait for content to appear", requires: [:js] do
|
26
26
|
@session.visit('/with_js')
|
27
27
|
@session.click_link('Click me')
|
28
28
|
expect(@session).to have_css("input[type='submit'][value='New Here']")
|
@@ -30,86 +30,86 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|
30
30
|
|
31
31
|
context "with between" do
|
32
32
|
it "should be true if the content occurs within the range given" do
|
33
|
-
expect(@session).to have_css("p", :
|
34
|
-
expect(@session).to have_css("p a#foo", :
|
35
|
-
expect(@session).to have_css("p a.doesnotexist", :
|
33
|
+
expect(@session).to have_css("p", between: 1..4)
|
34
|
+
expect(@session).to have_css("p a#foo", between: 1..3)
|
35
|
+
expect(@session).to have_css("p a.doesnotexist", between: 0..8)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be false if the content occurs more or fewer times than range" do
|
39
|
-
expect(@session).not_to have_css("p", :
|
40
|
-
expect(@session).not_to have_css("p a#foo", :
|
41
|
-
expect(@session).not_to have_css("p a.doesnotexist", :
|
39
|
+
expect(@session).not_to have_css("p", between: 6..11 )
|
40
|
+
expect(@session).not_to have_css("p a#foo", between: 4..7)
|
41
|
+
expect(@session).not_to have_css("p a.doesnotexist", between: 3..8)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context "with count" do
|
46
46
|
it "should be true if the content occurs the given number of times" do
|
47
|
-
expect(@session).to have_css("p", :
|
48
|
-
expect(@session).to have_css("p a#foo", :
|
49
|
-
expect(@session).to have_css("p a.doesnotexist", :
|
47
|
+
expect(@session).to have_css("p", count: 3)
|
48
|
+
expect(@session).to have_css("p a#foo", count: 1)
|
49
|
+
expect(@session).to have_css("p a.doesnotexist", count: 0)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should be false if the content occurs a different number of times than the given" do
|
53
|
-
expect(@session).not_to have_css("p", :
|
54
|
-
expect(@session).not_to have_css("p a#foo", :
|
55
|
-
expect(@session).not_to have_css("p a.doesnotexist", :
|
53
|
+
expect(@session).not_to have_css("p", count: 6)
|
54
|
+
expect(@session).not_to have_css("p a#foo", count: 2)
|
55
|
+
expect(@session).not_to have_css("p a.doesnotexist", count: 1)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should coerce count to an integer" do
|
59
|
-
expect(@session).to have_css("p", :
|
60
|
-
expect(@session).to have_css("p a#foo", :
|
59
|
+
expect(@session).to have_css("p", count: "3")
|
60
|
+
expect(@session).to have_css("p a#foo", count: "1")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
context "with maximum" do
|
65
65
|
it "should be true when content occurs same or fewer times than given" do
|
66
|
-
expect(@session).to have_css("h2.head", :
|
67
|
-
expect(@session).to have_css("h2", :
|
68
|
-
expect(@session).to have_css("p a.doesnotexist", :
|
69
|
-
expect(@session).to have_css("p a.doesnotexist", :
|
66
|
+
expect(@session).to have_css("h2.head", maximum: 5) # edge case
|
67
|
+
expect(@session).to have_css("h2", maximum: 10)
|
68
|
+
expect(@session).to have_css("p a.doesnotexist", maximum: 1)
|
69
|
+
expect(@session).to have_css("p a.doesnotexist", maximum: 0)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should be false when content occurs more times than given" do
|
73
|
-
expect(@session).not_to have_css("h2.head", :
|
74
|
-
expect(@session).not_to have_css("h2", :
|
75
|
-
expect(@session).not_to have_css("p", :
|
73
|
+
expect(@session).not_to have_css("h2.head", maximum: 4) # edge case
|
74
|
+
expect(@session).not_to have_css("h2", maximum: 3)
|
75
|
+
expect(@session).not_to have_css("p", maximum: 1)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should coerce maximum to an integer" do
|
79
|
-
expect(@session).to have_css("h2.head", :
|
80
|
-
expect(@session).to have_css("h2", :
|
79
|
+
expect(@session).to have_css("h2.head", maximum: "5") # edge case
|
80
|
+
expect(@session).to have_css("h2", maximum: "10")
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
context "with minimum" do
|
85
85
|
it "should be true when content occurs same or more times than given" do
|
86
|
-
expect(@session).to have_css("h2.head", :
|
87
|
-
expect(@session).to have_css("h2", :
|
88
|
-
expect(@session).to have_css("p a.doesnotexist", :
|
86
|
+
expect(@session).to have_css("h2.head", minimum: 5) # edge case
|
87
|
+
expect(@session).to have_css("h2", minimum: 3)
|
88
|
+
expect(@session).to have_css("p a.doesnotexist", minimum: 0)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should be false when content occurs fewer times than given" do
|
92
|
-
expect(@session).not_to have_css("h2.head", :
|
93
|
-
expect(@session).not_to have_css("h2", :
|
94
|
-
expect(@session).not_to have_css("p", :
|
95
|
-
expect(@session).not_to have_css("p a.doesnotexist", :
|
92
|
+
expect(@session).not_to have_css("h2.head", minimum: 6) # edge case
|
93
|
+
expect(@session).not_to have_css("h2", minimum: 8)
|
94
|
+
expect(@session).not_to have_css("p", minimum: 10)
|
95
|
+
expect(@session).not_to have_css("p a.doesnotexist", minimum: 1)
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should coerce minimum to an integer" do
|
99
|
-
expect(@session).to have_css("h2.head", :
|
100
|
-
expect(@session).to have_css("h2", :
|
99
|
+
expect(@session).to have_css("h2.head", minimum: "5") # edge case
|
100
|
+
expect(@session).to have_css("h2", minimum: "3")
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "with text" do
|
105
105
|
it "should discard all matches where the given string is not contained" do
|
106
|
-
expect(@session).to have_css("p a", :
|
107
|
-
expect(@session).not_to have_css("p a", :
|
106
|
+
expect(@session).to have_css("p a", text: "Redirect", count: 1)
|
107
|
+
expect(@session).not_to have_css("p a", text: "Doesnotexist")
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should discard all matches where the given regexp is not matched" do
|
111
|
-
expect(@session).to have_css("p a", :
|
112
|
-
expect(@session).not_to have_css("p a", :
|
111
|
+
expect(@session).to have_css("p a", text: /re[dab]i/i, count: 1)
|
112
|
+
expect(@session).not_to have_css("p a", text: /Red$/)
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -137,7 +137,7 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
it "should wait for content to disappear", :
|
140
|
+
it "should wait for content to disappear", requires: [:js] do
|
141
141
|
@session.visit('/with_js')
|
142
142
|
@session.click_link('Click me')
|
143
143
|
expect(@session).to have_no_css("p#change")
|
@@ -145,85 +145,85 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|
145
145
|
|
146
146
|
context "with between" do
|
147
147
|
it "should be false if the content occurs within the range given" do
|
148
|
-
expect(@session).not_to have_no_css("p", :
|
149
|
-
expect(@session).not_to have_no_css("p a#foo", :
|
150
|
-
expect(@session).not_to have_no_css("p a.doesnotexist", :
|
148
|
+
expect(@session).not_to have_no_css("p", between: 1..4)
|
149
|
+
expect(@session).not_to have_no_css("p a#foo", between: 1..3)
|
150
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", between: 0..2)
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should be true if the content occurs more or fewer times than range" do
|
154
|
-
expect(@session).to have_no_css("p", :
|
155
|
-
expect(@session).to have_no_css("p a#foo", :
|
156
|
-
expect(@session).to have_no_css("p a.doesnotexist", :
|
154
|
+
expect(@session).to have_no_css("p", between: 6..11 )
|
155
|
+
expect(@session).to have_no_css("p a#foo", between: 4..7)
|
156
|
+
expect(@session).to have_no_css("p a.doesnotexist", between: 3..8)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
context "with count" do
|
161
161
|
it "should be false if the content is on the page the given number of times" do
|
162
|
-
expect(@session).not_to have_no_css("p", :
|
163
|
-
expect(@session).not_to have_no_css("p a#foo", :
|
164
|
-
expect(@session).not_to have_no_css("p a.doesnotexist", :
|
162
|
+
expect(@session).not_to have_no_css("p", count: 3)
|
163
|
+
expect(@session).not_to have_no_css("p a#foo", count: 1)
|
164
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", count: 0)
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should be true if the content is on the page the given number of times" do
|
168
|
-
expect(@session).to have_no_css("p", :
|
169
|
-
expect(@session).to have_no_css("p a#foo", :
|
170
|
-
expect(@session).to have_no_css("p a.doesnotexist", :
|
168
|
+
expect(@session).to have_no_css("p", count: 6)
|
169
|
+
expect(@session).to have_no_css("p a#foo", count: 2)
|
170
|
+
expect(@session).to have_no_css("p a.doesnotexist", count: 1)
|
171
171
|
end
|
172
172
|
|
173
173
|
it "should coerce count to an integer" do
|
174
|
-
expect(@session).not_to have_no_css("p", :
|
175
|
-
expect(@session).not_to have_no_css("p a#foo", :
|
174
|
+
expect(@session).not_to have_no_css("p", count: "3")
|
175
|
+
expect(@session).not_to have_no_css("p a#foo", count: "1")
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
179
|
context "with maximum" do
|
180
180
|
it "should be false when content occurs same or fewer times than given" do
|
181
|
-
expect(@session).not_to have_no_css("h2.head", :
|
182
|
-
expect(@session).not_to have_no_css("h2", :
|
183
|
-
expect(@session).not_to have_no_css("p a.doesnotexist", :
|
181
|
+
expect(@session).not_to have_no_css("h2.head", maximum: 5) # edge case
|
182
|
+
expect(@session).not_to have_no_css("h2", maximum: 10)
|
183
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", maximum: 0)
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should be true when content occurs more times than given" do
|
187
|
-
expect(@session).to have_no_css("h2.head", :
|
188
|
-
expect(@session).to have_no_css("h2", :
|
189
|
-
expect(@session).to have_no_css("p", :
|
187
|
+
expect(@session).to have_no_css("h2.head", maximum: 4) # edge case
|
188
|
+
expect(@session).to have_no_css("h2", maximum: 3)
|
189
|
+
expect(@session).to have_no_css("p", maximum: 1)
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should coerce maximum to an integer" do
|
193
|
-
expect(@session).not_to have_no_css("h2.head", :
|
194
|
-
expect(@session).not_to have_no_css("h2", :
|
193
|
+
expect(@session).not_to have_no_css("h2.head", maximum: "5") # edge case
|
194
|
+
expect(@session).not_to have_no_css("h2", maximum: "10")
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
198
198
|
context "with minimum" do
|
199
199
|
it "should be false when content occurs same or more times than given" do
|
200
|
-
expect(@session).not_to have_no_css("h2.head", :
|
201
|
-
expect(@session).not_to have_no_css("h2", :
|
202
|
-
expect(@session).not_to have_no_css("p a.doesnotexist", :
|
200
|
+
expect(@session).not_to have_no_css("h2.head", minimum: 5) # edge case
|
201
|
+
expect(@session).not_to have_no_css("h2", minimum: 3)
|
202
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", minimum: 0)
|
203
203
|
end
|
204
204
|
|
205
205
|
it "should be true when content occurs fewer times than given" do
|
206
|
-
expect(@session).to have_no_css("h2.head", :
|
207
|
-
expect(@session).to have_no_css("h2", :
|
208
|
-
expect(@session).to have_no_css("p", :
|
209
|
-
expect(@session).to have_no_css("p a.doesnotexist", :
|
206
|
+
expect(@session).to have_no_css("h2.head", minimum: 6) # edge case
|
207
|
+
expect(@session).to have_no_css("h2", minimum: 8)
|
208
|
+
expect(@session).to have_no_css("p", minimum: 15)
|
209
|
+
expect(@session).to have_no_css("p a.doesnotexist", minimum: 1)
|
210
210
|
end
|
211
211
|
|
212
212
|
it "should coerce minimum to an integer" do
|
213
|
-
expect(@session).not_to have_no_css("h2.head", :
|
214
|
-
expect(@session).not_to have_no_css("h2", :
|
213
|
+
expect(@session).not_to have_no_css("h2.head", minimum: "4") # edge case
|
214
|
+
expect(@session).not_to have_no_css("h2", minimum: "3")
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
218
|
context "with text" do
|
219
219
|
it "should discard all matches where the given string is not contained" do
|
220
|
-
expect(@session).not_to have_no_css("p a", :
|
221
|
-
expect(@session).to have_no_css("p a", :
|
220
|
+
expect(@session).not_to have_no_css("p a", text: "Redirect", count: 1)
|
221
|
+
expect(@session).to have_no_css("p a", text: "Doesnotexist")
|
222
222
|
end
|
223
223
|
|
224
224
|
it "should discard all matches where the given regexp is not matched" do
|
225
|
-
expect(@session).not_to have_no_css("p a", :
|
226
|
-
expect(@session).to have_no_css("p a", :
|
225
|
+
expect(@session).not_to have_no_css("p a", text: /re[dab]i/i, count: 1)
|
226
|
+
expect(@session).to have_no_css("p a", text: /Red$/)
|
227
227
|
end
|
228
228
|
end
|
229
229
|
end
|
@@ -23,7 +23,7 @@ Capybara::SpecHelper.spec '#has_current_path?' do
|
|
23
23
|
expect(@session).to have_current_path("/with_html?options%5B%5D=things")
|
24
24
|
end
|
25
25
|
|
26
|
-
it "should wait for current_path", :
|
26
|
+
it "should wait for current_path", requires: [:js] do
|
27
27
|
@session.click_link("Change page")
|
28
28
|
expect(@session).to have_current_path("/with_html")
|
29
29
|
end
|
@@ -68,7 +68,7 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do
|
|
68
68
|
expect(@session).to have_no_current_path(/monkey/)
|
69
69
|
end
|
70
70
|
|
71
|
-
it "should wait for current_path to disappear", :
|
71
|
+
it "should wait for current_path to disappear", requires: [:js] do
|
72
72
|
@session.click_link("Change page")
|
73
73
|
expect(@session).to have_no_current_path('/with_js')
|
74
74
|
end
|
@@ -15,50 +15,50 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
15
15
|
|
16
16
|
context 'with value' do
|
17
17
|
it "should be true if a field with the given value is on the page" do
|
18
|
-
expect(@session).to have_field('First Name', :
|
19
|
-
expect(@session).to have_field('First Name', :
|
20
|
-
expect(@session).to have_field('Phone', :
|
21
|
-
expect(@session).to have_field('Street', :
|
22
|
-
expect(@session).to have_field('Description', :
|
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')
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be false if the given field is not on the page" do
|
26
|
-
expect(@session).not_to have_field('First Name', :
|
27
|
-
expect(@session).not_to have_field('First Name', :
|
28
|
-
expect(@session).not_to have_field('Wrong Name', :
|
29
|
-
expect(@session).not_to have_field('Description', :
|
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')
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should be true after the field has been filled in with the given value" do
|
33
|
-
@session.fill_in('First Name', :
|
34
|
-
expect(@session).to have_field('First Name', :
|
35
|
-
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/)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should be false after the field has been filled in with a different value" do
|
39
|
-
@session.fill_in('First Name', :
|
40
|
-
expect(@session).not_to have_field('First Name', :
|
41
|
-
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/)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'with type' do
|
46
46
|
it "should be true if a field with the given type is on the page" do
|
47
|
-
expect(@session).to have_field('First Name', :
|
48
|
-
expect(@session).to have_field('Html5 Email', :
|
49
|
-
expect(@session).to have_field('Html5 Multiple Email', :
|
50
|
-
expect(@session).to have_field('Html5 Tel', :
|
51
|
-
expect(@session).to have_field('Description', :
|
52
|
-
expect(@session).to have_field('Languages', :
|
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')
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should be false if the given field is not on the page" do
|
56
|
-
expect(@session).not_to have_field('First Name', :
|
57
|
-
expect(@session).not_to have_field('Html5 Email', :
|
58
|
-
expect(@session).not_to have_field('Html5 Multiple Email', :
|
59
|
-
expect(@session).not_to have_field('Description', :
|
60
|
-
expect(@session).not_to have_field('Description', :
|
61
|
-
expect(@session).not_to have_field('Languages', :
|
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
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -88,44 +88,44 @@ Capybara::SpecHelper.spec '#has_no_field' do
|
|
88
88
|
|
89
89
|
context 'with value' do
|
90
90
|
it "should be false if a field with the given value is on the page" do
|
91
|
-
expect(@session).not_to have_no_field('First Name', :
|
92
|
-
expect(@session).not_to have_no_field('Phone', :
|
93
|
-
expect(@session).not_to have_no_field('Street', :
|
94
|
-
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')
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should be true if the given field is not on the page" do
|
98
|
-
expect(@session).to have_no_field('First Name', :
|
99
|
-
expect(@session).to have_no_field('Wrong Name', :
|
100
|
-
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')
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should be false after the field has been filled in with the given value" do
|
104
|
-
@session.fill_in('First Name', :
|
105
|
-
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')
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should be true after the field has been filled in with a different value" do
|
109
|
-
@session.fill_in('First Name', :
|
110
|
-
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')
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
context 'with type' do
|
115
115
|
it "should be false if a field with the given type is on the page" do
|
116
|
-
expect(@session).not_to have_no_field('First Name', :
|
117
|
-
expect(@session).not_to have_no_field('Html5 Email', :
|
118
|
-
expect(@session).not_to have_no_field('Html5 Tel', :
|
119
|
-
expect(@session).not_to have_no_field('Description', :
|
120
|
-
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')
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should be true if the given field is not on the page" do
|
124
|
-
expect(@session).to have_no_field('First Name', :
|
125
|
-
expect(@session).to have_no_field('Html5 Email', :
|
126
|
-
expect(@session).to have_no_field('Description', :
|
127
|
-
expect(@session).to have_no_field('Description', :
|
128
|
-
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')
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
@@ -138,8 +138,8 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
138
138
|
expect(@session).to have_checked_field('Hamster')
|
139
139
|
end
|
140
140
|
|
141
|
-
it "should be true for disabled checkboxes if :
|
142
|
-
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)
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should be false if an unchecked field is on the page" do
|
@@ -155,16 +155,16 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
155
155
|
expect(@session).not_to have_checked_field('Disabled Checkbox')
|
156
156
|
end
|
157
157
|
|
158
|
-
it "should be false for disabled checkboxes if :
|
159
|
-
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
160
|
end
|
161
161
|
|
162
|
-
it "should be true for disabled checkboxes if :
|
163
|
-
expect(@session).to have_checked_field('Disabled Checkbox', :
|
162
|
+
it "should be true for disabled checkboxes if disabled: :all" do
|
163
|
+
expect(@session).to have_checked_field('Disabled Checkbox', disabled: :all)
|
164
164
|
end
|
165
165
|
|
166
|
-
it "should be true for enabled checkboxes if :
|
167
|
-
expect(@session).to have_checked_field('gender_female', :
|
166
|
+
it "should be true for enabled checkboxes if disabled: :all" do
|
167
|
+
expect(@session).to have_checked_field('gender_female', disabled: :all)
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should be true after an unchecked checkbox is checked" do
|
@@ -196,8 +196,8 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
196
196
|
expect(@session).not_to have_no_checked_field('Hamster')
|
197
197
|
end
|
198
198
|
|
199
|
-
it "should be false for disabled checkboxes if :
|
200
|
-
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)
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should be true if an unchecked field is on the page" do
|
@@ -213,8 +213,8 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
213
213
|
expect(@session).to have_no_checked_field('Disabled Checkbox')
|
214
214
|
end
|
215
215
|
|
216
|
-
it "should be true for disabled checkboxes if :
|
217
|
-
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)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
|
@@ -231,8 +231,8 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
231
231
|
expect(@session).to have_unchecked_field('Male')
|
232
232
|
end
|
233
233
|
|
234
|
-
it "should be true for disabled unchecked fields if :
|
235
|
-
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)
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should be false if no field is on the page" do
|
@@ -243,8 +243,8 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
243
243
|
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
|
244
244
|
end
|
245
245
|
|
246
|
-
it "should be false for disabled unchecked fields if :
|
247
|
-
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)
|
248
248
|
end
|
249
249
|
|
250
250
|
it "should be false after an unchecked checkbox is checked" do
|
@@ -266,6 +266,11 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
266
266
|
@session.choose('gender_male')
|
267
267
|
expect(@session).to have_unchecked_field('gender_female')
|
268
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
|
269
274
|
end
|
270
275
|
|
271
276
|
Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
@@ -281,8 +286,8 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
281
286
|
expect(@session).not_to have_no_unchecked_field('Male')
|
282
287
|
end
|
283
288
|
|
284
|
-
it "should be false for disabled unchecked fields if :
|
285
|
-
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)
|
286
291
|
end
|
287
292
|
|
288
293
|
it "should be true if no field is on the page" do
|
@@ -293,7 +298,12 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
293
298
|
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
|
294
299
|
end
|
295
300
|
|
296
|
-
it "should be true for disabled unchecked fields if :
|
297
|
-
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" )
|
298
308
|
end
|
299
309
|
end
|