kelp 0.1.1 → 0.1.2

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.
Files changed (56) hide show
  1. data/.gitignore +2 -0
  2. data/.yardopts +6 -0
  3. data/Gemfile +4 -9
  4. data/Gemfile.lock +8 -0
  5. data/History.md +22 -0
  6. data/README.md +154 -7
  7. data/kelp.gemspec +1 -1
  8. data/lib/kelp.rb +8 -1
  9. data/lib/kelp/attribute.rb +31 -0
  10. data/lib/kelp/checkbox.rb +31 -0
  11. data/lib/kelp/dropdown.rb +109 -0
  12. data/lib/kelp/field.rb +159 -0
  13. data/lib/kelp/helper.rb +14 -0
  14. data/lib/kelp/navigation.rb +63 -0
  15. data/lib/kelp/scoping.rb +45 -0
  16. data/lib/kelp/visibility.rb +176 -0
  17. data/lib/kelp/xpath.rb +14 -0
  18. data/spec/attribute_spec.rb +56 -0
  19. data/spec/checkbox_spec.rb +69 -0
  20. data/spec/dropdown_spec.rb +176 -0
  21. data/spec/field_spec.rb +290 -0
  22. data/spec/navigation_spec.rb +89 -0
  23. data/spec/scoping_spec.rb +0 -0
  24. data/spec/{capybara/spec_helper.rb → spec_helper.rb} +9 -5
  25. data/spec/test_app/views/form.erb +24 -0
  26. data/spec/visibility_spec.rb +315 -0
  27. data/spec/xpath_spec.rb +0 -0
  28. data/step_definitions/capybara_steps.rb +132 -0
  29. metadata +25 -32
  30. data/docs/Makefile +0 -130
  31. data/docs/_static/custom.css +0 -9
  32. data/docs/conf.py +0 -217
  33. data/docs/development.rst +0 -27
  34. data/docs/future.rst +0 -9
  35. data/docs/index.rst +0 -33
  36. data/docs/make.bat +0 -155
  37. data/docs/testing.rst +0 -15
  38. data/docs/usage.rst +0 -85
  39. data/lib/kelp/capybara.rb +0 -2
  40. data/lib/kelp/capybara/capybara_steps.rb +0 -225
  41. data/lib/kelp/capybara/form_helper.rb +0 -131
  42. data/lib/kelp/capybara/web_helper.rb +0 -148
  43. data/spec/capybara/click_link_in_row_spec.rb +0 -24
  44. data/spec/capybara/dropdown_spec.rb +0 -112
  45. data/spec/capybara/field_should_be_empty_spec.rb +0 -44
  46. data/spec/capybara/field_should_contain_spec.rb +0 -143
  47. data/spec/capybara/fill_in_fields_spec.rb +0 -67
  48. data/spec/capybara/follow_spec.rb +0 -35
  49. data/spec/capybara/page_should_have_spec.rb +0 -48
  50. data/spec/capybara/page_should_not_have_spec.rb +0 -53
  51. data/spec/capybara/press_spec.rb +0 -33
  52. data/spec/capybara/should_be_disabled_spec.rb +0 -28
  53. data/spec/capybara/should_be_enabled_spec.rb +0 -29
  54. data/spec/capybara/should_not_see_spec.rb +0 -97
  55. data/spec/capybara/should_see_in_same_row_spec.rb +0 -41
  56. data/spec/capybara/should_see_spec.rb +0 -80
