capybara_minitest_spec 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +4 -0
  3. data/.gitmodules +3 -0
  4. data/.rvmrc +1 -0
  5. data/Gemfile +7 -0
  6. data/README.md +31 -0
  7. data/Rakefile +9 -0
  8. data/capybara_minitest_spec.gemspec +25 -0
  9. data/lib/capybara_minitest_spec/version.rb +3 -0
  10. data/lib/capybara_minitest_spec.rb +45 -0
  11. data/test/matchers_spec.rb +447 -0
  12. data/test/spec_helper.rb +28 -0
  13. data/test_app/driver.rb +297 -0
  14. data/test_app/fixtures/capybara.jpg +3 -0
  15. data/test_app/fixtures/test_file.txt +1 -0
  16. data/test_app/public/test.js +43 -0
  17. data/test_app/session/all_spec.rb +78 -0
  18. data/test_app/session/attach_file_spec.rb +73 -0
  19. data/test_app/session/check_spec.rb +65 -0
  20. data/test_app/session/choose_spec.rb +26 -0
  21. data/test_app/session/click_button_spec.rb +304 -0
  22. data/test_app/session/click_link_or_button_spec.rb +36 -0
  23. data/test_app/session/click_link_spec.rb +119 -0
  24. data/test_app/session/current_host_spec.rb +68 -0
  25. data/test_app/session/current_url_spec.rb +15 -0
  26. data/test_app/session/fill_in_spec.rb +125 -0
  27. data/test_app/session/find_button_spec.rb +18 -0
  28. data/test_app/session/find_by_id_spec.rb +18 -0
  29. data/test_app/session/find_field_spec.rb +26 -0
  30. data/test_app/session/find_link_spec.rb +19 -0
  31. data/test_app/session/find_spec.rb +149 -0
  32. data/test_app/session/first_spec.rb +105 -0
  33. data/test_app/session/has_button_spec.rb +32 -0
  34. data/test_app/session/has_content_spec.rb +106 -0
  35. data/test_app/session/has_css_spec.rb +243 -0
  36. data/test_app/session/has_field_spec.rb +192 -0
  37. data/test_app/session/has_link_spec.rb +37 -0
  38. data/test_app/session/has_select_spec.rb +129 -0
  39. data/test_app/session/has_selector_spec.rb +129 -0
  40. data/test_app/session/has_table_spec.rb +96 -0
  41. data/test_app/session/has_xpath_spec.rb +123 -0
  42. data/test_app/session/headers.rb +19 -0
  43. data/test_app/session/javascript.rb +289 -0
  44. data/test_app/session/response_code.rb +19 -0
  45. data/test_app/session/select_spec.rb +113 -0
  46. data/test_app/session/text_spec.rb +19 -0
  47. data/test_app/session/uncheck_spec.rb +21 -0
  48. data/test_app/session/unselect_spec.rb +61 -0
  49. data/test_app/session/within_spec.rb +178 -0
  50. data/test_app/session.rb +154 -0
  51. data/test_app/test_app.rb +142 -0
  52. data/test_app/views/buttons.erb +4 -0
  53. data/test_app/views/fieldsets.erb +29 -0
  54. data/test_app/views/form.erb +365 -0
  55. data/test_app/views/frame_one.erb +8 -0
  56. data/test_app/views/frame_two.erb +8 -0
  57. data/test_app/views/header_links.erb +7 -0
  58. data/test_app/views/host_links.erb +12 -0
  59. data/test_app/views/popup_one.erb +8 -0
  60. data/test_app/views/popup_two.erb +8 -0
  61. data/test_app/views/postback.erb +13 -0
  62. data/test_app/views/tables.erb +122 -0
  63. data/test_app/views/with_html.erb +74 -0
  64. data/test_app/views/with_html_entities.erb +1 -0
  65. data/test_app/views/with_js.erb +48 -0
  66. data/test_app/views/with_scope.erb +36 -0
  67. data/test_app/views/with_simple_html.erb +1 -0
  68. data/test_app/views/within_frames.erb +10 -0
  69. data/test_app/views/within_popups.erb +25 -0
  70. metadata +158 -0
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "xpath"]
2
+ path = xpath
3
+ url = https://github.com/jnicklas/xpath.git
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use --create ruby-1.9.2-p0@capybara_minispec
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in capybara_minitest_spec.gemspec
4
+ gemspec
5
+
6
+ #@dependencies.delete_if {|d| d.name == "xpath" }
7
+ #gem 'xpath', :path => 'xpath'
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ Capybara MiniTest Spec
2
+ ======================
3
+
4
+ Define MiniTest::Spec expectations for Capybara node matchers.
5
+
6
+ Description
7
+ -----------
8
+
9
+ If you like using Capybara and RSpec, you're used to matchers like:
10
+
11
+ page.should have_content('Title')
12
+
13
+ Now you can have similar functionality while using MiniTest::Spec:
14
+
15
+ page.must_have_content('Title')
16
+
17
+ Compatibility
18
+ -------------
19
+
20
+ In theory, this should work with any version of Capybara, so the runtime dependency is not version specific. At the time of this writing, it was tested with Capybara 1.1.1.
21
+
22
+ TODO
23
+ ----
24
+
25
+ * Better failure messages.
26
+
27
+ Testing
28
+ -------
29
+
30
+ This gem was tested by copying the Capybara spec located in 'spec/rspec/matchers_spec.rb' and altering the test to run with MiniTest.
31
+ Capybara uses xpath as a submodule of the git repository. When adding this gem to gemtesters (http://test.rubygems.org/gems/capybara_minitest_spec), it sounded like too much trouble to check out the submodule, so I just used the regular gem.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/*_spec.rb'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "capybara_minitest_spec/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "capybara_minitest_spec"
7
+ s.version = CapybaraMinitestSpec::VERSION
8
+ s.authors = ["Jared Ning"]
9
+ s.email = ["jared@redningja.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{MiniTest::Spec expectations for Capybara node matchers.}
12
+ s.description = %q{MiniTest::Spec expectations for Capybara node matchers.}
13
+
14
+ s.rubyforge_project = "capybara_minitest_spec"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'capybara'
22
+ s.add_runtime_dependency 'minitest', '~> 2.0'
23
+
24
+ s.add_development_dependency 'sinatra', '>= 0.9.4'
25
+ end
@@ -0,0 +1,3 @@
1
+ module CapybaraMinitestSpec
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,45 @@
1
+ require "capybara_minitest_spec/version"
2
+
3
+ # Define assertions for each Capybara node matcher.
4
+ # Then define MiniTest::Spec expectations.
5
+ module MiniTest::Expectations
6
+
7
+ Capybara::Node::Matchers.public_instance_methods.each do |matcher_name|
8
+
9
+ without_question_mark = matcher_name.to_s.sub /\?$/, ''
10
+ have = without_question_mark.sub /has_/, 'have_'
11
+
12
+ # Define positive assertion.
13
+ positive_assertion_name = :"assert_page_#{without_question_mark}"
14
+ define_method positive_assertion_name do |page, *args|
15
+ assert wrap(page).send(matcher_name, *args), "Matcher #{without_question_mark} failed"
16
+ end
17
+
18
+ # Infect positive assertion.
19
+ positive_expectation_name = :"must_#{have}"
20
+ infect_an_assertion positive_assertion_name, positive_expectation_name, true
21
+
22
+ # Define negative assertion.
23
+ negative_assertion_name = :"refute_page_#{without_question_mark}"
24
+ define_method negative_assertion_name do |page, *args|
25
+ refute wrap(page).send(matcher_name, *args), "Matcher #{without_question_mark} should have failed"
26
+ end
27
+
28
+ # Infect negative assertions.
29
+ negative_expectation_name = :"wont_#{have}"
30
+ infect_an_assertion negative_assertion_name, negative_expectation_name, true
31
+
32
+ end
33
+
34
+ private
35
+
36
+ # Copied from Capybara::RSpecMatchers::HaveMatcher.
37
+ def wrap(actual)
38
+ if actual.respond_to?("has_selector?")
39
+ actual
40
+ else
41
+ Capybara.string(actual.to_s)
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,447 @@
1
+ require 'spec_helper'
2
+
3
+ describe CapybaraMinitestSpec do
4
+ include Capybara::DSL
5
+
6
+ describe "have_css matcher" do
7
+ describe "on a string" do
8
+ describe "with should" do
9
+ it "passes if has_css? returns true" do
10
+ "<h1>Text</h1>".must_have_css('h1')
11
+ end
12
+
13
+ it "fails if has_css? returns false" do
14
+ proc do
15
+ "<h1>Text</h1>".must_have_css('h2')
16
+ end.must_raise(/expected css "h2" to return something/)
17
+ end
18
+
19
+ it "passes if matched node count equals expected count" do
20
+ "<h1>Text</h1>".must_have_css('h1', :count => 1)
21
+ end
22
+
23
+ it "fails if matched node count does not equal expected count" do
24
+ proc do
25
+ "<h1>Text</h1>".must_have_css('h1', :count => 2)
26
+ end.must_raise(/expected css "h1" to return something/)
27
+ end
28
+ end
29
+
30
+ describe "with should_not" do
31
+ it "passes if has_no_css? returns true" do
32
+ "<h1>Text</h1>".wont_have_css('h2')
33
+ end
34
+
35
+ it "fails if has_no_css? returns false" do
36
+ proc do
37
+ "<h1>Text</h1>".wont_have_css('h1')
38
+ end.must_raise(/expected css "h1" not to return anything/)
39
+ end
40
+
41
+ it "passes if matched node count does not equal expected count" do
42
+ "<h1>Text</h1>".wont_have_css('h1', :count => 2)
43
+ end
44
+
45
+ it "fails if matched node count equals expected count" do
46
+ proc do
47
+ "<h1>Text</h1>".wont_have_css('h1', :count => 1)
48
+ end.must_raise(/expected css "h1" not to return anything/)
49
+ end
50
+ end
51
+ end
52
+
53
+ describe "on a page or node" do
54
+ before do
55
+ visit('/with_html')
56
+ end
57
+
58
+ describe "with should" do
59
+ it "passes if has_css? returns true" do
60
+ page.must_have_css('h1')
61
+ end
62
+
63
+ it "fails if has_css? returns false" do
64
+ proc do
65
+ page.must_have_css('h1#doesnotexist')
66
+ end.must_raise(/expected css "h1#doesnotexist" to return something/)
67
+ end
68
+ end
69
+
70
+ describe "with should_not" do
71
+ it "passes if has_no_css? returns true" do
72
+ page.wont_have_css('h1#doesnotexist')
73
+ end
74
+
75
+ it "fails if has_no_css? returns false" do
76
+ proc do
77
+ page.wont_have_css('h1')
78
+ end.must_raise(/expected css "h1" not to return anything/)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ describe "have_xpath matcher" do
85
+ describe "on a string" do
86
+ describe "with should" do
87
+ it "passes if has_css? returns true" do
88
+ "<h1>Text</h1>".must_have_xpath('//h1')
89
+ end
90
+
91
+ it "fails if has_css? returns false" do
92
+ proc do
93
+ "<h1>Text</h1>".must_have_xpath('//h2')
94
+ end.must_raise(%r(expected xpath "//h2" to return something))
95
+ end
96
+ end
97
+
98
+ describe "with should_not" do
99
+ it "passes if has_no_css? returns true" do
100
+ "<h1>Text</h1>".wont_have_xpath('//h2')
101
+ end
102
+
103
+ it "fails if has_no_css? returns false" do
104
+ proc do
105
+ "<h1>Text</h1>".wont_have_xpath('//h1')
106
+ end.must_raise(%r(expected xpath "//h1" not to return anything))
107
+ end
108
+ end
109
+ end
110
+
111
+ describe "on a page or node" do
112
+ before do
113
+ visit('/with_html')
114
+ end
115
+
116
+ describe "with should" do
117
+ it "passes if has_css? returns true" do
118
+ page.must_have_xpath('//h1')
119
+ end
120
+
121
+ it "fails if has_css? returns false" do
122
+ proc do
123
+ page.must_have_xpath("//h1[@id='doesnotexist']")
124
+ end.must_raise(%r(expected xpath "//h1\[@id='doesnotexist'\]" to return something))
125
+ end
126
+ end
127
+
128
+ describe "with should_not" do
129
+ it "passes if has_no_css? returns true" do
130
+ page.wont_have_xpath('//h1[@id="doesnotexist"]')
131
+ end
132
+
133
+ it "fails if has_no_css? returns false" do
134
+ proc do
135
+ page.wont_have_xpath('//h1')
136
+ end.must_raise(%r(expected xpath "//h1" not to return anything))
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ describe "have_selector matcher" do
143
+ describe "on a string" do
144
+ describe "with should" do
145
+ it "passes if has_css? returns true" do
146
+ assert Capybara.string("<h1>Text</h1>").has_selector?('//h1')
147
+ "<h1>Text</h1>".must_have_selector('//h1')
148
+ end
149
+
150
+ it "fails if has_css? returns false" do
151
+ proc do
152
+ "<h1>Text</h1>".must_have_selector('//h2')
153
+ end.must_raise(%r(expected xpath "//h2" to return something))
154
+ end
155
+
156
+ it "fails with the selector's failure_message if set" do
157
+ Capybara.add_selector(:monkey) do
158
+ xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
159
+ failure_message { |node, selector| node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
160
+ end
161
+ proc do
162
+ '<h1 id="monkey_paul">Monkey John</h1>'.must_have_selector(:monkey, 14)
163
+ end.must_raise("Monkey John")
164
+ end
165
+ end
166
+
167
+ describe "with should_not" do
168
+ it "passes if has_no_css? returns true" do
169
+ "<h1>Text</h1>".wont_have_selector(:css, 'h2')
170
+ end
171
+
172
+ it "fails if has_no_css? returns false" do
173
+ proc do
174
+ "<h1>Text</h1>".wont_have_selector(:css, 'h1')
175
+ end.must_raise(%r(expected css "h1" not to return anything))
176
+ end
177
+ end
178
+ end
179
+
180
+ describe "on a page or node" do
181
+ before do
182
+ visit('/with_html')
183
+ end
184
+
185
+ describe "with should" do
186
+ it "passes if has_css? returns true" do
187
+ page.must_have_selector('//h1', :text => 'test')
188
+ end
189
+
190
+ it "fails if has_css? returns false" do
191
+ proc do
192
+ page.must_have_selector("//h1[@id='doesnotexist']")
193
+ end.must_raise(%r(expected xpath "//h1\[@id='doesnotexist'\]" to return something))
194
+ end
195
+
196
+ it "includes text in error message" do
197
+ proc do
198
+ page.must_have_selector("//h1", :text => 'wrong text')
199
+ end.must_raise(%r(expected xpath "//h1" with text "wrong text" to return something))
200
+ end
201
+
202
+ it "fails with the selector's failure_message if set" do
203
+ Capybara.add_selector(:monkey) do
204
+ xpath { |num| ".//*[contains(@id, 'monkey')][#{num}]" }
205
+ failure_message { |node, selector| node.all(".//*[contains(@id, 'monkey')]").map { |node| node.text }.sort.join(', ') }
206
+ end
207
+ proc do
208
+ page.must_have_selector(:monkey, 14)
209
+ end.must_raise("Monkey John, Monkey Paul")
210
+ end
211
+ end
212
+
213
+ describe "with should_not" do
214
+ it "passes if has_no_css? returns true" do
215
+ page.wont_have_selector(:css, 'h1#doesnotexist')
216
+ end
217
+
218
+ it "fails if has_no_css? returns false" do
219
+ proc do
220
+ page.wont_have_selector(:css, 'h1', :text => 'test')
221
+ end.must_raise(%r(expected css "h1" with text "test" not to return anything))
222
+ end
223
+ end
224
+ end
225
+ end
226
+
227
+ describe "have_content matcher" do
228
+
229
+ describe "on a string" do
230
+ describe "with should" do
231
+ it "passes if has_css? returns true" do
232
+ "<h1>Text</h1>".must_have_content('Text')
233
+ end
234
+
235
+ it "fails if has_css? returns false" do
236
+ proc do
237
+ "<h1>Text</h1>".must_have_content('No such Text')
238
+ end.must_raise(/expected there to be content "No such Text" in "Text"/)
239
+ end
240
+ end
241
+
242
+ describe "with should_not" do
243
+ it "passes if has_no_css? returns true" do
244
+ "<h1>Text</h1>".wont_have_content('No such Text')
245
+ end
246
+
247
+ it "fails if has_no_css? returns false" do
248
+ proc do
249
+ "<h1>Text</h1>".wont_have_content('Text')
250
+ end.must_raise(/expected content "Text" not to return anything/)
251
+ end
252
+ end
253
+ end
254
+
255
+ describe "on a page or node" do
256
+ before do
257
+ visit('/with_html')
258
+ end
259
+
260
+ describe "with should" do
261
+ it "passes if has_css? returns true" do
262
+ page.must_have_content('This is a test')
263
+ end
264
+
265
+ it "fails if has_css? returns false" do
266
+ proc do
267
+ page.must_have_content('No such Text')
268
+ end.must_raise(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
269
+ end
270
+
271
+ describe "with default selector CSS" do
272
+ before { Capybara.default_selector = :css }
273
+ it "fails if has_css? returns false" do
274
+ proc do
275
+ page.must_have_content('No such Text')
276
+ end.must_raise(/expected there to be content "No such Text" in "(.*)This is a test(.*)"/)
277
+ end
278
+ after { Capybara.default_selector = :xpath }
279
+ end
280
+ end
281
+
282
+ describe "with should_not" do
283
+ it "passes if has_no_css? returns true" do
284
+ page.wont_have_content('No such Text')
285
+ end
286
+
287
+ it "fails if has_no_css? returns false" do
288
+ proc do
289
+ page.wont_have_content('This is a test')
290
+ end.must_raise(/expected content "This is a test" not to return anything/)
291
+ end
292
+ end
293
+ end
294
+ end
295
+
296
+ describe "have_link matcher" do
297
+ let(:html) { '<a href="#">Just a link</a>' }
298
+
299
+ it "passes if there is such a button" do
300
+ html.must_have_link('Just a link')
301
+ end
302
+
303
+ it "fails if there is no such button" do
304
+ proc do
305
+ html.must_have_link('No such Link')
306
+ end.must_raise(/expected link "No such Link"/)
307
+ end
308
+ end
309
+
310
+ describe "have_button matcher" do
311
+ let(:html) { '<button>A button</button><input type="submit" value="Another button"/>' }
312
+
313
+ it "passes if there is such a button" do
314
+ html.must_have_button('A button')
315
+ end
316
+
317
+ it "fails if there is no such button" do
318
+ proc do
319
+ html.must_have_button('No such Button')
320
+ end.must_raise(/expected button "No such Button"/)
321
+ end
322
+ end
323
+
324
+ describe "have_field matcher" do
325
+ let(:html) { '<p><label>Text field<input type="text"/></label></p>' }
326
+
327
+ it "passes if there is such a field" do
328
+ html.must_have_field('Text field')
329
+ end
330
+
331
+ it "fails if there is no such field" do
332
+ proc do
333
+ html.must_have_field('No such Field')
334
+ end.must_raise(/expected field "No such Field"/)
335
+ end
336
+ end
337
+
338
+ describe "have_checked_field matcher" do
339
+ let(:html) do
340
+ '<label>it is checked<input type="checkbox" checked="checked"/></label>
341
+ <label>unchecked field<input type="checkbox"/></label>'
342
+ end
343
+
344
+ describe "with should" do
345
+ it "passes if there is such a field and it is checked" do
346
+ html.must_have_checked_field('it is checked')
347
+ end
348
+
349
+ it "fails if there is such a field but it is not checked" do
350
+ proc do
351
+ html.must_have_checked_field('unchecked field')
352
+ end.must_raise(/expected checked_field "unchecked field"/)
353
+ end
354
+
355
+ it "fails if there is no such field" do
356
+ proc do
357
+ html.must_have_checked_field('no such field')
358
+ end.must_raise(/expected checked_field "no such field"/)
359
+ end
360
+ end
361
+
362
+ describe "with must_not" do
363
+ it "fails if there is such a field and it is checked" do
364
+ proc do
365
+ html.wont_have_checked_field('it is checked')
366
+ end.must_raise(/expected checked_field "it is checked" not to return anything/)
367
+ end
368
+
369
+ it "passes if there is such a field but it is not checked" do
370
+ html.wont_have_checked_field('unchecked field')
371
+ end
372
+
373
+ it "passes if there is no such field" do
374
+ html.wont_have_checked_field('no such field')
375
+ end
376
+ end
377
+ end
378
+
379
+ describe "have_unchecked_field matcher" do
380
+ let(:html) do
381
+ '<label>it is checked<input type="checkbox" checked="checked"/></label>
382
+ <label>unchecked field<input type="checkbox"/></label>'
383
+ end
384
+
385
+ describe "with should" do
386
+ it "passes if there is such a field and it is not checked" do
387
+ html.must_have_unchecked_field('unchecked field')
388
+ end
389
+
390
+ it "fails if there is such a field but it is checked" do
391
+ proc do
392
+ html.must_have_unchecked_field('it is checked')
393
+ end.must_raise(/expected unchecked_field "it is checked"/)
394
+ end
395
+
396
+ it "fails if there is no such field" do
397
+ proc do
398
+ html.must_have_unchecked_field('no such field')
399
+ end.must_raise(/expected unchecked_field "no such field"/)
400
+ end
401
+ end
402
+
403
+ describe "with must_not" do
404
+ it "fails if there is such a field and it is not checked" do
405
+ proc do
406
+ html.wont_have_unchecked_field('unchecked field')
407
+ end.must_raise(/expected unchecked_field "unchecked field" not to return anything/)
408
+ end
409
+
410
+ it "passes if there is such a field but it is checked" do
411
+ html.wont_have_unchecked_field('it is checked')
412
+ end
413
+
414
+ it "passes if there is no such field" do
415
+ html.wont_have_unchecked_field('no such field')
416
+ end
417
+ end
418
+ end
419
+
420
+ describe "have_select matcher" do
421
+ let(:html) { '<label>Select Box<select></select></label>' }
422
+
423
+ it "passes if there is such a select" do
424
+ html.must_have_select('Select Box')
425
+ end
426
+
427
+ it "fails if there is no such select" do
428
+ proc do
429
+ html.must_have_select('No such Select box')
430
+ end.must_raise(/expected select "No such Select box"/)
431
+ end
432
+ end
433
+
434
+ describe "have_table matcher" do
435
+ let(:html) { '<table><caption>Lovely table</caption></table>' }
436
+
437
+ it "passes if there is such a select" do
438
+ html.must_have_table('Lovely table')
439
+ end
440
+
441
+ it "fails if there is no such select" do
442
+ proc do
443
+ html.must_have_table('No such Table')
444
+ end.must_raise(/expected table "No such Table"/)
445
+ end
446
+ end
447
+ end
@@ -0,0 +1,28 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'minitest/autorun'
4
+ require 'capybara/dsl'
5
+
6
+ require 'capybara_minitest_spec'
7
+
8
+ MiniTest::Spec.register_spec_type //, MiniTest::Spec
9
+
10
+ $LOAD_PATH << File.join(__FILE__, '../../test_app')
11
+ require 'test_app'
12
+ Capybara.app = TestApp
13
+
14
+ class MiniTest::Spec
15
+ before :each do
16
+ Capybara.configure do |config|
17
+ config.default_selector = :xpath
18
+ end
19
+ end
20
+ end
21
+
22
+ class Proc
23
+ include MiniTest::Assertions
24
+ # TODO: Replace this with a real assertion that checks the message.
25
+ def must_raise(exception_or_message)
26
+ assert_raises(MiniTest::Assertion, &self)
27
+ end
28
+ end