nimboids-capybara 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/History.txt +289 -0
  2. data/README.rdoc +722 -0
  3. data/lib/capybara.rb +252 -0
  4. data/lib/capybara/cucumber.rb +28 -0
  5. data/lib/capybara/driver/base.rb +64 -0
  6. data/lib/capybara/driver/node.rb +74 -0
  7. data/lib/capybara/dsl.rb +168 -0
  8. data/lib/capybara/node/actions.rb +162 -0
  9. data/lib/capybara/node/base.rb +63 -0
  10. data/lib/capybara/node/document.rb +25 -0
  11. data/lib/capybara/node/element.rb +201 -0
  12. data/lib/capybara/node/finders.rb +197 -0
  13. data/lib/capybara/node/matchers.rb +417 -0
  14. data/lib/capybara/node/simple.rb +132 -0
  15. data/lib/capybara/rack_test/browser.rb +121 -0
  16. data/lib/capybara/rack_test/driver.rb +80 -0
  17. data/lib/capybara/rack_test/form.rb +80 -0
  18. data/lib/capybara/rack_test/node.rb +105 -0
  19. data/lib/capybara/rails.rb +17 -0
  20. data/lib/capybara/rspec.rb +26 -0
  21. data/lib/capybara/rspec/features.rb +22 -0
  22. data/lib/capybara/rspec/matchers.rb +154 -0
  23. data/lib/capybara/selector.rb +89 -0
  24. data/lib/capybara/selenium/driver.rb +163 -0
  25. data/lib/capybara/selenium/node.rb +91 -0
  26. data/lib/capybara/server.rb +90 -0
  27. data/lib/capybara/session.rb +321 -0
  28. data/lib/capybara/spec/driver.rb +301 -0
  29. data/lib/capybara/spec/fixtures/capybara.jpg +3 -0
  30. data/lib/capybara/spec/fixtures/test_file.txt +1 -0
  31. data/lib/capybara/spec/public/test.js +43 -0
  32. data/lib/capybara/spec/session.rb +154 -0
  33. data/lib/capybara/spec/session/all_spec.rb +78 -0
  34. data/lib/capybara/spec/session/attach_file_spec.rb +73 -0
  35. data/lib/capybara/spec/session/check_spec.rb +65 -0
  36. data/lib/capybara/spec/session/choose_spec.rb +26 -0
  37. data/lib/capybara/spec/session/click_button_spec.rb +304 -0
  38. data/lib/capybara/spec/session/click_link_or_button_spec.rb +36 -0
  39. data/lib/capybara/spec/session/click_link_spec.rb +119 -0
  40. data/lib/capybara/spec/session/current_host_spec.rb +68 -0
  41. data/lib/capybara/spec/session/current_url_spec.rb +15 -0
  42. data/lib/capybara/spec/session/fill_in_spec.rb +125 -0
  43. data/lib/capybara/spec/session/find_button_spec.rb +18 -0
  44. data/lib/capybara/spec/session/find_by_id_spec.rb +18 -0
  45. data/lib/capybara/spec/session/find_field_spec.rb +26 -0
  46. data/lib/capybara/spec/session/find_link_spec.rb +19 -0
  47. data/lib/capybara/spec/session/find_spec.rb +149 -0
  48. data/lib/capybara/spec/session/first_spec.rb +105 -0
  49. data/lib/capybara/spec/session/has_button_spec.rb +32 -0
  50. data/lib/capybara/spec/session/has_content_spec.rb +106 -0
  51. data/lib/capybara/spec/session/has_css_spec.rb +243 -0
  52. data/lib/capybara/spec/session/has_field_spec.rb +192 -0
  53. data/lib/capybara/spec/session/has_link_spec.rb +37 -0
  54. data/lib/capybara/spec/session/has_select_spec.rb +129 -0
  55. data/lib/capybara/spec/session/has_selector_spec.rb +129 -0
  56. data/lib/capybara/spec/session/has_table_spec.rb +96 -0
  57. data/lib/capybara/spec/session/has_xpath_spec.rb +123 -0
  58. data/lib/capybara/spec/session/headers.rb +19 -0
  59. data/lib/capybara/spec/session/javascript.rb +289 -0
  60. data/lib/capybara/spec/session/response_code.rb +19 -0
  61. data/lib/capybara/spec/session/select_spec.rb +113 -0
  62. data/lib/capybara/spec/session/text_spec.rb +19 -0
  63. data/lib/capybara/spec/session/uncheck_spec.rb +21 -0
  64. data/lib/capybara/spec/session/unselect_spec.rb +61 -0
  65. data/lib/capybara/spec/session/within_spec.rb +178 -0
  66. data/lib/capybara/spec/test_app.rb +142 -0
  67. data/lib/capybara/spec/views/buttons.erb +4 -0
  68. data/lib/capybara/spec/views/fieldsets.erb +29 -0
  69. data/lib/capybara/spec/views/form.erb +365 -0
  70. data/lib/capybara/spec/views/frame_one.erb +8 -0
  71. data/lib/capybara/spec/views/frame_two.erb +8 -0
  72. data/lib/capybara/spec/views/header_links.erb +7 -0
  73. data/lib/capybara/spec/views/host_links.erb +12 -0
  74. data/lib/capybara/spec/views/popup_one.erb +8 -0
  75. data/lib/capybara/spec/views/popup_two.erb +8 -0
  76. data/lib/capybara/spec/views/postback.erb +13 -0
  77. data/lib/capybara/spec/views/tables.erb +122 -0
  78. data/lib/capybara/spec/views/with_html.erb +78 -0
  79. data/lib/capybara/spec/views/with_html_entities.erb +1 -0
  80. data/lib/capybara/spec/views/with_js.erb +48 -0
  81. data/lib/capybara/spec/views/with_scope.erb +36 -0
  82. data/lib/capybara/spec/views/with_simple_html.erb +1 -0
  83. data/lib/capybara/spec/views/within_frames.erb +10 -0
  84. data/lib/capybara/spec/views/within_popups.erb +25 -0
  85. data/lib/capybara/util/save_and_open_page.rb +44 -0
  86. data/lib/capybara/util/timeout.rb +27 -0
  87. data/lib/capybara/version.rb +3 -0
  88. data/spec/basic_node_spec.rb +77 -0
  89. data/spec/capybara_spec.rb +46 -0
  90. data/spec/driver/rack_test_driver_spec.rb +89 -0
  91. data/spec/driver/selenium_driver_spec.rb +50 -0
  92. data/spec/dsl_spec.rb +253 -0
  93. data/spec/fixtures/selenium_driver_rspec_failure.rb +8 -0
  94. data/spec/fixtures/selenium_driver_rspec_success.rb +8 -0
  95. data/spec/rspec/features_spec.rb +45 -0
  96. data/spec/rspec/matchers_spec.rb +495 -0
  97. data/spec/rspec_spec.rb +53 -0
  98. data/spec/save_and_open_page_spec.rb +155 -0
  99. data/spec/server_spec.rb +89 -0
  100. data/spec/session/rack_test_session_spec.rb +55 -0
  101. data/spec/session/selenium_session_spec.rb +26 -0
  102. data/spec/spec_helper.rb +30 -0
  103. data/spec/string_spec.rb +77 -0
  104. data/spec/timeout_spec.rb +28 -0
  105. metadata +346 -0
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Capybara::Selenium::Driver do
4
+ it "should exit with a zero exit status" do
5
+ browser = Capybara::Selenium::Driver.new(TestApp).browser
6
+ true.should == true
7
+ end
8
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'capybara/rspec'
3
+
4
+ Capybara.app = TestApp
5
+
6
+ RSpec.configuration.before(:each, :example_group => {:file_path => __FILE__}) do
7
+ @in_filtered_hook = true
8
+ end
9
+
10
+ feature "Capybara's feature DSL" do
11
+ background do
12
+ @in_background = true
13
+ end
14
+
15
+ scenario "includes Capybara" do
16
+ visit('/')
17
+ page.should have_content('Hello world!')
18
+ end
19
+
20
+ scenario "preserves description" do
21
+ example.metadata[:full_description].should == "Capybara's feature DSL preserves description"
22
+ end
23
+
24
+ scenario "allows driver switching", :driver => :selenium do
25
+ Capybara.current_driver.should == :selenium
26
+ end
27
+
28
+ scenario "runs background" do
29
+ @in_background.should be_true
30
+ end
31
+
32
+ scenario "runs hooks filtered by file path" do
33
+ @in_filtered_hook.should be_true
34
+ end
35
+
36
+ scenario "doesn't pollute the Object namespace" do
37
+ Object.new.respond_to?(:feature, true).should be_false
38
+ end
39
+ end
40
+
41
+ feature "Capybara's feature DSL with driver", :driver => :culerity do
42
+ scenario "switches driver" do
43
+ Capybara.current_driver.should == :culerity
44
+ end
45
+ end
@@ -0,0 +1,495 @@
1
+ require 'spec_helper'
2
+ require 'capybara/dsl'
3
+ require 'capybara/rspec/matchers'
4
+
5
+ Capybara.app = TestApp
6
+
7
+ describe Capybara::RSpecMatchers do
8
+ include Capybara::DSL
9
+ include Capybara::RSpecMatchers
10
+
11
+ describe "have_css matcher" do
12
+ it "gives proper description" do
13
+ have_css('h1').description.should == "has css \"h1\""
14
+ end
15
+
16
+ context "on a string" do
17
+ context "with should" do
18
+ it "passes if has_css? returns true" do
19
+ "<h1>Text</h1>".should have_css('h1')
20
+ end
21
+
22
+ it "fails if has_css? returns false" do
23
+ expect do
24
+ "<h1>Text</h1>".should have_css('h2')
25
+ end.to raise_error(/expected css "h2" to return something/)
26
+ end
27
+
28
+ it "passes if matched node count equals expected count" do
29
+ "<h1>Text</h1>".should have_css('h1', :count => 1)
30
+ end
31
+
32
+ it "fails if matched node count does not equal expected count" do
33
+ expect do
34
+ "<h1>Text</h1>".should have_css('h1', :count => 2)
35
+ end.to raise_error(/expected css "h1" to return something/)
36
+ end
37
+ end
38
+
39
+ context "with should_not" do
40
+ it "passes if has_no_css? returns true" do
41
+ "<h1>Text</h1>".should_not have_css('h2')
42
+ end
43
+
44
+ it "fails if has_no_css? returns false" do
45
+ expect do
46
+ "<h1>Text</h1>".should_not have_css('h1')
47
+ end.to raise_error(/expected css "h1" not to return anything/)
48
+ end
49
+
50
+ it "passes if matched node count does not equal expected count" do
51
+ "<h1>Text</h1>".should_not have_css('h1', :count => 2)
52
+ end
53
+
54
+ it "fails if matched node count equals expected count" do
55
+ expect do
56
+ "<h1>Text</h1>".should_not have_css('h1', :count => 1)
57
+ end.to raise_error(/expected css "h1" not to return anything/)
58
+ end
59
+ end
60
+ end
61
+
62
+ context "on a page or node" do
63
+ before do
64
+ visit('/with_html')
65
+ end
66
+
67
+ context "with should" do
68
+ it "passes if has_css? returns true" do
69
+ page.should have_css('h1')
70
+ end
71
+
72
+ it "fails if has_css? returns false" do
73
+ expect do
74
+ page.should have_css('h1#doesnotexist')
75
+ end.to raise_error(/expected css "h1#doesnotexist" to return something/)
76
+ end
77
+ end
78
+
79
+ context "with should_not" do
80
+ it "passes if has_no_css? returns true" do
81
+ page.should_not have_css('h1#doesnotexist')
82
+ end
83
+
84
+ it "fails if has_no_css? returns false" do
85
+ expect do
86
+ page.should_not have_css('h1')
87
+ end.to raise_error(/expected css "h1" not to return anything/)
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "have_xpath matcher" do
94
+ it "gives proper description" do
95
+ have_xpath('//h1').description.should == "has xpath \"\/\/h1\""
96
+ end
97
+
98
+ context "on a string" do
99
+ context "with should" do
100
+ it "passes if has_css? returns true" do
101
+ "<h1>Text</h1>".should have_xpath('//h1')
102
+ end
103
+
104
+ it "fails if has_css? returns false" do
105
+ expect do
106
+ "<h1>Text</h1>".should have_xpath('//h2')
107
+ end.to raise_error(%r(expected xpath "//h2" to return something))
108
+ end
109
+ end
110
+
111
+ context "with should_not" do
112
+ it "passes if has_no_css? returns true" do
113
+ "<h1>Text</h1>".should_not have_xpath('//h2')
114
+ end
115
+
116
+ it "fails if has_no_css? returns false" do
117
+ expect do
118
+ "<h1>Text</h1>".should_not have_xpath('//h1')
119
+ end.to raise_error(%r(expected xpath "//h1" not to return anything))
120
+ end
121
+ end
122
+ end
123
+
124
+ context "on a page or node" do
125
+ before do
126
+ visit('/with_html')
127
+ end
128
+
129
+ context "with should" do
130
+ it "passes if has_css? returns true" do
131
+ page.should have_xpath('//h1')
132
+ end
133
+
134
+ it "fails if has_css? returns false" do
135
+ expect do
136
+ page.should have_xpath("//h1[@id='doesnotexist']")
137
+ end.to raise_error(%r(expected xpath "//h1\[@id='doesnotexist'\]" to return something))
138
+ end
139
+ end
140
+
141
+ context "with should_not" do
142
+ it "passes if has_no_css? returns true" do
143
+ page.should_not have_xpath('//h1[@id="doesnotexist"]')
144
+ end
145
+
146
+ it "fails if has_no_css? returns false" do
147
+ expect do
148
+ page.should_not have_xpath('//h1')
149
+ end.to raise_error(%r(expected xpath "//h1" not to return anything))
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ describe "have_selector matcher" do
156
+ it "gives proper description" do
157
+ have_selector('//h1').description.should == "has xpath \"//h1\""
158
+ end
159
+
160
+ context "on a string" do
161
+ context "with should" do
162
+ it "passes if has_css? returns true" do
163
+ "<h1>Text</h1>".should have_selector('//h1')
164
+ end
165
+
166
+ it "fails if has_css? returns false" do
167
+ expect do
168
+ "<h1>Text</h1>".should have_selector('//h2')
169
+ end.to raise_error(%r(expected xpath "//h2" to return something))
170
+ end
171
+
172
+ it "fails with the selector's failure_message if set" do
173
+ Capybara.add_selector(:monkey) do
174
+ xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
175
+ failure_message { |node, selector| node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
176
+ end
177
+ expect do
178
+ '<h1 id="monkey_paul">Monkey John</h1>'.should have_selector(:monkey, 14)
179
+ end.to raise_error("Monkey John")
180
+ end
181
+ end
182
+
183
+ context "with should_not" do
184
+ it "passes if has_no_css? returns true" do
185
+ "<h1>Text</h1>".should_not have_selector(:css, 'h2')
186
+ end
187
+
188
+ it "fails if has_no_css? returns false" do
189
+ expect do
190
+ "<h1>Text</h1>".should_not have_selector(:css, 'h1')
191
+ end.to raise_error(%r(expected css "h1" not to return anything))
192
+ end
193
+ end
194
+ end
195
+
196
+ context "on a page or node" do
197
+ before do
198
+ visit('/with_html')
199
+ end
200
+
201
+ context "with should" do
202
+ it "passes if has_css? returns true" do
203
+ page.should have_selector('//h1', :text => 'test')
204
+ end
205
+
206
+ it "fails if has_css? returns false" do
207
+ expect do
208
+ page.should have_selector("//h1[@id='doesnotexist']")
209
+ end.to raise_error(%r(expected xpath "//h1\[@id='doesnotexist'\]" to return something))
210
+ end
211
+
212
+ it "includes text in error message" do
213
+ expect do
214
+ page.should have_selector("//h1", :text => 'wrong text')
215
+ end.to raise_error(%r(expected xpath "//h1" with text "wrong text" to return something))
216
+ end
217
+
218
+ it "fails with the selector's failure_message if set" do
219
+ Capybara.add_selector(:monkey) do
220
+ xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
221
+ failure_message { |node, selector| node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
222
+ end
223
+ expect do
224
+ page.should have_selector(:monkey, 14)
225
+ end.to raise_error("Monkey John, Monkey Paul")
226
+ end
227
+ end
228
+
229
+ context "with should_not" do
230
+ it "passes if has_no_css? returns true" do
231
+ page.should_not have_selector(:css, 'h1#doesnotexist')
232
+ end
233
+
234
+ it "fails if has_no_css? returns false" do
235
+ expect do
236
+ page.should_not have_selector(:css, 'h1', :text => 'test')
237
+ end.to raise_error(%r(expected css "h1" with text "test" not to return anything))
238
+ end
239
+ end
240
+ end
241
+ end
242
+
243
+ describe "have_content matcher" do
244
+ it "gives proper description" do
245
+ have_content('Text').description.should == "has content \"Text\""
246
+ end
247
+
248
+ context "on a string" do
249
+ context "with should" do
250
+ it "passes if has_css? returns true" do
251
+ "<h1>Text</h1>".should have_content('Text')
252
+ end
253
+
254
+ it "fails if has_css? returns false" do
255
+ expect do
256
+ "<h1>Text</h1>".should have_content('No such Text')
257
+ end.to raise_error(/expected there to be content "No such Text" in "Text"/)
258
+ end
259
+ end
260
+
261
+ context "with should_not" do
262
+ it "passes if has_no_css? returns true" do
263
+ "<h1>Text</h1>".should_not have_content('No such Text')
264
+ end
265
+
266
+ it "fails if has_no_css? returns false" do
267
+ expect do
268
+ "<h1>Text</h1>".should_not have_content('Text')
269
+ end.to raise_error(/expected content "Text" not to return anything/)
270
+ end
271
+ end
272
+ end
273
+
274
+ context "on a page or node" do
275
+ before do
276
+ visit('/with_html')
277
+ end
278
+
279
+ context "with should" do
280
+ it "passes if has_css? returns true" do
281
+ page.should have_content('This is a test')
282
+ end
283
+
284
+ it "fails if has_css? returns false" do
285
+ expect do
286
+ page.should have_content('No such Text')
287
+ end.to raise_error(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
288
+ end
289
+
290
+ context "with default selector CSS" do
291
+ before { Capybara.default_selector = :css }
292
+ it "fails if has_css? returns false" do
293
+ expect do
294
+ page.should have_content('No such Text')
295
+ end.to raise_error(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
296
+ end
297
+ after { Capybara.default_selector = :xpath }
298
+ end
299
+ end
300
+
301
+ context "with should_not" do
302
+ it "passes if has_no_css? returns true" do
303
+ page.should_not have_content('No such Text')
304
+ end
305
+
306
+ it "fails if has_no_css? returns false" do
307
+ expect do
308
+ page.should_not have_content('This is a test')
309
+ end.to raise_error(/expected content "This is a test" not to return anything/)
310
+ end
311
+ end
312
+ end
313
+ end
314
+
315
+ describe "have_link matcher" do
316
+ let(:html) { '<a href="#">Just a link</a>' }
317
+
318
+ it "gives proper description" do
319
+ have_link('Just a link').description.should == "has link \"Just a link\""
320
+ end
321
+
322
+ it "passes if there is such a button" do
323
+ html.should have_link('Just a link')
324
+ end
325
+
326
+ it "fails if there is no such button" do
327
+ expect do
328
+ html.should have_link('No such Link')
329
+ end.to raise_error(/expected link "No such Link"/)
330
+ end
331
+ end
332
+
333
+ describe "have_button matcher" do
334
+ let(:html) { '<button>A button</button><input type="submit" value="Another button"/>' }
335
+
336
+ it "gives proper description" do
337
+ have_button('A button').description.should == "has button \"A button\""
338
+ end
339
+
340
+ it "passes if there is such a button" do
341
+ html.should have_button('A button')
342
+ end
343
+
344
+ it "fails if there is no such button" do
345
+ expect do
346
+ html.should have_button('No such Button')
347
+ end.to raise_error(/expected button "No such Button"/)
348
+ end
349
+ end
350
+
351
+ describe "have_field matcher" do
352
+ let(:html) { '<p><label>Text field<input type="text"/></label></p>' }
353
+
354
+ it "gives proper description" do
355
+ have_field('Text field').description.should == "has field \"Text field\""
356
+ end
357
+
358
+ it "passes if there is such a field" do
359
+ html.should have_field('Text field')
360
+ end
361
+
362
+ it "fails if there is no such field" do
363
+ expect do
364
+ html.should have_field('No such Field')
365
+ end.to raise_error(/expected field "No such Field"/)
366
+ end
367
+ end
368
+
369
+ describe "have_checked_field matcher" do
370
+ let(:html) do
371
+ '<label>it is checked<input type="checkbox" checked="checked"/></label>
372
+ <label>unchecked field<input type="checkbox"/></label>'
373
+ end
374
+
375
+ it "gives proper description" do
376
+ have_checked_field('it is checked').description.should == "has checked_field \"it is checked\""
377
+ end
378
+
379
+ context "with should" do
380
+ it "passes if there is such a field and it is checked" do
381
+ html.should have_checked_field('it is checked')
382
+ end
383
+
384
+ it "fails if there is such a field but it is not checked" do
385
+ expect do
386
+ html.should have_checked_field('unchecked field')
387
+ end.to raise_error(/expected checked_field "unchecked field"/)
388
+ end
389
+
390
+ it "fails if there is no such field" do
391
+ expect do
392
+ html.should have_checked_field('no such field')
393
+ end.to raise_error(/expected checked_field "no such field"/)
394
+ end
395
+ end
396
+
397
+ context "with should not" do
398
+ it "fails if there is such a field and it is checked" do
399
+ expect do
400
+ html.should_not have_checked_field('it is checked')
401
+ end.to raise_error(/expected checked_field "it is checked" not to return anything/)
402
+ end
403
+
404
+ it "passes if there is such a field but it is not checked" do
405
+ html.should_not have_checked_field('unchecked field')
406
+ end
407
+
408
+ it "passes if there is no such field" do
409
+ html.should_not have_checked_field('no such field')
410
+ end
411
+ end
412
+ end
413
+
414
+ describe "have_unchecked_field matcher" do
415
+ let(:html) do
416
+ '<label>it is checked<input type="checkbox" checked="checked"/></label>
417
+ <label>unchecked field<input type="checkbox"/></label>'
418
+ end
419
+
420
+ it "gives proper description" do
421
+ have_unchecked_field('unchecked field').description.should == "has unchecked_field \"unchecked field\""
422
+ end
423
+
424
+ context "with should" do
425
+ it "passes if there is such a field and it is not checked" do
426
+ html.should have_unchecked_field('unchecked field')
427
+ end
428
+
429
+ it "fails if there is such a field but it is checked" do
430
+ expect do
431
+ html.should have_unchecked_field('it is checked')
432
+ end.to raise_error(/expected unchecked_field "it is checked"/)
433
+ end
434
+
435
+ it "fails if there is no such field" do
436
+ expect do
437
+ html.should have_unchecked_field('no such field')
438
+ end.to raise_error(/expected unchecked_field "no such field"/)
439
+ end
440
+ end
441
+
442
+ context "with should not" do
443
+ it "fails if there is such a field and it is not checked" do
444
+ expect do
445
+ html.should_not have_unchecked_field('unchecked field')
446
+ end.to raise_error(/expected unchecked_field "unchecked field" not to return anything/)
447
+ end
448
+
449
+ it "passes if there is such a field but it is checked" do
450
+ html.should_not have_unchecked_field('it is checked')
451
+ end
452
+
453
+ it "passes if there is no such field" do
454
+ html.should_not have_unchecked_field('no such field')
455
+ end
456
+ end
457
+ end
458
+
459
+ describe "have_select matcher" do
460
+ let(:html) { '<label>Select Box<select></select></label>' }
461
+
462
+ it "gives proper description" do
463
+ have_select('Select Box').description.should == "has select \"Select Box\""
464
+ end
465
+
466
+ it "passes if there is such a select" do
467
+ html.should have_select('Select Box')
468
+ end
469
+
470
+ it "fails if there is no such select" do
471
+ expect do
472
+ html.should have_select('No such Select box')
473
+ end.to raise_error(/expected select "No such Select box"/)
474
+ end
475
+ end
476
+
477
+ describe "have_table matcher" do
478
+ let(:html) { '<table><caption>Lovely table</caption></table>' }
479
+
480
+ it "gives proper description" do
481
+ have_table('Lovely table').description.should == "has table \"Lovely table\""
482
+ end
483
+
484
+ it "passes if there is such a select" do
485
+ html.should have_table('Lovely table')
486
+ end
487
+
488
+ it "fails if there is no such select" do
489
+ expect do
490
+ html.should have_table('No such Table')
491
+ end.to raise_error(/expected table "No such Table"/)
492
+ end
493
+ end
494
+ end
495
+