@@ -0,0 +1,290 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Kelp::Field, "field_should_be_empty" do
4
+ before(:each) do
5
+ visit('/form')
6
+ end
7
+
8
+ context "passes when" do
9
+ context "field with id" do
10
+ it "is empty" do
11
+ field_should_be_empty "first_name"
12
+ field_should_be_empty "last_name"
13
+ end
14
+ end
15
+
16
+ context "field with label" do
17
+ it "is empty" do
18
+ field_should_be_empty "First name"
19
+ field_should_be_empty "Last name"
20
+ end
21
+ end
22
+ end
23
+
24
+ context "fails when" do
25
+ context "field with id" do
26
+ it "has a value" do
27
+ fill_in "first_name", :with => "Brian"
28
+ lambda do
29
+ field_should_be_empty "first_name"
30
+ end.should raise_error(RuntimeError)
31
+ end
32
+ end
33
+
34
+ context "field with label" do
35
+ it "has a value" do
36
+ fill_in "First name", :with => "Brian"
37
+ lambda do
38
+ field_should_be_empty "First name"
39
+ end.should raise_error(RuntimeError)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+
46
+ describe Kelp::Field, "field_should_contain" do
47
+ before(:each) do
48
+ visit('/form')
49
+ end
50
+
51
+ context "passes when" do
52
+ context "field with id" do
53
+ it "has the given value" do
54
+ fill_in "first_name", :with => "Brian"
55
+ field_should_contain "first_name", "Brian"
56
+ end
57
+ end
58
+
59
+ context "field with label" do
60
+ it "has the given value" do
61
+ fill_in "First name", :with => "Brian"
62
+ field_should_contain "First name", "Brian"
63
+ end
64
+ end
65
+ end
66
+
67
+ context "fails when" do
68
+ context "field with id" do
69
+ it "is empty" do
70
+ lambda do
71
+ field_should_contain "first_name", "Brian"
72
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
73
+ end
74
+
75
+ it "has a different value" do
76
+ fill_in "first_name", :with => "Judith"
77
+ lambda do
78
+ field_should_contain "first_name", "Brian"
79
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
80
+ end
81
+ end
82
+
83
+ context "field with label" do
84
+ it "is empty" do
85
+ lambda do
86
+ field_should_contain "First name", "Brian"
87
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
88
+ end
89
+
90
+ it "has a different value" do
91
+ fill_in "First name", :with => "Judith"
92
+ lambda do
93
+ field_should_contain "First name", "Brian"
94
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+
102
+
103
+ describe Kelp::Field, "fields_should_contain" do
104
+ before(:each) do
105
+ visit('/form')
106
+ end
107
+
108
+ context "passes when" do
109
+ context "fields with ids" do
110
+ it "all match" do
111
+ fill_in "first_name", :with => "Terry"
112
+ fill_in "last_name", :with => "Jones"
113
+ fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
114
+ end
115
+
116
+ it "all match with some empty" do
117
+ fill_in "first_name", :with => "Terry"
118
+ fields_should_contain "first_name" => "Terry", "last_name" => ""
119
+ end
120
+
121
+ it "all match with some dropdowns" do
122
+ fill_in "first_name", :with => "Terry"
123
+ fill_in "last_name", :with => "Jones"
124
+ select "Average", :from => "height"
125
+ fields_should_contain "first_name" => "Terry", "last_name" => "Jones", "height" => "Average"
126
+ end
127
+ end
128
+
129
+ context "fields with labels" do
130
+ it "all match" do
131
+ fill_in "First name", :with => "Terry"
132
+ fill_in "Last name", :with => "Jones"
133
+ fields_should_contain "First name" => "Terry", "Last name" => "Jones"
134
+ end
135
+
136
+ it "all match with some empty" do
137
+ fill_in "First name", :with => "Terry"
138
+ fields_should_contain "First name" => "Terry", "Last name" => ""
139
+ end
140
+
141
+ it "all match with some dropdowns" do
142
+ fill_in "First name", :with => "Terry"
143
+ fill_in "Last name", :with => "Jones"
144
+ select "Average", :from => "Height"
145
+ fields_should_contain "First name" => "Terry", "Last name" => "Jones", "Height" => "Average"
146
+ end
147
+ end
148
+ end
149
+
150
+ context "fails when" do
151
+ context "fields with ids" do
152
+ it "are empty" do
153
+ lambda do
154
+ fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
155
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
156
+ end
157
+
158
+ it "do not all match" do
159
+ fill_in "first_name", :with => "Terry"
160
+ fill_in "last_name", :with => "Gilliam"
161
+ lambda do
162
+ fields_should_contain "first_name" => "Terry", "last_name" => "Jones"
163
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
164
+ end
165
+ end
166
+
167
+ context "fields with labels" do
168
+ it "are empty" do
169
+ lambda do
170
+ fields_should_contain "First name" => "Terry", "Last name" => "Jones"
171
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
172
+ end
173
+
174
+ it "do not all match" do
175
+ fill_in "First name", :with => "Terry"
176
+ fill_in "Last name", :with => "Gilliam"
177
+ lambda do
178
+ fields_should_contain "First name" => "Terry", "Last name" => "Jones"
179
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
180
+ end
181
+ end
182
+
183
+ end
184
+
185
+ end
186
+
187
+
188
+ describe Kelp::Field, "fill_in_field" do
189
+ before(:each) do
190
+ visit('/form')
191
+ end
192
+
193
+ context "passes when" do
194
+ it "filling a single field by id" do
195
+ fill_in_field "first_name", "Mel"
196
+ field_should_contain "first_name", "Mel"
197
+ end
198
+
199
+ it "filling a single field by label" do
200
+ fill_in_field "First name", "Mel"
201
+ field_should_contain "First name", "Mel"
202
+ end
203
+
204
+ it "filling a single field by id within a scope" do
205
+ fill_in_field_within "#person_form", "first_name", "Mel"
206
+ field_should_contain_within "#person_form", "first_name", "Mel"
207
+ end
208
+ end
209
+
210
+ context "fails when" do
211
+ it "filling a nonexistent field" do
212
+ lambda do
213
+ fill_in_field "Middle name", "Kaminsky"
214
+ end.should raise_error(Capybara::ElementNotFound)
215
+ end
216
+
217
+ it "filling a field in the wrong scope" do
218
+ lambda do
219
+ fill_in_field_within "#other_form", "First name", "Mel"
220
+ end.should raise_error(Capybara::ElementNotFound)
221
+ end
222
+ end
223
+ end
224
+
225
+
226
+ describe Kelp::Field, "fill_in_fields" do
227
+ before(:each) do
228
+ visit('/form')
229
+ end
230
+
231
+ context "passes when" do
232
+ it "filling a single field by id" do
233
+ fill_in_fields "first_name" => "Mel"
234
+ field_should_contain "first_name", "Mel"
235
+ end
236
+
237
+ it "filling a single field by label" do
238
+ fill_in_fields "First name" => "Mel"
239
+ field_should_contain "First name", "Mel"
240
+ end
241
+
242
+ it "filling multiple fields by id" do
243
+ fill_in_fields \
244
+ "first_name" => "Mel",
245
+ "last_name" => "Brooks"
246
+ field_should_contain "first_name", "Mel"
247
+ field_should_contain "last_name", "Brooks"
248
+ end
249
+
250
+ it "filling multiple fields by label" do
251
+ fill_in_fields \
252
+ "First name" => "Mel",
253
+ "Last name" => "Brooks"
254
+ field_should_contain "First name", "Mel"
255
+ field_should_contain "Last name", "Brooks"
256
+ end
257
+
258
+ it "filling a single field by id within a scope" do
259
+ fill_in_fields_within "#person_form", "first_name" => "Mel"
260
+ field_should_contain "first_name", "Mel", :within => "#person_form"
261
+ end
262
+
263
+ it "filling multiple fields by id within a scope" do
264
+ fill_in_fields_within "#person_form",
265
+ "first_name" => "Mel",
266
+ "last_name" => "Brooks"
267
+ fields_should_contain_within "#person_form",
268
+ "first_name" => "Mel",
269
+ "last_name" => "Brooks"
270
+ end
271
+ end
272
+
273
+ context "fails when" do
274
+ it "filling a nonexistent field" do
275
+ lambda do
276
+ fill_in_fields "Middle name" => "Kaminsky"
277
+ end.should raise_error(Capybara::ElementNotFound)
278
+ end
279
+
280
+ it "filling a field in the wrong scope" do
281
+ lambda do
282
+ fill_in_fields_within "#other_form",
283
+ "First name" => "Mel"
284
+ end.should raise_error(Capybara::ElementNotFound)
285
+ end
286
+ end
287
+
288
+ end
289
+
290
+
@@ -0,0 +1,89 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Kelp::Navigation, "follow" do
4
+ before(:each) do
5
+ visit('/home')
6
+ end
7
+
8
+ context "passes when" do
9
+ it "link exists" do
10
+ follow "About Us"
11
+ should_see "We're a small company with an even smaller webpage"
12
+ end
13
+
14
+ it "link is within the scope" do
15
+ follow "About Us", :within => "#links"
16
+ should_see "We're a small company with an even smaller webpage"
17
+ end
18
+ end
19
+
20
+ context "fails when" do
21
+ it "link does not exist" do
22
+ lambda do
23
+ follow "About Them"
24
+ end.should raise_error(Capybara::ElementNotFound)
25
+ end
26
+
27
+ it "link is not within the scope" do
28
+ lambda do
29
+ follow "About Us", :within => "#invalid_scope"
30
+ end.should raise_error(Capybara::ElementNotFound)
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+
37
+ describe Kelp::Navigation, "press" do
38
+ before(:each) do
39
+ visit('/home')
40
+ end
41
+
42
+ context "passes when" do
43
+ it "button exists" do
44
+ press "Submit"
45
+ end
46
+
47
+ it "button exists within the scope" do
48
+ press "Submit", :within => "#fields"
49
+ end
50
+ end
51
+
52
+ context "fails when" do
53
+ it "button does not exist" do
54
+ lambda do
55
+ press "Poke"
56
+ end.should raise_error(Capybara::ElementNotFound)
57
+ end
58
+
59
+ it "button exists but is not within the scope" do
60
+ lambda do
61
+ press "Submit", :within => "#greeting"
62
+ end.should raise_error(Capybara::ElementNotFound)
63
+ end
64
+ end
65
+ end
66
+
67
+
68
+ describe Kelp::Navigation, "click_link_in_row" do
69
+ before(:each) do
70
+ visit('/home')
71
+ end
72
+
73
+ context "passes when" do
74
+ it "link exists in the row" do
75
+ click_link_in_row "Edit", "Eric"
76
+ should_see "You are editing record 1"
77
+ end
78
+ end
79
+
80
+ context "fails when" do
81
+ it "link does not exist in the row" do
82
+ lambda do
83
+ click_link_in_row "Frob", "Eric"
84
+ end.should raise_error(Capybara::ElementNotFound)
85
+ end
86
+ end
87
+ end
88
+
89
+
File without changes
@@ -1,14 +1,18 @@
1
1
  require 'rspec'
