capybara 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +26 -0
- data/README.md +36 -14
- data/lib/capybara.rb +6 -3
- data/lib/capybara/driver/base.rb +37 -1
- data/lib/capybara/driver/node.rb +10 -2
- data/lib/capybara/helpers.rb +21 -13
- data/lib/capybara/node/base.rb +12 -7
- data/lib/capybara/node/element.rb +17 -1
- data/lib/capybara/node/finders.rb +22 -1
- data/lib/capybara/node/matchers.rb +26 -5
- data/lib/capybara/node/simple.rb +9 -2
- data/lib/capybara/rack_test/css_handlers.rb +3 -1
- data/lib/capybara/rack_test/form.rb +3 -2
- data/lib/capybara/rack_test/node.rb +3 -3
- data/lib/capybara/rspec.rb +1 -0
- data/lib/capybara/rspec/features.rb +2 -1
- data/lib/capybara/rspec/matchers.rb +50 -5
- data/lib/capybara/selenium/driver.rb +76 -12
- data/lib/capybara/selenium/node.rb +8 -0
- data/lib/capybara/server.rb +1 -1
- data/lib/capybara/session.rb +234 -29
- data/lib/capybara/spec/public/jquery.js +1 -1
- data/lib/capybara/spec/public/test.js +7 -0
- data/lib/capybara/spec/session/all_spec.rb +88 -17
- data/lib/capybara/spec/session/assert_selector.rb +6 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
- data/lib/capybara/spec/session/body_spec.rb +4 -4
- data/lib/capybara/spec/session/check_spec.rb +16 -16
- data/lib/capybara/spec/session/choose_spec.rb +5 -5
- data/lib/capybara/spec/session/click_button_spec.rb +93 -84
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
- data/lib/capybara/spec/session/click_link_spec.rb +26 -19
- data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
- data/lib/capybara/spec/session/current_url_spec.rb +8 -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 +22 -22
- data/lib/capybara/spec/session/find_button_spec.rb +4 -4
- data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
- data/lib/capybara/spec/session/find_field_spec.rb +7 -7
- data/lib/capybara/spec/session/find_link_spec.rb +4 -4
- data/lib/capybara/spec/session/find_spec.rb +46 -46
- data/lib/capybara/spec/session/first_spec.rb +23 -23
- data/lib/capybara/spec/session/go_back_spec.rb +3 -3
- data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
- data/lib/capybara/spec/session/has_button_spec.rb +13 -13
- data/lib/capybara/spec/session/has_css_spec.rb +87 -87
- data/lib/capybara/spec/session/has_field_spec.rb +87 -87
- data/lib/capybara/spec/session/has_link_spec.rb +11 -11
- data/lib/capybara/spec/session/has_select_spec.rb +58 -58
- data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
- data/lib/capybara/spec/session/has_table_spec.rb +7 -7
- data/lib/capybara/spec/session/has_text_spec.rb +73 -73
- data/lib/capybara/spec/session/has_title_spec.rb +10 -10
- data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
- data/lib/capybara/spec/session/headers.rb +1 -1
- data/lib/capybara/spec/session/html_spec.rb +9 -9
- data/lib/capybara/spec/session/node_spec.rb +81 -65
- data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
- data/lib/capybara/spec/session/response_code.rb +1 -1
- data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
- data/lib/capybara/spec/session/save_page_spec.rb +9 -9
- data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
- data/lib/capybara/spec/session/select_spec.rb +22 -22
- data/lib/capybara/spec/session/text_spec.rb +15 -10
- data/lib/capybara/spec/session/title_spec.rb +2 -2
- data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
- data/lib/capybara/spec/session/unselect_spec.rb +14 -14
- data/lib/capybara/spec/session/visit_spec.rb +24 -17
- data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
- data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
- data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
- data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
- data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
- data/lib/capybara/spec/session/window/window_spec.rb +141 -0
- data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
- data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
- data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
- data/lib/capybara/spec/session/within_spec.rb +16 -16
- data/lib/capybara/spec/spec_helper.rb +14 -4
- data/lib/capybara/spec/views/form.erb +7 -0
- data/lib/capybara/spec/views/popup_one.erb +1 -1
- data/lib/capybara/spec/views/popup_two.erb +1 -1
- data/lib/capybara/spec/views/with_js.erb +2 -0
- data/lib/capybara/spec/views/with_windows.erb +38 -0
- data/lib/capybara/version.rb +1 -1
- data/lib/capybara/window.rb +123 -0
- data/spec/basic_node_spec.rb +32 -32
- data/spec/capybara_spec.rb +6 -7
- data/spec/dsl_spec.rb +48 -48
- data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
- data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
- data/spec/rack_test_spec.rb +33 -19
- data/spec/result_spec.rb +13 -13
- data/spec/rspec/features_spec.rb +20 -15
- data/spec/rspec/matchers_spec.rb +109 -109
- data/spec/rspec_spec.rb +10 -10
- data/spec/selenium_spec.rb +31 -6
- data/spec/selenium_spec_chrome.rb +2 -2
- data/spec/server_spec.rb +13 -13
- metadata +51 -62
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/capybara/spec/session/within_window_spec.rb +0 -45
- data/lib/capybara/spec/views/within_popups.erb +0 -25
- metadata.gz.sig +0 -0
@@ -1,10 +1,10 @@
|
|
1
1
|
Capybara::SpecHelper.spec '#go_back', :requires => [:js] do
|
2
2
|
it "should fetch a response from the driver from the previous page" do
|
3
3
|
@session.visit('/')
|
4
|
-
@session.
|
4
|
+
expect(@session).to have_content('Hello world!')
|
5
5
|
@session.visit('/foo')
|
6
|
-
@session.
|
6
|
+
expect(@session).to have_content('Another World')
|
7
7
|
@session.go_back
|
8
|
-
@session.
|
8
|
+
expect(@session).to have_content('Hello world!')
|
9
9
|
end
|
10
10
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Capybara::SpecHelper.spec '#go_forward', :requires => [:js] do
|
2
2
|
it "should fetch a response from the driver from the previous page" do
|
3
3
|
@session.visit('/')
|
4
|
-
@session.
|
4
|
+
expect(@session).to have_content('Hello world!')
|
5
5
|
@session.visit('/foo')
|
6
|
-
@session.
|
6
|
+
expect(@session).to have_content('Another World')
|
7
7
|
@session.go_back
|
8
|
-
@session.
|
8
|
+
expect(@session).to have_content('Hello world!')
|
9
9
|
@session.go_forward
|
10
|
-
@session.
|
10
|
+
expect(@session).to have_content('Another World')
|
11
11
|
end
|
12
12
|
end
|
@@ -4,25 +4,25 @@ Capybara::SpecHelper.spec '#has_button?' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be true if the given button is on the page" do
|
7
|
-
@session.
|
8
|
-
@session.
|
9
|
-
@session.
|
7
|
+
expect(@session).to have_button('med')
|
8
|
+
expect(@session).to have_button('crap321')
|
9
|
+
expect(@session).to have_button(:'crap321')
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should be true for disabled buttons if :disabled => true" do
|
13
|
-
@session.
|
13
|
+
expect(@session).to have_button('Disabled button', :disabled => true)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should be false if the given button is not on the page" do
|
17
|
-
@session.
|
17
|
+
expect(@session).not_to have_button('monkey')
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should be false for disabled buttons by default" do
|
21
|
-
@session.
|
21
|
+
expect(@session).not_to have_button('Disabled button')
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should be false for disabled buttons if :disabled => false" do
|
25
|
-
@session.
|
25
|
+
expect(@session).not_to have_button('Disabled button', :disabled => false)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -32,23 +32,23 @@ Capybara::SpecHelper.spec '#has_no_button?' do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should be true if the given button is on the page" do
|
35
|
-
@session.
|
36
|
-
@session.
|
35
|
+
expect(@session).not_to have_no_button('med')
|
36
|
+
expect(@session).not_to have_no_button('crap321')
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should be true for disabled buttons if :disabled => true" do
|
40
|
-
@session.
|
40
|
+
expect(@session).not_to have_no_button('Disabled button', :disabled => true)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should be false if the given button is not on the page" do
|
44
|
-
@session.
|
44
|
+
expect(@session).to have_no_button('monkey')
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should be false for disabled buttons by default" do
|
48
|
-
@session.
|
48
|
+
expect(@session).to have_no_button('Disabled button')
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should be false for disabled buttons if :disabled => false" do
|
52
|
-
@session.
|
52
|
+
expect(@session).to have_no_button('Disabled button', :disabled => false)
|
53
53
|
end
|
54
54
|
end
|
@@ -4,111 +4,111 @@ Capybara::SpecHelper.spec '#has_css?' do
|
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be true if the given selector is on the page" do
|
7
|
-
@session.
|
8
|
-
@session.
|
7
|
+
expect(@session).to have_css("p")
|
8
|
+
expect(@session).to have_css("p a#foo")
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should be false if the given selector is not on the page" do
|
12
|
-
@session.
|
13
|
-
@session.
|
14
|
-
@session.
|
12
|
+
expect(@session).not_to have_css("abbr")
|
13
|
+
expect(@session).not_to have_css("p a#doesnotexist")
|
14
|
+
expect(@session).not_to have_css("p.nosuchclass")
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should respect scopes" do
|
18
18
|
@session.within "//p[@id='first']" do
|
19
|
-
@session.
|
20
|
-
@session.
|
19
|
+
expect(@session).to have_css("a#foo")
|
20
|
+
expect(@session).not_to have_css("a#red")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should wait for content to appear", :requires => [:js] do
|
25
25
|
@session.visit('/with_js')
|
26
26
|
@session.click_link('Click me')
|
27
|
-
@session.
|
27
|
+
expect(@session).to have_css("input[type='submit'][value='New Here']")
|
28
28
|
end
|
29
29
|
|
30
30
|
context "with between" do
|
31
31
|
it "should be true if the content occurs within the range given" do
|
32
|
-
@session.
|
33
|
-
@session.
|
34
|
-
@session.
|
32
|
+
expect(@session).to have_css("p", :between => 1..4)
|
33
|
+
expect(@session).to have_css("p a#foo", :between => 1..3)
|
34
|
+
expect(@session).to have_css("p a.doesnotexist", :between => 0..8)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should be false if the content occurs more or fewer times than range" do
|
38
|
-
@session.
|
39
|
-
@session.
|
40
|
-
@session.
|
38
|
+
expect(@session).not_to have_css("p", :between => 6..11 )
|
39
|
+
expect(@session).not_to have_css("p a#foo", :between => 4..7)
|
40
|
+
expect(@session).not_to have_css("p a.doesnotexist", :between => 3..8)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
context "with count" do
|
45
45
|
it "should be true if the content occurs the given number of times" do
|
46
|
-
@session.
|
47
|
-
@session.
|
48
|
-
@session.
|
46
|
+
expect(@session).to have_css("p", :count => 3)
|
47
|
+
expect(@session).to have_css("p a#foo", :count => 1)
|
48
|
+
expect(@session).to have_css("p a.doesnotexist", :count => 0)
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should be false if the content occurs a different number of times than the given" do
|
52
|
-
@session.
|
53
|
-
@session.
|
54
|
-
@session.
|
52
|
+
expect(@session).not_to have_css("p", :count => 6)
|
53
|
+
expect(@session).not_to have_css("p a#foo", :count => 2)
|
54
|
+
expect(@session).not_to have_css("p a.doesnotexist", :count => 1)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should coerce count to an integer" do
|
58
|
-
@session.
|
59
|
-
@session.
|
58
|
+
expect(@session).to have_css("p", :count => "3")
|
59
|
+
expect(@session).to have_css("p a#foo", :count => "1")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context "with maximum" do
|
64
64
|
it "should be true when content occurs same or fewer times than given" do
|
65
|
-
@session.
|
66
|
-
@session.
|
67
|
-
@session.
|
68
|
-
@session.
|
65
|
+
expect(@session).to have_css("h2.head", :maximum => 5) # edge case
|
66
|
+
expect(@session).to have_css("h2", :maximum => 10)
|
67
|
+
expect(@session).to have_css("p a.doesnotexist", :maximum => 1)
|
68
|
+
expect(@session).to have_css("p a.doesnotexist", :maximum => 0)
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should be false when content occurs more times than given" do
|
72
|
-
@session.
|
73
|
-
@session.
|
74
|
-
@session.
|
72
|
+
expect(@session).not_to have_css("h2.head", :maximum => 4) # edge case
|
73
|
+
expect(@session).not_to have_css("h2", :maximum => 3)
|
74
|
+
expect(@session).not_to have_css("p", :maximum => 1)
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should coerce maximum to an integer" do
|
78
|
-
@session.
|
79
|
-
@session.
|
78
|
+
expect(@session).to have_css("h2.head", :maximum => "5") # edge case
|
79
|
+
expect(@session).to have_css("h2", :maximum => "10")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
context "with minimum" do
|
84
84
|
it "should be true when content occurs same or more times than given" do
|
85
|
-
@session.
|
86
|
-
@session.
|
87
|
-
@session.
|
85
|
+
expect(@session).to have_css("h2.head", :minimum => 5) # edge case
|
86
|
+
expect(@session).to have_css("h2", :minimum => 3)
|
87
|
+
expect(@session).to have_css("p a.doesnotexist", :minimum => 0)
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should be false when content occurs fewer times than given" do
|
91
|
-
@session.
|
92
|
-
@session.
|
93
|
-
@session.
|
94
|
-
@session.
|
91
|
+
expect(@session).not_to have_css("h2.head", :minimum => 6) # edge case
|
92
|
+
expect(@session).not_to have_css("h2", :minimum => 8)
|
93
|
+
expect(@session).not_to have_css("p", :minimum => 10)
|
94
|
+
expect(@session).not_to have_css("p a.doesnotexist", :minimum => 1)
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should coerce minimum to an integer" do
|
98
|
-
@session.
|
99
|
-
@session.
|
98
|
+
expect(@session).to have_css("h2.head", :minimum => "5") # edge case
|
99
|
+
expect(@session).to have_css("h2", :minimum => "3")
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
context "with text" do
|
104
104
|
it "should discard all matches where the given string is not contained" do
|
105
|
-
@session.
|
106
|
-
@session.
|
105
|
+
expect(@session).to have_css("p a", :text => "Redirect", :count => 1)
|
106
|
+
expect(@session).not_to have_css("p a", :text => "Doesnotexist")
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should discard all matches where the given regexp is not matched" do
|
110
|
-
@session.
|
111
|
-
@session.
|
110
|
+
expect(@session).to have_css("p a", :text => /re[dab]i/i, :count => 1)
|
111
|
+
expect(@session).not_to have_css("p a", :text => /Red$/)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -119,110 +119,110 @@ Capybara::SpecHelper.spec '#has_no_css?' do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should be false if the given selector is on the page" do
|
122
|
-
@session.
|
123
|
-
@session.
|
122
|
+
expect(@session).not_to have_no_css("p")
|
123
|
+
expect(@session).not_to have_no_css("p a#foo")
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should be true if the given selector is not on the page" do
|
127
|
-
@session.
|
128
|
-
@session.
|
129
|
-
@session.
|
127
|
+
expect(@session).to have_no_css("abbr")
|
128
|
+
expect(@session).to have_no_css("p a#doesnotexist")
|
129
|
+
expect(@session).to have_no_css("p.nosuchclass")
|
130
130
|
end
|
131
131
|
|
132
132
|
it "should respect scopes" do
|
133
133
|
@session.within "//p[@id='first']" do
|
134
|
-
@session.
|
135
|
-
@session.
|
134
|
+
expect(@session).not_to have_no_css("a#foo")
|
135
|
+
expect(@session).to have_no_css("a#red")
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
139
|
it "should wait for content to disappear", :requires => [:js] do
|
140
140
|
@session.visit('/with_js')
|
141
141
|
@session.click_link('Click me')
|
142
|
-
@session.
|
142
|
+
expect(@session).to have_no_css("p#change")
|
143
143
|
end
|
144
144
|
|
145
145
|
context "with between" do
|
146
146
|
it "should be false if the content occurs within the range given" do
|
147
|
-
@session.
|
148
|
-
@session.
|
149
|
-
@session.
|
147
|
+
expect(@session).not_to have_no_css("p", :between => 1..4)
|
148
|
+
expect(@session).not_to have_no_css("p a#foo", :between => 1..3)
|
149
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", :between => 0..2)
|
150
150
|
end
|
151
151
|
|
152
152
|
it "should be true if the content occurs more or fewer times than range" do
|
153
|
-
@session.
|
154
|
-
@session.
|
155
|
-
@session.
|
153
|
+
expect(@session).to have_no_css("p", :between => 6..11 )
|
154
|
+
expect(@session).to have_no_css("p a#foo", :between => 4..7)
|
155
|
+
expect(@session).to have_no_css("p a.doesnotexist", :between => 3..8)
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
159
|
context "with count" do
|
160
160
|
it "should be false if the content is on the page the given number of times" do
|
161
|
-
@session.
|
162
|
-
@session.
|
163
|
-
@session.
|
161
|
+
expect(@session).not_to have_no_css("p", :count => 3)
|
162
|
+
expect(@session).not_to have_no_css("p a#foo", :count => 1)
|
163
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", :count => 0)
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should be true if the content is on the page the given number of times" do
|
167
|
-
@session.
|
168
|
-
@session.
|
169
|
-
@session.
|
167
|
+
expect(@session).to have_no_css("p", :count => 6)
|
168
|
+
expect(@session).to have_no_css("p a#foo", :count => 2)
|
169
|
+
expect(@session).to have_no_css("p a.doesnotexist", :count => 1)
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should coerce count to an integer" do
|
173
|
-
@session.
|
174
|
-
@session.
|
173
|
+
expect(@session).not_to have_no_css("p", :count => "3")
|
174
|
+
expect(@session).not_to have_no_css("p a#foo", :count => "1")
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
context "with maximum" do
|
179
179
|
it "should be false when content occurs same or fewer times than given" do
|
180
|
-
@session.
|
181
|
-
@session.
|
182
|
-
@session.
|
180
|
+
expect(@session).not_to have_no_css("h2.head", :maximum => 5) # edge case
|
181
|
+
expect(@session).not_to have_no_css("h2", :maximum => 10)
|
182
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", :maximum => 0)
|
183
183
|
end
|
184
184
|
|
185
185
|
it "should be true when content occurs more times than given" do
|
186
|
-
@session.
|
187
|
-
@session.
|
188
|
-
@session.
|
186
|
+
expect(@session).to have_no_css("h2.head", :maximum => 4) # edge case
|
187
|
+
expect(@session).to have_no_css("h2", :maximum => 3)
|
188
|
+
expect(@session).to have_no_css("p", :maximum => 1)
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should coerce maximum to an integer" do
|
192
|
-
@session.
|
193
|
-
@session.
|
192
|
+
expect(@session).not_to have_no_css("h2.head", :maximum => "5") # edge case
|
193
|
+
expect(@session).not_to have_no_css("h2", :maximum => "10")
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
context "with minimum" do
|
198
198
|
it "should be false when content occurs same or more times than given" do
|
199
|
-
@session.
|
200
|
-
@session.
|
201
|
-
@session.
|
199
|
+
expect(@session).not_to have_no_css("h2.head", :minimum => 5) # edge case
|
200
|
+
expect(@session).not_to have_no_css("h2", :minimum => 3)
|
201
|
+
expect(@session).not_to have_no_css("p a.doesnotexist", :minimum => 0)
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should be true when content occurs fewer times than given" do
|
205
|
-
@session.
|
206
|
-
@session.
|
207
|
-
@session.
|
208
|
-
@session.
|
205
|
+
expect(@session).to have_no_css("h2.head", :minimum => 6) # edge case
|
206
|
+
expect(@session).to have_no_css("h2", :minimum => 8)
|
207
|
+
expect(@session).to have_no_css("p", :minimum => 15)
|
208
|
+
expect(@session).to have_no_css("p a.doesnotexist", :minimum => 1)
|
209
209
|
end
|
210
210
|
|
211
211
|
it "should coerce minimum to an integer" do
|
212
|
-
@session.
|
213
|
-
@session.
|
212
|
+
expect(@session).not_to have_no_css("h2.head", :minimum => "4") # edge case
|
213
|
+
expect(@session).not_to have_no_css("h2", :minimum => "3")
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
217
217
|
context "with text" do
|
218
218
|
it "should discard all matches where the given string is not contained" do
|
219
|
-
@session.
|
220
|
-
@session.
|
219
|
+
expect(@session).not_to have_no_css("p a", :text => "Redirect", :count => 1)
|
220
|
+
expect(@session).to have_no_css("p a", :text => "Doesnotexist")
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should discard all matches where the given regexp is not matched" do
|
224
|
-
@session.
|
225
|
-
@session.
|
224
|
+
expect(@session).not_to have_no_css("p a", :text => /re[dab]i/i, :count => 1)
|
225
|
+
expect(@session).to have_no_css("p a", :text => /Red$/)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
end
|
@@ -2,56 +2,56 @@ Capybara::SpecHelper.spec '#has_field' do
|
|
2
2
|
before { @session.visit('/form') }
|
3
3
|
|
4
4
|
it "should be true if the field is on the page" do
|
5
|
-
@session.
|
6
|
-
@session.
|
7
|
-
@session.
|
8
|
-
@session.
|
5
|
+
expect(@session).to have_field('Dog')
|
6
|
+
expect(@session).to have_field('form_description')
|
7
|
+
expect(@session).to have_field('Region')
|
8
|
+
expect(@session).to have_field(:'Region')
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should be false if the field is not on the page" do
|
12
|
-
@session.
|
12
|
+
expect(@session).not_to have_field('Monkey')
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with value' do
|
16
16
|
it "should be true if a field with the given value is on the page" do
|
17
|
-
@session.
|
18
|
-
@session.
|
19
|
-
@session.
|
20
|
-
@session.
|
17
|
+
expect(@session).to have_field('First Name', :with => 'John')
|
18
|
+
expect(@session).to have_field('Phone', :with => '+1 555 7021')
|
19
|
+
expect(@session).to have_field('Street', :with => 'Sesame street 66')
|
20
|
+
expect(@session).to have_field('Description', :with => 'Descriptive text goes here')
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should be false if the given field is not on the page" do
|
24
|
-
@session.
|
25
|
-
@session.
|
26
|
-
@session.
|
24
|
+
expect(@session).not_to have_field('First Name', :with => 'Peter')
|
25
|
+
expect(@session).not_to have_field('Wrong Name', :with => 'John')
|
26
|
+
expect(@session).not_to have_field('Description', :with => 'Monkey')
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should be true after the field has been filled in with the given value" do
|
30
30
|
@session.fill_in('First Name', :with => 'Jonas')
|
31
|
-
@session.
|
31
|
+
expect(@session).to have_field('First Name', :with => 'Jonas')
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should be false after the field has been filled in with a different value" do
|
35
35
|
@session.fill_in('First Name', :with => 'Jonas')
|
36
|
-
@session.
|
36
|
+
expect(@session).not_to have_field('First Name', :with => 'John')
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'with type' do
|
41
41
|
it "should be true if a field with the given type is on the page" do
|
42
|
-
@session.
|
43
|
-
@session.
|
44
|
-
@session.
|
45
|
-
@session.
|
46
|
-
@session.
|
42
|
+
expect(@session).to have_field('First Name', :type => 'text')
|
43
|
+
expect(@session).to have_field('Html5 Email', :type => 'email')
|
44
|
+
expect(@session).to have_field('Html5 Tel', :type => 'tel')
|
45
|
+
expect(@session).to have_field('Description', :type => 'textarea')
|
46
|
+
expect(@session).to have_field('Languages', :type => 'select')
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should be false if the given field is not on the page" do
|
50
|
-
@session.
|
51
|
-
@session.
|
52
|
-
@session.
|
53
|
-
@session.
|
54
|
-
@session.
|
50
|
+
expect(@session).not_to have_field('First Name', :type => 'textarea')
|
51
|
+
expect(@session).not_to have_field('Html5 Email', :type => 'tel')
|
52
|
+
expect(@session).not_to have_field('Description', :type => '')
|
53
|
+
expect(@session).not_to have_field('Description', :type => 'email')
|
54
|
+
expect(@session).not_to have_field('Languages', :type => 'textarea')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -60,55 +60,55 @@ Capybara::SpecHelper.spec '#has_no_field' do
|
|
60
60
|
before { @session.visit('/form') }
|
61
61
|
|
62
62
|
it "should be false if the field is on the page" do
|
63
|
-
@session.
|
64
|
-
@session.
|
65
|
-
@session.
|
63
|
+
expect(@session).not_to have_no_field('Dog')
|
64
|
+
expect(@session).not_to have_no_field('form_description')
|
65
|
+
expect(@session).not_to have_no_field('Region')
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should be true if the field is not on the page" do
|
69
|
-
@session.
|
69
|
+
expect(@session).to have_no_field('Monkey')
|
70
70
|
end
|
71
71
|
|
72
72
|
context 'with value' do
|
73
73
|
it "should be false if a field with the given value is on the page" do
|
74
|
-
@session.
|
75
|
-
@session.
|
76
|
-
@session.
|
77
|
-
@session.
|
74
|
+
expect(@session).not_to have_no_field('First Name', :with => 'John')
|
75
|
+
expect(@session).not_to have_no_field('Phone', :with => '+1 555 7021')
|
76
|
+
expect(@session).not_to have_no_field('Street', :with => 'Sesame street 66')
|
77
|
+
expect(@session).not_to have_no_field('Description', :with => 'Descriptive text goes here')
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should be true if the given field is not on the page" do
|
81
|
-
@session.
|
82
|
-
@session.
|
83
|
-
@session.
|
81
|
+
expect(@session).to have_no_field('First Name', :with => 'Peter')
|
82
|
+
expect(@session).to have_no_field('Wrong Name', :with => 'John')
|
83
|
+
expect(@session).to have_no_field('Description', :with => 'Monkey')
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should be false after the field has been filled in with the given value" do
|
87
87
|
@session.fill_in('First Name', :with => 'Jonas')
|
88
|
-
@session.
|
88
|
+
expect(@session).not_to have_no_field('First Name', :with => 'Jonas')
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should be true after the field has been filled in with a different value" do
|
92
92
|
@session.fill_in('First Name', :with => 'Jonas')
|
93
|
-
@session.
|
93
|
+
expect(@session).to have_no_field('First Name', :with => 'John')
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
context 'with type' do
|
98
98
|
it "should be false if a field with the given type is on the page" do
|
99
|
-
@session.
|
100
|
-
@session.
|
101
|
-
@session.
|
102
|
-
@session.
|
103
|
-
@session.
|
99
|
+
expect(@session).not_to have_no_field('First Name', :type => 'text')
|
100
|
+
expect(@session).not_to have_no_field('Html5 Email', :type => 'email')
|
101
|
+
expect(@session).not_to have_no_field('Html5 Tel', :type => 'tel')
|
102
|
+
expect(@session).not_to have_no_field('Description', :type => 'textarea')
|
103
|
+
expect(@session).not_to have_no_field('Languages', :type => 'select')
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should be true if the given field is not on the page" do
|
107
|
-
@session.
|
108
|
-
@session.
|
109
|
-
@session.
|
110
|
-
@session.
|
111
|
-
@session.
|
107
|
+
expect(@session).to have_no_field('First Name', :type => 'textarea')
|
108
|
+
expect(@session).to have_no_field('Html5 Email', :type => 'tel')
|
109
|
+
expect(@session).to have_no_field('Description', :type => '')
|
110
|
+
expect(@session).to have_no_field('Description', :type => 'email')
|
111
|
+
expect(@session).to have_no_field('Languages', :type => 'textarea')
|
112
112
|
end
|
113
113
|
end
|
114
114
|
end
|
@@ -117,49 +117,49 @@ Capybara::SpecHelper.spec '#has_checked_field?' do
|
|
117
117
|
before { @session.visit('/form') }
|
118
118
|
|
119
119
|
it "should be true if a checked field is on the page" do
|
120
|
-
@session.
|
121
|
-
@session.
|
120
|
+
expect(@session).to have_checked_field('gender_female')
|
121
|
+
expect(@session).to have_checked_field('Hamster')
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should be true for disabled checkboxes if :disabled => true" do
|
125
|
-
@session.
|
125
|
+
expect(@session).to have_checked_field('Disabled Checkbox', :disabled => true)
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should be false if an unchecked field is on the page" do
|
129
|
-
@session.
|
130
|
-
@session.
|
129
|
+
expect(@session).not_to have_checked_field('form_pets_cat')
|
130
|
+
expect(@session).not_to have_checked_field('Male')
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should be false if no field is on the page" do
|
134
|
-
@session.
|
134
|
+
expect(@session).not_to have_checked_field('Does Not Exist')
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should be false for disabled checkboxes by default" do
|
138
|
-
@session.
|
138
|
+
expect(@session).not_to have_checked_field('Disabled Checkbox')
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should be false for disabled checkboxes if :disabled => false" do
|
142
|
-
@session.
|
142
|
+
expect(@session).not_to have_checked_field('Disabled Checkbox', :disabled => false)
|
143
143
|
end
|
144
144
|
|
145
145
|
it "should be true after an unchecked checkbox is checked" do
|
146
146
|
@session.check('form_pets_cat')
|
147
|
-
@session.
|
147
|
+
expect(@session).to have_checked_field('form_pets_cat')
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should be false after a checked checkbox is unchecked" do
|
151
151
|
@session.uncheck('form_pets_dog')
|
152
|
-
@session.
|
152
|
+
expect(@session).not_to have_checked_field('form_pets_dog')
|
153
153
|
end
|
154
154
|
|
155
155
|
it "should be true after an unchecked radio button is chosen" do
|
156
156
|
@session.choose('gender_male')
|
157
|
-
@session.
|
157
|
+
expect(@session).to have_checked_field('gender_male')
|
158
158
|
end
|
159
159
|
|
160
160
|
it "should be false after another radio button in the group is chosen" do
|
161
161
|
@session.choose('gender_male')
|
162
|
-
@session.
|
162
|
+
expect(@session).not_to have_checked_field('gender_female')
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
@@ -167,29 +167,29 @@ Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
|
167
167
|
before { @session.visit('/form') }
|
168
168
|
|
169
169
|
it "should be false if a checked field is on the page" do
|
170
|
-
@session.
|
171
|
-
@session.
|
170
|
+
expect(@session).not_to have_no_checked_field('gender_female')
|
171
|
+
expect(@session).not_to have_no_checked_field('Hamster')
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should be false for disabled checkboxes if :disabled => true" do
|
175
|
-
@session.
|
175
|
+
expect(@session).not_to have_no_checked_field('Disabled Checkbox', :disabled => true)
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should be true if an unchecked field is on the page" do
|
179
|
-
@session.
|
180
|
-
@session.
|
179
|
+
expect(@session).to have_no_checked_field('form_pets_cat')
|
180
|
+
expect(@session).to have_no_checked_field('Male')
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should be true if no field is on the page" do
|
184
|
-
@session.
|
184
|
+
expect(@session).to have_no_checked_field('Does Not Exist')
|
185
185
|
end
|
186
186
|
|
187
187
|
it "should be true for disabled checkboxes by default" do
|
188
|
-
@session.
|
188
|
+
expect(@session).to have_no_checked_field('Disabled Checkbox')
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should be true for disabled checkboxes if :disabled => false" do
|
192
|
-
@session.
|
192
|
+
expect(@session).to have_no_checked_field('Disabled Checkbox', :disabled => false)
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
@@ -197,49 +197,49 @@ Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
|
197
197
|
before { @session.visit('/form') }
|
198
198
|
|
199
199
|
it "should be false if a checked field is on the page" do
|
200
|
-
@session.
|
201
|
-
@session.
|
200
|
+
expect(@session).not_to have_unchecked_field('gender_female')
|
201
|
+
expect(@session).not_to have_unchecked_field('Hamster')
|
202
202
|
end
|
203
203
|
|
204
204
|
it "should be true if an unchecked field is on the page" do
|
205
|
-
@session.
|
206
|
-
@session.
|
205
|
+
expect(@session).to have_unchecked_field('form_pets_cat')
|
206
|
+
expect(@session).to have_unchecked_field('Male')
|
207
207
|
end
|
208
208
|
|
209
209
|
it "should be true for disabled unchecked fields if :disabled => true" do
|
210
|
-
@session.
|
210
|
+
expect(@session).to have_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
|
211
211
|
end
|
212
212
|
|
213
213
|
it "should be false if no field is on the page" do
|
214
|
-
@session.
|
214
|
+
expect(@session).not_to have_unchecked_field('Does Not Exist')
|
215
215
|
end
|
216
216
|
|
217
217
|
it "should be false for disabled unchecked fields by default" do
|
218
|
-
@session.
|
218
|
+
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox')
|
219
219
|
end
|
220
220
|
|
221
221
|
it "should be false for disabled unchecked fields if :disabled => false" do
|
222
|
-
@session.
|
222
|
+
expect(@session).not_to have_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should be false after an unchecked checkbox is checked" do
|
226
226
|
@session.check('form_pets_cat')
|
227
|
-
@session.
|
227
|
+
expect(@session).not_to have_unchecked_field('form_pets_cat')
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should be true after a checked checkbox is unchecked" do
|
231
231
|
@session.uncheck('form_pets_dog')
|
232
|
-
@session.
|
232
|
+
expect(@session).to have_unchecked_field('form_pets_dog')
|
233
233
|
end
|
234
234
|
|
235
235
|
it "should be false after an unchecked radio button is chosen" do
|
236
236
|
@session.choose('gender_male')
|
237
|
-
@session.
|
237
|
+
expect(@session).not_to have_unchecked_field('gender_male')
|
238
238
|
end
|
239
239
|
|
240
240
|
it "should be true after another radio button in the group is chosen" do
|
241
241
|
@session.choose('gender_male')
|
242
|
-
@session.
|
242
|
+
expect(@session).to have_unchecked_field('gender_female')
|
243
243
|
end
|
244
244
|
end
|
245
245
|
|
@@ -247,28 +247,28 @@ Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
|
247
247
|
before { @session.visit('/form') }
|
248
248
|
|
249
249
|
it "should be true if a checked field is on the page" do
|
250
|
-
@session.
|
251
|
-
@session.
|
250
|
+
expect(@session).to have_no_unchecked_field('gender_female')
|
251
|
+
expect(@session).to have_no_unchecked_field('Hamster')
|
252
252
|
end
|
253
253
|
|
254
254
|
it "should be false if an unchecked field is on the page" do
|
255
|
-
@session.
|
256
|
-
@session.
|
255
|
+
expect(@session).not_to have_no_unchecked_field('form_pets_cat')
|
256
|
+
expect(@session).not_to have_no_unchecked_field('Male')
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should be false for disabled unchecked fields if :disabled => true" do
|
260
|
-
@session.
|
260
|
+
expect(@session).not_to have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => true)
|
261
261
|
end
|
262
262
|
|
263
263
|
it "should be true if no field is on the page" do
|
264
|
-
@session.
|
264
|
+
expect(@session).to have_no_unchecked_field('Does Not Exist')
|
265
265
|
end
|
266
266
|
|
267
267
|
it "should be true for disabled unchecked fields by default" do
|
268
|
-
@session.
|
268
|
+
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox')
|
269
269
|
end
|
270
270
|
|
271
271
|
it "should be true for disabled unchecked fields if :disabled => false" do
|
272
|
-
@session.
|
272
|
+
expect(@session).to have_no_unchecked_field('Disabled Unchecked Checkbox', :disabled => false)
|
273
273
|
end
|
274
274
|
end
|