capybara 2.0.0.beta2 → 2.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +30 -1
- data/README.md +52 -31
- data/lib/capybara.rb +1 -0
- data/lib/capybara/driver/base.rb +1 -1
- data/lib/capybara/driver/node.rb +1 -0
- data/lib/capybara/dsl.rb +12 -5
- data/lib/capybara/helpers.rb +33 -0
- data/lib/capybara/node/actions.rb +4 -2
- data/lib/capybara/node/base.rb +52 -1
- data/lib/capybara/node/element.rb +0 -12
- data/lib/capybara/node/finders.rb +1 -1
- data/lib/capybara/node/matchers.rb +57 -47
- data/lib/capybara/node/simple.rb +4 -0
- data/lib/capybara/query.rb +11 -11
- data/lib/capybara/rack_test/browser.rb +14 -15
- data/lib/capybara/rack_test/driver.rb +2 -2
- data/lib/capybara/rack_test/node.rb +15 -2
- data/lib/capybara/result.rb +7 -19
- data/lib/capybara/rspec.rb +7 -4
- data/lib/capybara/rspec/features.rb +4 -1
- data/lib/capybara/rspec/matchers.rb +8 -3
- data/lib/capybara/selector.rb +1 -2
- data/lib/capybara/selenium/driver.rb +2 -2
- data/lib/capybara/selenium/node.rb +9 -7
- data/lib/capybara/session.rb +47 -31
- data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
- data/lib/capybara/spec/public/test.js +1 -1
- data/lib/capybara/spec/session/all_spec.rb +60 -62
- data/lib/capybara/spec/session/assert_selector.rb +123 -0
- data/lib/capybara/spec/session/attach_file_spec.rb +72 -58
- data/lib/capybara/spec/session/body_spec.rb +21 -0
- data/lib/capybara/spec/session/check_spec.rb +67 -50
- data/lib/capybara/spec/session/choose_spec.rb +32 -21
- data/lib/capybara/spec/session/click_button_spec.rb +261 -221
- data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -30
- data/lib/capybara/spec/session/click_link_spec.rb +95 -81
- data/lib/capybara/spec/session/current_url_spec.rb +70 -60
- data/lib/capybara/spec/session/evaluate_script_spec.rb +6 -0
- data/lib/capybara/spec/session/execute_script_spec.rb +7 -0
- data/lib/capybara/spec/session/fill_in_spec.rb +118 -92
- data/lib/capybara/spec/session/find_button_spec.rb +16 -14
- data/lib/capybara/spec/session/find_by_id_spec.rb +16 -14
- data/lib/capybara/spec/session/find_field_spec.rb +23 -21
- data/lib/capybara/spec/session/find_link_spec.rb +15 -14
- data/lib/capybara/spec/session/find_spec.rb +96 -91
- data/lib/capybara/spec/session/first_spec.rb +53 -55
- data/lib/capybara/spec/session/has_button_spec.rb +22 -24
- data/lib/capybara/spec/session/has_css_spec.rb +190 -205
- data/lib/capybara/spec/session/has_field_spec.rb +167 -169
- data/lib/capybara/spec/session/has_link_spec.rb +26 -29
- data/lib/capybara/spec/session/has_select_spec.rb +175 -176
- data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
- data/lib/capybara/spec/session/has_table_spec.rb +22 -26
- data/lib/capybara/spec/session/has_text_spec.rb +159 -132
- data/lib/capybara/spec/session/has_xpath_spec.rb +100 -96
- data/lib/capybara/spec/session/headers.rb +4 -17
- data/lib/capybara/spec/session/html_spec.rb +15 -0
- data/lib/capybara/spec/session/node_spec.rb +172 -82
- data/lib/capybara/spec/session/reset_session_spec.rb +42 -0
- data/lib/capybara/spec/session/response_code.rb +4 -17
- data/lib/capybara/spec/session/save_page_spec.rb +46 -0
- data/lib/capybara/spec/session/screenshot.rb +8 -24
- data/lib/capybara/spec/session/select_spec.rb +100 -89
- data/lib/capybara/spec/session/source_spec.rb +12 -0
- data/lib/capybara/spec/session/text_spec.rb +15 -17
- data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
- data/lib/capybara/spec/session/unselect_spec.rb +57 -52
- data/lib/capybara/spec/session/visit_spec.rb +58 -60
- data/lib/capybara/spec/session/within_frame_spec.rb +24 -26
- data/lib/capybara/spec/session/within_spec.rb +119 -121
- data/lib/capybara/spec/session/within_window_spec.rb +29 -31
- data/lib/capybara/spec/spec_helper.rb +84 -0
- data/lib/capybara/spec/test_app.rb +5 -3
- data/lib/capybara/spec/views/form.erb +1 -0
- data/lib/capybara/spec/views/with_html.erb +6 -1
- data/lib/capybara/spec/views/with_js.erb +1 -0
- data/lib/capybara/version.rb +1 -1
- data/spec/basic_node_spec.rb +2 -2
- data/spec/capybara_spec.rb +9 -0
- data/spec/dsl_spec.rb +22 -10
- data/spec/rack_test_spec.rb +28 -23
- data/spec/result_spec.rb +51 -0
- data/spec/rspec/features_spec.rb +19 -0
- data/spec/rspec/matchers_spec.rb +6 -0
- data/spec/rspec_spec.rb +1 -1
- data/spec/selenium_spec.rb +11 -25
- data/spec/server_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -46
- metadata +41 -98
- data/lib/capybara/spec/session.rb +0 -183
- data/lib/capybara/spec/session/javascript.rb +0 -290
- data/lib/capybara/util/save_and_open_page.rb +0 -45
- data/spec/save_and_open_page_spec.rb +0 -155
@@ -1,220 +1,218 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
Capybara::SpecHelper.spec '#has_field' do
|
2
|
+
before { @session.visit('/form') }
|
3
|
+
|
4
|
+
it "should be true if the field is on the page" do
|
5
|
+
@session.should have_field('Dog')
|
6
|
+
@session.should have_field('form_description')
|
7
|
+
@session.should have_field('Region')
|
8
|
+
@session.should have_field(:'Region')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_field('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with value' do
|
16
|
+
it "should be true if a field with the given value is on the page" do
|
17
|
+
@session.should have_field('First Name', :with => 'John')
|
18
|
+
@session.should have_field('Phone', :with => '+1 555 7021')
|
19
|
+
@session.should have_field('Street', :with => 'Sesame street 66')
|
20
|
+
@session.should have_field('Description', :with => 'Descriptive text goes here')
|
9
21
|
end
|
10
22
|
|
11
|
-
it "should be false if the field is not on the page" do
|
12
|
-
@session.should_not have_field('
|
23
|
+
it "should be false if the given field is not on the page" do
|
24
|
+
@session.should_not have_field('First Name', :with => 'Peter')
|
25
|
+
@session.should_not have_field('Wrong Name', :with => 'John')
|
26
|
+
@session.should_not have_field('Description', :with => 'Monkey')
|
13
27
|
end
|
14
28
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@session.should have_field('Phone', :with => '+1 555 7021')
|
19
|
-
@session.should have_field('Street', :with => 'Sesame street 66')
|
20
|
-
@session.should have_field('Description', :with => 'Descriptive text goes here')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be false if the given field is not on the page" do
|
24
|
-
@session.should_not have_field('First Name', :with => 'Peter')
|
25
|
-
@session.should_not have_field('Wrong Name', :with => 'John')
|
26
|
-
@session.should_not have_field('Description', :with => 'Monkey')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should be true after the field has been filled in with the given value" do
|
30
|
-
@session.fill_in('First Name', :with => 'Jonas')
|
31
|
-
@session.should have_field('First Name', :with => 'Jonas')
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be false after the field has been filled in with a different value" do
|
35
|
-
@session.fill_in('First Name', :with => 'Jonas')
|
36
|
-
@session.should_not have_field('First Name', :with => 'John')
|
37
|
-
end
|
29
|
+
it "should be true after the field has been filled in with the given value" do
|
30
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
31
|
+
@session.should have_field('First Name', :with => 'Jonas')
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@session.should have_field('Html5 Email', :type => 'email')
|
44
|
-
@session.should have_field('Html5 Tel', :type => 'tel')
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should be false if the given field is not on the page" do
|
48
|
-
@session.should_not have_field('First Name', :type => 'email')
|
49
|
-
@session.should_not have_field('Html5 Email', :type => 'tel')
|
50
|
-
@session.should_not have_field('Description', :type => '')
|
51
|
-
end
|
34
|
+
it "should be false after the field has been filled in with a different value" do
|
35
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
36
|
+
@session.should_not have_field('First Name', :with => 'John')
|
52
37
|
end
|
53
38
|
end
|
54
39
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@session.
|
60
|
-
@session.should_not have_no_field('form_description')
|
61
|
-
@session.should_not have_no_field('Region')
|
40
|
+
context 'with type' do
|
41
|
+
it "should be true if a field with the given type is on the page" do
|
42
|
+
@session.should have_field('First Name', :type => 'text')
|
43
|
+
@session.should have_field('Html5 Email', :type => 'email')
|
44
|
+
@session.should have_field('Html5 Tel', :type => 'tel')
|
62
45
|
end
|
63
46
|
|
64
|
-
it "should be
|
65
|
-
@session.
|
47
|
+
it "should be false if the given field is not on the page" do
|
48
|
+
@session.should_not have_field('First Name', :type => 'email')
|
49
|
+
@session.should_not have_field('Html5 Email', :type => 'tel')
|
50
|
+
@session.should_not have_field('Description', :type => '')
|
66
51
|
end
|
52
|
+
end
|
53
|
+
end
|
67
54
|
|
68
|
-
|
69
|
-
|
70
|
-
@session.should_not have_no_field('First Name', :with => 'John')
|
71
|
-
@session.should_not have_no_field('Phone', :with => '+1 555 7021')
|
72
|
-
@session.should_not have_no_field('Street', :with => 'Sesame street 66')
|
73
|
-
@session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should be true if the given field is not on the page" do
|
77
|
-
@session.should have_no_field('First Name', :with => 'Peter')
|
78
|
-
@session.should have_no_field('Wrong Name', :with => 'John')
|
79
|
-
@session.should have_no_field('Description', :with => 'Monkey')
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should be false after the field has been filled in with the given value" do
|
83
|
-
@session.fill_in('First Name', :with => 'Jonas')
|
84
|
-
@session.should_not have_no_field('First Name', :with => 'Jonas')
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should be true after the field has been filled in with a different value" do
|
88
|
-
@session.fill_in('First Name', :with => 'Jonas')
|
89
|
-
@session.should have_no_field('First Name', :with => 'John')
|
90
|
-
end
|
91
|
-
end
|
55
|
+
Capybara::SpecHelper.spec '#has_no_field' do
|
56
|
+
before { @session.visit('/form') }
|
92
57
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@session.should_not have_no_field('Html5 Tel', :type => 'tel')
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should be true if the given field is not on the page" do
|
101
|
-
@session.should have_no_field('First Name', :type => 'email')
|
102
|
-
@session.should have_no_field('Html5 Email', :type => 'tel')
|
103
|
-
@session.should have_no_field('Description', :type => '')
|
104
|
-
end
|
105
|
-
end
|
58
|
+
it "should be false if the field is on the page" do
|
59
|
+
@session.should_not have_no_field('Dog')
|
60
|
+
@session.should_not have_no_field('form_description')
|
61
|
+
@session.should_not have_no_field('Region')
|
106
62
|
end
|
107
63
|
|
108
|
-
|
109
|
-
|
64
|
+
it "should be true if the field is not on the page" do
|
65
|
+
@session.should have_no_field('Monkey')
|
66
|
+
end
|
110
67
|
|
111
|
-
|
112
|
-
|
113
|
-
@session.
|
68
|
+
context 'with value' do
|
69
|
+
it "should be false if a field with the given value is on the page" do
|
70
|
+
@session.should_not have_no_field('First Name', :with => 'John')
|
71
|
+
@session.should_not have_no_field('Phone', :with => '+1 555 7021')
|
72
|
+
@session.should_not have_no_field('Street', :with => 'Sesame street 66')
|
73
|
+
@session.should_not have_no_field('Description', :with => 'Descriptive text goes here')
|
114
74
|
end
|
115
75
|
|
116
|
-
it "should be
|
117
|
-
@session.
|
118
|
-
@session.
|
76
|
+
it "should be true if the given field is not on the page" do
|
77
|
+
@session.should have_no_field('First Name', :with => 'Peter')
|
78
|
+
@session.should have_no_field('Wrong Name', :with => 'John')
|
79
|
+
@session.should have_no_field('Description', :with => 'Monkey')
|
119
80
|
end
|
120
81
|
|
121
|
-
it "should be false
|
122
|
-
@session.
|
82
|
+
it "should be false after the field has been filled in with the given value" do
|
83
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
84
|
+
@session.should_not have_no_field('First Name', :with => 'Jonas')
|
123
85
|
end
|
124
86
|
|
125
|
-
it "should be true after
|
126
|
-
@session.
|
127
|
-
@session.should
|
87
|
+
it "should be true after the field has been filled in with a different value" do
|
88
|
+
@session.fill_in('First Name', :with => 'Jonas')
|
89
|
+
@session.should have_no_field('First Name', :with => 'John')
|
128
90
|
end
|
91
|
+
end
|
129
92
|
|
130
|
-
|
131
|
-
|
132
|
-
@session.should_not
|
93
|
+
context 'with type' do
|
94
|
+
it "should be false if a field with the given type is on the page" do
|
95
|
+
@session.should_not have_no_field('First Name', :type => 'text')
|
96
|
+
@session.should_not have_no_field('Html5 Email', :type => 'email')
|
97
|
+
@session.should_not have_no_field('Html5 Tel', :type => 'tel')
|
133
98
|
end
|
134
99
|
|
135
|
-
it "should be true
|
136
|
-
@session.
|
137
|
-
@session.should
|
100
|
+
it "should be true if the given field is not on the page" do
|
101
|
+
@session.should have_no_field('First Name', :type => 'email')
|
102
|
+
@session.should have_no_field('Html5 Email', :type => 'tel')
|
103
|
+
@session.should have_no_field('Description', :type => '')
|
138
104
|
end
|
105
|
+
end
|
106
|
+
end
|
139
107
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
108
|
+
Capybara::SpecHelper.spec '#has_checked_field?' do
|
109
|
+
before { @session.visit('/form') }
|
110
|
+
|
111
|
+
it "should be true if a checked field is on the page" do
|
112
|
+
@session.should have_checked_field('gender_female')
|
113
|
+
@session.should have_checked_field('Hamster')
|
144
114
|
end
|
145
115
|
|
146
|
-
|
147
|
-
|
116
|
+
it "should be false if an unchecked field is on the page" do
|
117
|
+
@session.should_not have_checked_field('form_pets_cat')
|
118
|
+
@session.should_not have_checked_field('Male')
|
119
|
+
end
|
148
120
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
121
|
+
it "should be false if no field is on the page" do
|
122
|
+
@session.should_not have_checked_field('Does Not Exist')
|
123
|
+
end
|
153
124
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
125
|
+
it "should be true after an unchecked checkbox is checked" do
|
126
|
+
@session.check('form_pets_cat')
|
127
|
+
@session.should have_checked_field('form_pets_cat')
|
128
|
+
end
|
158
129
|
|
159
|
-
|
160
|
-
|
161
|
-
|
130
|
+
it "should be false after a checked checkbox is unchecked" do
|
131
|
+
@session.uncheck('form_pets_dog')
|
132
|
+
@session.should_not have_checked_field('form_pets_dog')
|
162
133
|
end
|
163
134
|
|
164
|
-
|
165
|
-
|
135
|
+
it "should be true after an unchecked radio button is chosen" do
|
136
|
+
@session.choose('gender_male')
|
137
|
+
@session.should have_checked_field('gender_male')
|
138
|
+
end
|
166
139
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
140
|
+
it "should be false after another radio button in the group is chosen" do
|
141
|
+
@session.choose('gender_male')
|
142
|
+
@session.should_not have_checked_field('gender_female')
|
143
|
+
end
|
144
|
+
end
|
171
145
|
|
172
|
-
|
173
|
-
|
174
|
-
@session.should have_unchecked_field('Male')
|
175
|
-
end
|
146
|
+
Capybara::SpecHelper.spec '#has_no_checked_field?' do
|
147
|
+
before { @session.visit('/form') }
|
176
148
|
|
177
|
-
|
178
|
-
|
179
|
-
|
149
|
+
it "should be false if a checked field is on the page" do
|
150
|
+
@session.should_not have_no_checked_field('gender_female')
|
151
|
+
@session.should_not have_no_checked_field('Hamster')
|
152
|
+
end
|
180
153
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
154
|
+
it "should be true if an unchecked field is on the page" do
|
155
|
+
@session.should have_no_checked_field('form_pets_cat')
|
156
|
+
@session.should have_no_checked_field('Male')
|
157
|
+
end
|
185
158
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
159
|
+
it "should be true if no field is on the page" do
|
160
|
+
@session.should have_no_checked_field('Does Not Exist')
|
161
|
+
end
|
162
|
+
end
|
190
163
|
|
191
|
-
|
192
|
-
|
193
|
-
@session.should_not have_unchecked_field('gender_male')
|
194
|
-
end
|
164
|
+
Capybara::SpecHelper.spec '#has_unchecked_field?' do
|
165
|
+
before { @session.visit('/form') }
|
195
166
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
end
|
167
|
+
it "should be false if a checked field is on the page" do
|
168
|
+
@session.should_not have_unchecked_field('gender_female')
|
169
|
+
@session.should_not have_unchecked_field('Hamster')
|
200
170
|
end
|
201
171
|
|
202
|
-
|
203
|
-
|
172
|
+
it "should be true if an unchecked field is on the page" do
|
173
|
+
@session.should have_unchecked_field('form_pets_cat')
|
174
|
+
@session.should have_unchecked_field('Male')
|
175
|
+
end
|
204
176
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
end
|
177
|
+
it "should be false if no field is on the page" do
|
178
|
+
@session.should_not have_unchecked_field('Does Not Exist')
|
179
|
+
end
|
209
180
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
181
|
+
it "should be false after an unchecked checkbox is checked" do
|
182
|
+
@session.check('form_pets_cat')
|
183
|
+
@session.should_not have_unchecked_field('form_pets_cat')
|
184
|
+
end
|
214
185
|
|
215
|
-
|
216
|
-
|
217
|
-
|
186
|
+
it "should be true after a checked checkbox is unchecked" do
|
187
|
+
@session.uncheck('form_pets_dog')
|
188
|
+
@session.should have_unchecked_field('form_pets_dog')
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should be false after an unchecked radio button is chosen" do
|
192
|
+
@session.choose('gender_male')
|
193
|
+
@session.should_not have_unchecked_field('gender_male')
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should be true after another radio button in the group is chosen" do
|
197
|
+
@session.choose('gender_male')
|
198
|
+
@session.should have_unchecked_field('gender_female')
|
218
199
|
end
|
219
200
|
end
|
220
201
|
|
202
|
+
Capybara::SpecHelper.spec '#has_no_unchecked_field?' do
|
203
|
+
before { @session.visit('/form') }
|
204
|
+
|
205
|
+
it "should be true if a checked field is on the page" do
|
206
|
+
@session.should have_no_unchecked_field('gender_female')
|
207
|
+
@session.should have_no_unchecked_field('Hamster')
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should be false if an unchecked field is on the page" do
|
211
|
+
@session.should_not have_no_unchecked_field('form_pets_cat')
|
212
|
+
@session.should_not have_no_unchecked_field('Male')
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should be true if no field is on the page" do
|
216
|
+
@session.should have_no_unchecked_field('Does Not Exist')
|
217
|
+
end
|
218
|
+
end
|
@@ -1,37 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
@session.visit('/with_html')
|
6
|
-
end
|
1
|
+
Capybara::SpecHelper.spec '#has_link?' do
|
2
|
+
before do
|
3
|
+
@session.visit('/with_html')
|
4
|
+
end
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
it "should be true if the given link is on the page" do
|
7
|
+
@session.should have_link('foo')
|
8
|
+
@session.should have_link('awesome title')
|
9
|
+
@session.should have_link('A link', :href => '/with_simple_html')
|
10
|
+
@session.should have_link(:'A link', :href => :'/with_simple_html')
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
13
|
+
it "should be false if the given link is not on the page" do
|
14
|
+
@session.should_not have_link('monkey')
|
15
|
+
@session.should_not have_link('A link', :href => '/non-existant-href')
|
18
16
|
end
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
Capybara::SpecHelper.spec '#has_no_link?' do
|
20
|
+
before do
|
21
|
+
@session.visit('/with_html')
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
it "should be false if the given link is on the page" do
|
25
|
+
@session.should_not have_no_link('foo')
|
26
|
+
@session.should_not have_no_link('awesome title')
|
27
|
+
@session.should_not have_no_link('A link', :href => '/with_simple_html')
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
30
|
+
it "should be true if the given link is not on the page" do
|
31
|
+
@session.should have_no_link('monkey')
|
32
|
+
@session.should have_no_link('A link', :href => '/non-existant-href')
|
35
33
|
end
|
36
34
|
end
|
37
|
-
|
@@ -1,182 +1,181 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
1
|
+
Capybara::SpecHelper.spec '#has_select?' do
|
2
|
+
before { @session.visit('/form') }
|
3
|
+
|
4
|
+
it "should be true if the field is on the page" do
|
5
|
+
@session.should have_select('Locale')
|
6
|
+
@session.should have_select('form_region')
|
7
|
+
@session.should have_select('Languages')
|
8
|
+
@session.should have_select(:'Languages')
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be false if the field is not on the page" do
|
12
|
+
@session.should_not have_select('Monkey')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with selected value' do
|
16
|
+
it "should be true if a field with the given value is on the page" do
|
17
|
+
@session.should have_select('form_locale', :selected => 'English')
|
18
|
+
@session.should have_select('Region', :selected => 'Norway')
|
19
|
+
@session.should have_select('Underwear', :selected => [
|
20
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
21
|
+
])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should be false if the given field is not on the page" do
|
25
|
+
@session.should_not have_select('Locale', :selected => 'Swedish')
|
26
|
+
@session.should_not have_select('Does not exist', :selected => 'John')
|
27
|
+
@session.should_not have_select('City', :selected => 'Not there')
|
28
|
+
@session.should_not have_select('Underwear', :selected => [
|
29
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
30
|
+
])
|
31
|
+
@session.should_not have_select('Underwear', :selected => [
|
32
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
33
|
+
])
|
34
|
+
@session.should_not have_select('Underwear', :selected => [
|
35
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
36
|
+
])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be true after the given value is selected" do
|
40
|
+
@session.select('Swedish', :from => 'Locale')
|
41
|
+
@session.should have_select('Locale', :selected => 'Swedish')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be false after a different value is selected" do
|
45
|
+
@session.select('Swedish', :from => 'Locale')
|
46
|
+
@session.should_not have_select('Locale', :selected => 'English')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be true after the given values are selected" do
|
50
|
+
@session.select('Boxers', :from => 'Underwear')
|
51
|
+
@session.should have_select('Underwear', :selected => [
|
52
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
53
|
+
])
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be false after one of the values is unselected" do
|
57
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
58
|
+
@session.should_not have_select('Underwear', :selected => [
|
59
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
60
|
+
])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'with exact options' do
|
65
|
+
it "should be true if a field with the given options is on the page" do
|
66
|
+
@session.should have_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
67
|
+
@session.should have_select('Tendency', :options => [])
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be false if the given field is not on the page" do
|
71
|
+
@session.should_not have_select('Locale', :options => ['Swedish'])
|
72
|
+
@session.should_not have_select('Does not exist', :options => ['John'])
|
73
|
+
@session.should_not have_select('City', :options => ['London', 'Made up city'])
|
74
|
+
@session.should_not have_select('Region', :options => ['Norway', 'Sweden'])
|
75
|
+
@session.should_not have_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'with partial options' do
|
80
|
+
it "should be true if a field with the given partial options is on the page" do
|
81
|
+
@session.should have_select('Region', :with_options => ['Norway', 'Sweden'])
|
82
|
+
@session.should have_select('City', :with_options => ['London'])
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should be false if a field with the given partial options is not on the page" do
|
86
|
+
@session.should_not have_select('Locale', :with_options => ['Uruguayan'])
|
87
|
+
@session.should_not have_select('Does not exist', :with_options => ['John'])
|
88
|
+
@session.should_not have_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Capybara::SpecHelper.spec '#has_no_select?' do
|
94
|
+
before { @session.visit('/form') }
|
95
|
+
|
96
|
+
it "should be false if the field is on the page" do
|
97
|
+
@session.should_not have_no_select('Locale')
|
98
|
+
@session.should_not have_no_select('form_region')
|
99
|
+
@session.should_not have_no_select('Languages')
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should be true if the field is not on the page" do
|
103
|
+
@session.should have_no_select('Monkey')
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'with selected value' do
|
107
|
+
it "should be false if a field with the given value is on the page" do
|
108
|
+
@session.should_not have_no_select('form_locale', :selected => 'English')
|
109
|
+
@session.should_not have_no_select('Region', :selected => 'Norway')
|
110
|
+
@session.should_not have_no_select('Underwear', :selected => [
|
111
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
112
|
+
])
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should be true if the given field is not on the page" do
|
116
|
+
@session.should have_no_select('Locale', :selected => 'Swedish')
|
117
|
+
@session.should have_no_select('Does not exist', :selected => 'John')
|
118
|
+
@session.should have_no_select('City', :selected => 'Not there')
|
119
|
+
@session.should have_no_select('Underwear', :selected => [
|
120
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
121
|
+
])
|
122
|
+
@session.should have_no_select('Underwear', :selected => [
|
123
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
124
|
+
])
|
125
|
+
@session.should have_no_select('Underwear', :selected => [
|
126
|
+
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
127
|
+
])
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should be false after the given value is selected" do
|
131
|
+
@session.select('Swedish', :from => 'Locale')
|
132
|
+
@session.should_not have_no_select('Locale', :selected => 'Swedish')
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should be true after a different value is selected" do
|
136
|
+
@session.select('Swedish', :from => 'Locale')
|
137
|
+
@session.should have_no_select('Locale', :selected => 'English')
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should be false after the given values are selected" do
|
141
|
+
@session.select('Boxers', :from => 'Underwear')
|
142
|
+
@session.should_not have_no_select('Underwear', :selected => [
|
143
|
+
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
144
|
+
])
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should be true after one of the values is unselected" do
|
148
|
+
@session.unselect('Briefs', :from => 'Underwear')
|
149
|
+
@session.should have_no_select('Underwear', :selected => [
|
150
|
+
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
151
|
+
])
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'with exact options' do
|
156
|
+
it "should be false if a field with the given options is on the page" do
|
157
|
+
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should be true if the given field is not on the page" do
|
161
|
+
@session.should have_no_select('Locale', :options => ['Swedish'])
|
162
|
+
@session.should have_no_select('Does not exist', :options => ['John'])
|
163
|
+
@session.should have_no_select('City', :options => ['London', 'Made up city'])
|
164
|
+
@session.should have_no_select('Region', :options => ['Norway', 'Sweden'])
|
165
|
+
@session.should have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
90
166
|
end
|
91
167
|
end
|
92
168
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
@session.should have_no_select('Monkey')
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'with selected value' do
|
107
|
-
it "should be false if a field with the given value is on the page" do
|
108
|
-
@session.should_not have_no_select('form_locale', :selected => 'English')
|
109
|
-
@session.should_not have_no_select('Region', :selected => 'Norway')
|
110
|
-
@session.should_not have_no_select('Underwear', :selected => [
|
111
|
-
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
112
|
-
])
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should be true if the given field is not on the page" do
|
116
|
-
@session.should have_no_select('Locale', :selected => 'Swedish')
|
117
|
-
@session.should have_no_select('Does not exist', :selected => 'John')
|
118
|
-
@session.should have_no_select('City', :selected => 'Not there')
|
119
|
-
@session.should have_no_select('Underwear', :selected => [
|
120
|
-
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns', 'Nonexistant'
|
121
|
-
])
|
122
|
-
@session.should have_no_select('Underwear', :selected => [
|
123
|
-
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
124
|
-
])
|
125
|
-
@session.should have_no_select('Underwear', :selected => [
|
126
|
-
'Boxerbriefs', 'Briefs','Commando', "Frenchman's Pantalons"
|
127
|
-
])
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should be false after the given value is selected" do
|
131
|
-
@session.select('Swedish', :from => 'Locale')
|
132
|
-
@session.should_not have_no_select('Locale', :selected => 'Swedish')
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should be true after a different value is selected" do
|
136
|
-
@session.select('Swedish', :from => 'Locale')
|
137
|
-
@session.should have_no_select('Locale', :selected => 'English')
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should be false after the given values are selected" do
|
141
|
-
@session.select('Boxers', :from => 'Underwear')
|
142
|
-
@session.should_not have_no_select('Underwear', :selected => [
|
143
|
-
'Boxerbriefs', 'Briefs', 'Boxers', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
144
|
-
])
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should be true after one of the values is unselected" do
|
148
|
-
@session.unselect('Briefs', :from => 'Underwear')
|
149
|
-
@session.should have_no_select('Underwear', :selected => [
|
150
|
-
'Boxerbriefs', 'Briefs', 'Commando', "Frenchman's Pantalons", 'Long Johns'
|
151
|
-
])
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context 'with exact options' do
|
156
|
-
it "should be false if a field with the given options is on the page" do
|
157
|
-
@session.should_not have_no_select('Region', :options => ['Norway', 'Sweden', 'Finland'])
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should be true if the given field is not on the page" do
|
161
|
-
@session.should have_no_select('Locale', :options => ['Swedish'])
|
162
|
-
@session.should have_no_select('Does not exist', :options => ['John'])
|
163
|
-
@session.should have_no_select('City', :options => ['London', 'Made up city'])
|
164
|
-
@session.should have_no_select('Region', :options => ['Norway', 'Sweden'])
|
165
|
-
@session.should have_no_select('Region', :options => ['Norway', 'Norway', 'Norway'])
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context 'with partial options' do
|
170
|
-
it "should be false if a field with the given partial options is on the page" do
|
171
|
-
@session.should_not have_no_select('Region', :with_options => ['Norway', 'Sweden'])
|
172
|
-
@session.should_not have_no_select('City', :with_options => ['London'])
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should be true if a field with the given partial options is not on the page" do
|
176
|
-
@session.should have_no_select('Locale', :with_options => ['Uruguayan'])
|
177
|
-
@session.should have_no_select('Does not exist', :with_options => ['John'])
|
178
|
-
@session.should have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
179
|
-
end
|
169
|
+
context 'with partial options' do
|
170
|
+
it "should be false if a field with the given partial options is on the page" do
|
171
|
+
@session.should_not have_no_select('Region', :with_options => ['Norway', 'Sweden'])
|
172
|
+
@session.should_not have_no_select('City', :with_options => ['London'])
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should be true if a field with the given partial options is not on the page" do
|
176
|
+
@session.should have_no_select('Locale', :with_options => ['Uruguayan'])
|
177
|
+
@session.should have_no_select('Does not exist', :with_options => ['John'])
|
178
|
+
@session.should have_no_select('Region', :with_options => ['Norway', 'Sweden', 'Finland', 'Latvia'])
|
180
179
|
end
|
181
180
|
end
|
182
181
|
end
|