2
2
  require 'capybara'
3
3
  require 'capybara/dsl'
4
- require File.expand_path(File.dirname(__FILE__) + '/../test_app/test_app')
5
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/kelp/capybara/web_helper')
6
- require File.expand_path(File.dirname(__FILE__) + '/../../lib/kelp/capybara/form_helper')
4
+ require 'kelp'
5
+ require File.expand_path(File.dirname(__FILE__) + '/test_app/test_app')
7
6
 
8
7
  RSpec.configure do |config|
9
8
  config.include Capybara
10
- config.include WebHelper
11
- config.include FormHelper
9
+ config.include Kelp::Attribute
10
+ config.include Kelp::Checkbox
11
+ config.include Kelp::Dropdown
12
+ config.include Kelp::Field
13
+ config.include Kelp::Navigation
14
+ config.include Kelp::Scoping
15
+ config.include Kelp::Visibility
12
16
  config.after do
13
17
  Capybara.reset_sessions!
14
18
  Capybara.use_default_driver
@@ -21,6 +21,30 @@
21
21
  <option value="3" >Tall</option>
22
22
  </select>
23
23
  </p>
24
+ <p>
25
+ <label for="weight">Weight</label>
26
+ <select id="weight">
27
+ <option value="1">Light</option>
28
+ <option value="2">Medium</option>
29
+ <option value="3">Heavy</option>
30
+ </select>
31
+ </p>
32
+ <p>
33
+ <label for="favorite_colors">Favorite Colors</label>
34
+ <select id="favorite_colors" multiple="multiple">
35
+ <option value="r">Red</option>
36
+ <option value="g">Green</option>
37
+ <option value="b">Blue</option>
38
+ </select>
39
+ </p>
40
+ <p>
41
+ <label for="like_cheese">I like cheese</label>
42
+ <input id="like_cheese" type="checkbox" checked="checked"/>
43
+ </p>
44
+ <p>
45
+ <label for="like_salami">I like salami</label>
46
+ <input id="like_salami" type="checkbox" />
47
+ </p>
24
48
  <p><input type="submit" value="Submit" /></p>
