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.
Files changed (93) hide show
  1. data/History.txt +30 -1
  2. data/README.md +52 -31
  3. data/lib/capybara.rb +1 -0
  4. data/lib/capybara/driver/base.rb +1 -1
  5. data/lib/capybara/driver/node.rb +1 -0
  6. data/lib/capybara/dsl.rb +12 -5
  7. data/lib/capybara/helpers.rb +33 -0
  8. data/lib/capybara/node/actions.rb +4 -2
  9. data/lib/capybara/node/base.rb +52 -1
  10. data/lib/capybara/node/element.rb +0 -12
  11. data/lib/capybara/node/finders.rb +1 -1
  12. data/lib/capybara/node/matchers.rb +57 -47
  13. data/lib/capybara/node/simple.rb +4 -0
  14. data/lib/capybara/query.rb +11 -11
  15. data/lib/capybara/rack_test/browser.rb +14 -15
  16. data/lib/capybara/rack_test/driver.rb +2 -2
  17. data/lib/capybara/rack_test/node.rb +15 -2
  18. data/lib/capybara/result.rb +7 -19
  19. data/lib/capybara/rspec.rb +7 -4
  20. data/lib/capybara/rspec/features.rb +4 -1
  21. data/lib/capybara/rspec/matchers.rb +8 -3
  22. data/lib/capybara/selector.rb +1 -2
  23. data/lib/capybara/selenium/driver.rb +2 -2
  24. data/lib/capybara/selenium/node.rb +9 -7
  25. data/lib/capybara/session.rb +47 -31
  26. data/lib/capybara/spec/fixtures/another_test_file.txt +1 -0
  27. data/lib/capybara/spec/public/test.js +1 -1
  28. data/lib/capybara/spec/session/all_spec.rb +60 -62
  29. data/lib/capybara/spec/session/assert_selector.rb +123 -0
  30. data/lib/capybara/spec/session/attach_file_spec.rb +72 -58
  31. data/lib/capybara/spec/session/body_spec.rb +21 -0
  32. data/lib/capybara/spec/session/check_spec.rb +67 -50
  33. data/lib/capybara/spec/session/choose_spec.rb +32 -21
  34. data/lib/capybara/spec/session/click_button_spec.rb +261 -221
  35. data/lib/capybara/spec/session/click_link_or_button_spec.rb +40 -30
  36. data/lib/capybara/spec/session/click_link_spec.rb +95 -81
  37. data/lib/capybara/spec/session/current_url_spec.rb +70 -60
  38. data/lib/capybara/spec/session/evaluate_script_spec.rb +6 -0
  39. data/lib/capybara/spec/session/execute_script_spec.rb +7 -0
  40. data/lib/capybara/spec/session/fill_in_spec.rb +118 -92
  41. data/lib/capybara/spec/session/find_button_spec.rb +16 -14
  42. data/lib/capybara/spec/session/find_by_id_spec.rb +16 -14
  43. data/lib/capybara/spec/session/find_field_spec.rb +23 -21
  44. data/lib/capybara/spec/session/find_link_spec.rb +15 -14
  45. data/lib/capybara/spec/session/find_spec.rb +96 -91
  46. data/lib/capybara/spec/session/first_spec.rb +53 -55
  47. data/lib/capybara/spec/session/has_button_spec.rb +22 -24
  48. data/lib/capybara/spec/session/has_css_spec.rb +190 -205
  49. data/lib/capybara/spec/session/has_field_spec.rb +167 -169
  50. data/lib/capybara/spec/session/has_link_spec.rb +26 -29
  51. data/lib/capybara/spec/session/has_select_spec.rb +175 -176
  52. data/lib/capybara/spec/session/has_selector_spec.rb +94 -100
  53. data/lib/capybara/spec/session/has_table_spec.rb +22 -26
  54. data/lib/capybara/spec/session/has_text_spec.rb +159 -132
  55. data/lib/capybara/spec/session/has_xpath_spec.rb +100 -96
  56. data/lib/capybara/spec/session/headers.rb +4 -17
  57. data/lib/capybara/spec/session/html_spec.rb +15 -0
  58. data/lib/capybara/spec/session/node_spec.rb +172 -82
  59. data/lib/capybara/spec/session/reset_session_spec.rb +42 -0
  60. data/lib/capybara/spec/session/response_code.rb +4 -17
  61. data/lib/capybara/spec/session/save_page_spec.rb +46 -0
  62. data/lib/capybara/spec/session/screenshot.rb +8 -24
  63. data/lib/capybara/spec/session/select_spec.rb +100 -89
  64. data/lib/capybara/spec/session/source_spec.rb +12 -0
  65. data/lib/capybara/spec/session/text_spec.rb +15 -17
  66. data/lib/capybara/spec/session/uncheck_spec.rb +22 -17
  67. data/lib/capybara/spec/session/unselect_spec.rb +57 -52
  68. data/lib/capybara/spec/session/visit_spec.rb +58 -60
  69. data/lib/capybara/spec/session/within_frame_spec.rb +24 -26
  70. data/lib/capybara/spec/session/within_spec.rb +119 -121
  71. data/lib/capybara/spec/session/within_window_spec.rb +29 -31
  72. data/lib/capybara/spec/spec_helper.rb +84 -0
  73. data/lib/capybara/spec/test_app.rb +5 -3
  74. data/lib/capybara/spec/views/form.erb +1 -0
  75. data/lib/capybara/spec/views/with_html.erb +6 -1
  76. data/lib/capybara/spec/views/with_js.erb +1 -0
  77. data/lib/capybara/version.rb +1 -1
  78. data/spec/basic_node_spec.rb +2 -2
  79. data/spec/capybara_spec.rb +9 -0
  80. data/spec/dsl_spec.rb +22 -10
  81. data/spec/rack_test_spec.rb +28 -23
  82. data/spec/result_spec.rb +51 -0
  83. data/spec/rspec/features_spec.rb +19 -0
  84. data/spec/rspec/matchers_spec.rb +6 -0
  85. data/spec/rspec_spec.rb +1 -1
  86. data/spec/selenium_spec.rb +11 -25
  87. data/spec/server_spec.rb +2 -2
  88. data/spec/spec_helper.rb +1 -46
  89. metadata +41 -98
  90. data/lib/capybara/spec/session.rb +0 -183
  91. data/lib/capybara/spec/session/javascript.rb +0 -290
  92. data/lib/capybara/util/save_and_open_page.rb +0 -45
  93. data/spec/save_and_open_page_spec.rb +0 -155