25
49
  </form>
26
50
  </div>
@@ -0,0 +1,315 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Kelp::Visibility, "should_see" do
4
+ before(:each) do
5
+ visit('/home')
6
+ end
7
+
8
+ context "passes when" do
9
+ context "String" do
10
+ it "exists" do
11
+ should_see "Hello world"
12
+ should_see "Goodbye world"
13
+ end
14
+
15
+ it "multiple exist" do
16
+ should_see [
17
+ "Hello world",
18
+ "Goodbye world"
19
+ ]
20
+ end
21
+
22
+ it "is within the scope" do
23
+ should_see "Hello world", :within => "#greeting"
24
+ end
25
+ end
26
+
27
+ context "Regexp" do
28
+ it "matches" do
29
+ should_see /(Hello|Goodbye) world/
30
+ end
31
+
32
+ it "matches within the scope" do
33
+ should_see /(Hello|Goodbye) world/, :within => "#greeting"
34
+ should_see /(Hello|Goodbye) world/, :within => "#farewell"
35
+ end
36
+ end
37
+ end
38
+
39
+ context "fails when" do
40
+ context "String" do
41
+ it "does not exist" do
42
+ lambda do
43
+ should_see "Goodbye cruel world"
44
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
45
+ end
46
+
47
+ it "any of several do not exist" do
48
+ lambda do
49
+ should_see [
50
+ "Hello world",
51
+ "Goodbye world",
52
+ "Hello, nurse!"
53
+ ]
54
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
55
+ end
56
+
57
+ it "is not within the scope" do
58
+ lambda do
59
+ should_see "Goodbye world", :within => "#greeting"
60
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
61
+ end
62
+ end
63
+
64
+ context "Regexp" do
65
+ it "does not match" do
66
+ lambda do
67
+ should_see /(Yo|Wazzup) world/
68
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
69
+ end
70
+
71
+ it "matches but is not within the scope" do
72
+ lambda do
73
+ should_see /Goodbye world/, :within => "#greeting"
74
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+
81
+
82
+ describe Kelp::Visibility, "should_not_see" do
83
+ before(:each) do
84
+ visit('/home')
85
+ end
86
+
87
+ context "passes when" do
88
+ context "String" do
89
+ it "does not exist" do
90
+ should_not_see "Goodbye cruel world"
91
+ end
92
+
93
+ it "none of several strings exist" do
94
+ should_not_see [
95
+ "Hello nurse",
96
+ "Goodbye cruel world"
97
+ ]
98
+ end
99
+
100
+ it "exists but is not within the scope" do
101
+ should_not_see "Goodbye world", :within => "#greeting"
102
+ end
103
+ end
104
+
105
+ context "Regexp" do
106
+ it "does not match" do
107
+ should_not_see /(Yo|Wazzup) world/
108
+ end
109
+
110
+ it "none of several regexps match" do
111
+ should_not_see [
112
+ /(Yo|Wazzup) world/,
113
+ /(Ciao|Later) world/
114
+ ]
115
+ end
116
+
117
+ it "matches but is not within the scope" do
118
+ should_not_see /Goodbye world/, :within => "#greeting"
119
+ end
120
+ end
121
+ end
122
+
123
+
124
+ context "fails when" do
125
+ context "String" do
126
+ it "exists" do
127
+ lambda do
128
+ should_not_see "Hello world"
129
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
130
+ end
131
+
132
+ it "any of several exist" do
133
+ lambda do
134
+ should_not_see [
135
+ "Hello nurse",
136
+ "Goodbye cruel world",
137
+ "Goodbye world"
138
+ ]
139
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
140
+ end
141
+
142
+ it "exists within the scope" do
143
+ lambda do
144
+ should_not_see "Hello world", :within => "#greeting"
145
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
146
+ end
147
+ end
148
+
149
+ context "Regexp" do
150
+ it "matches" do
151
+ lambda do
152
+ should_not_see /(Hello|Goodbye) world/
153
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
154
+ end
155
+
156
+ it "any of several regexps match" do
157
+ lambda do
158
+ should_not_see [
159
+ /(Yo|Wazzup) world/,
160
+ /(Ciao|Later) world/,
161
+ /(Hello|Goodbye) world/
162
+ ]
163
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
164
+ end
165
+
166
+ it "matches within the scope" do
167
+ lambda do
168
+ should_not_see /(Hello|Goodbye) world/, :within => "#greeting"
169
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
170
+ end
171
+ end
172
+
173
+ end
174
+ end
175
+
176
+
177
+ describe Kelp::Visibility, "should_see_in_same_row" do
178
+ before(:each) do
179
+ visit('/home')
180
+ end
181
+
182
+ context "passes when" do
183
+ it "two strings are in the same row" do
184
+ should_see_in_same_row ["Eric", "Edit"]
185
+ should_see_in_same_row ["John", "Edit"]
186
+ should_see_in_same_row ["Terry", "Edit"]
187
+ end
188
+
189
+ it "three strings are in the same row" do
190
+ should_see_in_same_row ["Eric", "555-4444", "Edit"]
191
+ should_see_in_same_row ["John", "666-5555", "Edit"]
192
+ should_see_in_same_row ["Terry", "777-6666", "Edit"]
193
+ end
194
+ end
195
+ end
196
+
197
+ describe Kelp::Visibility, "should_see_in_same_row" do
198
+ before(:each) do
199
+ visit('/home')
200
+ end
201
+
202
+ context "passes when" do
203
+ it "two strings are not in the same row" do
204
+ should_not_see_in_same_row ["Eric", "Delete"]
205
+ should_not_see_in_same_row ["John", "Delete"]
206
+ should_not_see_in_same_row ["Terry", "Delete"]
207
+ end
208
+
209
+ it "any two of three strings are not in the same row" do
210
+ should_not_see_in_same_row ["Eric", "555-4444", "Delete"]
211
+ should_not_see_in_same_row ["John", "666-5555", "Delete"]
212
+ should_not_see_in_same_row ["Terry", "777-6666", "Delete"]
213
+ end
214
+ end
215
+ end
216
+
217
+
218
+ describe Kelp::Visibility, "page_should_contain" do
219
+ before(:each) do
220
+ visit('/home')
221
+ end
222
+
223
+ context "passes when" do
224
+ context "String" do
225
+ it "exists" do
226
+ page_should_contain "Hello world"
227
+ page_should_contain "Goodbye world"
228
+ end
229
+ end
230
+ context "Regexp" do
231
+ it "matches" do
232
+ page_should_contain /(Hello|Goodbye) world/
233
+ page_should_contain /\d\d\d-\d\d\d\d/
234
+ end
235
+ end
236
+ end
237
+
238
+ context "fails when" do
239
+ context "String" do
240
+ it "does not exist" do
241
+ lambda do
242
+ page_should_contain "Wazzup world"
243
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
244
+ end
245
+ end
246
+
247
+ context "Regexp" do
248
+ it "does not match" do
249
+ lambda do
250
+ page_should_contain /(Foo|Bar|Baz) world/
251
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
252
+ end
253
+ end
254
+
255
+ it "not a String or Regexp" do
256
+ lambda do
257
+ page_should_contain 123
258
+ end.should raise_error(ArgumentError)
259
+ end
260
+ end
261
+
262
+ end
263
+
264
+
265
+ describe Kelp::Visibility, "page_should_not_contain" do
266
+ before(:each) do
267
+ visit('/home')
268
+ end
269
+
270
+ context "passes when" do
271
+ context "String" do
272
+ it "does not exist" do
273
+ page_should_not_contain "Wazzup world"
274
+ end
275
+ end
276
+
277
+ context "Regexp" do
278
+ it "does not match" do
279
+ page_should_not_contain /(Foo|Bar|Baz) world/
280
+ end
281
+ end
282
+ end
283
+
284
+ context "fails when" do
285
+ context "String" do
286
+ it "exists" do
287
+ lambda do
288
+ page_should_not_contain "Hello world"
289
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
290
+ lambda do
291
+ page_should_not_contain "Goodbye world"
292
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
293
+ end
294
+ end
295
+ context "Regexp" do
296
+ it "matches" do
297
+ lambda do
298
+ page_should_not_contain /(Hello|Goodbye) world/
299
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
300
+ lambda do
301
+ page_should_not_contain /\d\d\d-\d\d\d\d/
302
+ end.should raise_error(RSpec::Expectations::ExpectationNotMetError)
303
+ end
304
+ end
305
+
306
+ it "not a String or Regexp" do
307
+ lambda do
308
+ page_should_not_contain 123
309
+ end.should raise_error(ArgumentError)
310
+ end
311
+ end
312
+
313
+ end
314
+
315
+