@@ -1,220 +1,218 @@
1
- shared_examples_for "has_field" do
2
- describe '#has_field' do
3
- before { @session.visit('/form') }
4
-
5
- it "should be true if the field is on the page" do
6
- @session.should have_field('Dog')
7
- @session.should have_field('form_description')
8
- @session.should have_field('Region')
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('Monkey')
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
- 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')
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
- 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')
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
- describe '#has_no_field' do
56
- before { @session.visit('/form') }
57
-
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')
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 true if the field is not on the page" do
65
- @session.should have_no_field('Monkey')
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
- 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')
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
- 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')
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
- describe '#has_checked_field?' do
109
- before { @session.visit('/form') }
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
- 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')
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 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')
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 if no field is on the page" do
122
- @session.should_not have_checked_field('Does Not Exist')
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 an unchecked checkbox is checked" do
126
- @session.check('form_pets_cat')
127
- @session.should have_checked_field('form_pets_cat')
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
- 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')
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 after an unchecked radio button is chosen" do
136
- @session.choose('gender_male')
137
- @session.should have_checked_field('gender_male')
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
- 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
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
- describe '#has_no_checked_field?' do
147
- before { @session.visit('/form') }
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
- 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
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
- 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
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
- it "should be true if no field is on the page" do
160
- @session.should have_no_checked_field('Does Not Exist')
161
- end
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
- describe '#has_unchecked_field?' do
165
- before { @session.visit('/form') }
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
- 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')
170
- end
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
- 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
146
+ Capybara::SpecHelper.spec '#has_no_checked_field?' do
147
+ before { @session.visit('/form') }
176
148
 
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
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
- 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
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
- 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
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
- 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
164
+ Capybara::SpecHelper.spec '#has_unchecked_field?' do
165
+ before { @session.visit('/form') }
195
166
 
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')
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
- describe '#has_no_unchecked_field?' do
203
- before { @session.visit('/form') }
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
- 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
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
- 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
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
- it "should be true if no field is on the page" do
216
- @session.should have_no_unchecked_field('Does Not Exist')
217
- end
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
- shared_examples_for "has_link" do
2
-
3
- describe '#has_link?' do
4
- before do
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
- it "should be true if the given link is on the page" do
9
- @session.should have_link('foo')
10
- @session.should have_link('awesome title')
11
- @session.should have_link('A link', :href => '/with_simple_html')
12
- end
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
- it "should be false if the given link is not on the page" do
15
- @session.should_not have_link('monkey')
16
- @session.should_not have_link('A link', :href => '/non-existant-href')
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
- describe '#has_no_link?' do
21
- before do
22
- @session.visit('/with_html')
23
- end
19
+ Capybara::SpecHelper.spec '#has_no_link?' do
20
+ before do
21
+ @session.visit('/with_html')
22
+ end
24
23
 
25
- it "should be false if the given link is on the page" do
26
- @session.should_not have_no_link('foo')
27
- @session.should_not have_no_link('awesome title')
28
- @session.should_not have_no_link('A link', :href => '/with_simple_html')
29
- end
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
- it "should be true if the given link is not on the page" do
32
- @session.should have_no_link('monkey')
33
- @session.should have_no_link('A link', :href => '/non-existant-href')
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
- shared_examples_for "has_select" do
2
- describe '#has_select?' do
3
- before { @session.visit('/form') }
4
-
5
- it "should be true if the field is on the page" do
6
- @session.should have_select('Locale')
7
- @session.should have_select('form_region')
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
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
- describe '#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'])
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