minitest_log 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 414ff4a477e41ee42d0562f91553039206e280d6250724b3382229de9d75be34
4
+ data.tar.gz: 025cccda92e9489e10b44b94d4a49682e6398f834807eecd056d2ce38c599649
5
+ SHA512:
6
+ metadata.gz: ace6b6191de2af3509156473668f19c7ad73cbce2501922114bd23b4d0b549c850f37497a8dea1c906a50f7d887bc3221751cce0fd8673a3dc4be69c96ba1fee
7
+ data.tar.gz: c6992df8fd2ba3725b3467daf9132dd7950ea0eab350e573ea64427802fc8ac0d8481ab4b7d687113944d345e25524091905412f3fdab212094fa1567fd6ff51
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /.idea
2
+ /pkg/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.6
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at burdettelamar@yahoo.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in minitest_log.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ minitest_log (0.1.0)
5
+ diff-lcs (~> 1.3)
6
+ minitest (~> 5.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ markdown_helper (2.1.0)
13
+ minitest (5.11.3)
14
+ rake (10.5.0)
15
+
16
+ PLATFORMS
17
+ x64-mingw32
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.7)
21
+ markdown_helper (~> 2.0)
22
+ minitest_log!
23
+ rake (~> 10.0)
24
+
25
+ BUNDLED WITH
26
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 burdettelamar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2579 @@
1
+ # MinitestLog
2
+
3
+
4
+ ```MinitestLog``` gives you three things:
5
+
6
+ - **Nested sections:** Use nested sections to structure your test (and, importantly, its log), so that the test can "tell its story" clearly.
7
+ - **Data explication:** Use data-logging methods to log objects. Most collections (```Aray```, ```Hash```, etc.) are automatically logged in detail.
8
+ - **(And of course) Verdicts:** Use verdict methods to express assertions. Details for the verdict are logged, whether passed or failed.
9
+
10
+ ## Contents
11
+ - [Logs and Sections](#logs-and-sections)
12
+ - [Nested Sections](#nested-sections)
13
+ - [Text](#text)
14
+ - [Formatted Text](#formatted-text)
15
+ - [Attributes](#attributes)
16
+ - [Timestamps and Durations](#timestamps-and-durations)
17
+ - [Rescue](#rescue)
18
+ - [Unrescued Exception](#unrescued-exception)
19
+ - [Potpourri](#potpourri)
20
+ - [Custom Elements](#custom-elements)
21
+ - [Options](#options)
22
+ - [Root Name](#root-name)
23
+ - [XML Indentation](#xml-indentation)
24
+ - [Summary](#summary)
25
+ - [Error Verdict](#error-verdict)
26
+ - [Data](#data)
27
+ - [Strings](#strings)
28
+ - [Hash-Like Objects](#hash-like-objects)
29
+ - [Array-Like Objects](#array-like-objects)
30
+ - [Other Objects](#other-objects)
31
+ - [Verdicts](#verdicts)
32
+ - [Assert Verdicts](#assert-verdicts)
33
+ - [verdict_assert?](#verdict_assert)
34
+ - [verdict_assert_empty?](#verdict_assert_empty)
35
+ - [verdict_assert_equal?](#verdict_assert_equal)
36
+ - [verdict_assert_in_delta?](#verdict_assert_in_delta)
37
+ - [verdict_assert_in_epsilon?](#verdict_assert_in_epsilon)
38
+ - [verdict_assert_includes?](#verdict_assert_includes)
39
+ - [verdict_assert_instance_of?](#verdict_assert_instance_of)
40
+ - [verdict_assert_kind_of?](#verdict_assert_kind_of)
41
+ - [verdict_assert_match?](#verdict_assert_match)
42
+ - [verdict_assert_nil?](#verdict_assert_nil)
43
+ - [verdict_assert_operator?](#verdict_assert_operator)
44
+ - [verdict_assert_output?](#verdict_assert_output)
45
+ - [verdict_assert_predicate?](#verdict_assert_predicate)
46
+ - [verdict_assert_raises?](#verdict_assert_raises)
47
+ - [verdict_assert_respond_to?](#verdict_assert_respond_to)
48
+ - [verdict_assert_same?](#verdict_assert_same)
49
+ - [verdict_assert_silent?](#verdict_assert_silent)
50
+ - [verdict_assert_throws?](#verdict_assert_throws)
51
+ - [Refute Verdicts](#refute-verdicts)
52
+ - [verdict_refute?](#verdict_refute)
53
+ - [verdict_refute_empty?](#verdict_refute_empty)
54
+ - [verdict_refute_equal?](#verdict_refute_equal)
55
+ - [verdict_refute_in_delta?](#verdict_refute_in_delta)
56
+ - [verdict_refute_in_epsilon?](#verdict_refute_in_epsilon)
57
+ - [verdict_refute_includes?](#verdict_refute_includes)
58
+ - [verdict_refute_instance_of?](#verdict_refute_instance_of)
59
+ - [verdict_refute_kind_of?](#verdict_refute_kind_of)
60
+ - [verdict_refute_match?](#verdict_refute_match)
61
+ - [verdict_refute_nil?](#verdict_refute_nil)
62
+ - [verdict_refute_operator?](#verdict_refute_operator)
63
+ - [verdict_refute_predicate?](#verdict_refute_predicate)
64
+ - [verdict_refute_respond_to?](#verdict_refute_respond_to)
65
+ - [verdict_refute_same?](#verdict_refute_same)
66
+ - [Tips](#tips)
67
+ - [Use Short Verdict Aliases](#use-short-verdict-aliases)
68
+ - [Avoid Failure Clutter](#avoid-failure-clutter)
69
+ - [Facilitate Post-Processing](#facilitate-post-processing)
70
+
71
+ ## Logs and Sections
72
+
73
+ ### Nested Sections
74
+
75
+ Use nested sections to give structure to your test -- and its log.
76
+
77
+ In calling method ```section```, the first argument is the section name. Any following string arguments become text.
78
+
79
+ ```example.rb```:
80
+ ```ruby
81
+ require 'minitest_log'
82
+ class Example < MiniTest::Test
83
+ def test_example
84
+ MinitestLog.new('log.xml') do |log|
85
+ log.section('My nested sections', 'Sections can nest.') do
86
+ log.section('Outer', 'Outer section.') do
87
+ log.section('Mid', 'Mid-level section') do
88
+ log.section('Inner', 'Inner section.')
89
+ log.section('Another','Another inner section.')
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ ```
97
+
98
+ ```log.xml```:
99
+ ```xml
100
+ <log>
101
+ <section_ name='My nested sections'>
102
+ Sections can nest.
103
+ <section_ name='Outer'>
104
+ Outer section.
105
+ <section_ name='Mid'>
106
+ Mid-level section
107
+ <section_ name='Inner'>
108
+ Inner section.
109
+ </section_>
110
+ <section_ name='Another'>
111
+ Another inner section.
112
+ </section_>
113
+ </section_>
114
+ </section_>
115
+ </section_>
116
+ </log>
117
+ ```
118
+
119
+ ### Text
120
+
121
+ Put text onto a section by calling method ```section``` with string arguments.
122
+
123
+ As before, the first argument is the section name; other string arguments become text.
124
+
125
+ Multiple string arguments are concatenated into the text.
126
+
127
+ Note that you can also put text onto a section by calling method ```put_data```. See [Data](#data) below.
128
+
129
+ ```example.rb```:
130
+ ```ruby
131
+ require 'minitest_log'
132
+ class Example < MiniTest::Test
133
+ def test_example
134
+ MinitestLog.new('log.xml') do |log|
135
+ log.section('My section', 'Text for my section.') do
136
+ log.section('Another section', 'Text for another section.', ' More text.')
137
+ end
138
+ end
139
+ end
140
+ end
141
+ ```
142
+
143
+ ```log.xml```:
144
+ ```xml
145
+ <log>
146
+ <section_ name='My section'>
147
+ Text for my section.
148
+ <section_ name='Another section'>
149
+ Text for another section. More text.
150
+ </section_>
151
+ </section_>
152
+ </log>
153
+ ```
154
+
155
+
156
+ ### Formatted Text
157
+
158
+ Put formatted text onto a section by calling method ```put_pre```.
159
+
160
+ Whitespace, including newlines, is preserved.
161
+
162
+ The formatted text in the log is more readable if it begins and ends with suitable whitespace, so by default the method displays the text with enhanced whitespace if needed.
163
+
164
+ You can specify ```verbatim = true``` to suppress the enhancement.
165
+
166
+ ```example.rb```:
167
+ ```ruby
168
+ require 'minitest_log'
169
+ class Example < MiniTest::Test
170
+
171
+ def test_example
172
+ MinitestLog.new('log.xml') do |log|
173
+ log.section('Line of text with leading and trailing whitespace') do
174
+ log.put_pre(' Text. ')
175
+ end
176
+ text = <<EOT
177
+ Text
178
+ and
179
+ more
180
+ text.
181
+ EOT
182
+ log.section('Multiline text with enhanced whitespace') do
183
+ log.put_pre(text)
184
+ end
185
+ log.section('Multiline text without without enhanced whitespace') do
186
+ log.put_pre(text, verbatim = true)
187
+ end
188
+ end
189
+ end
190
+ end
191
+ ```
192
+
193
+ ```log.xml```:
194
+ ```xml
195
+ <log>
196
+ <section_ name='Line of text with leading and trailing whitespace'>
197
+ <![CDATA[
198
+ Text.
199
+ ]]>
200
+ </section_>
201
+ <section_ name='Multiline text with enhanced whitespace'>
202
+ <![CDATA[
203
+ Text
204
+ and
205
+ more
206
+ text.
207
+ ]]>
208
+ </section_>
209
+ <section_ name='Multiline text without without enhanced whitespace'>
210
+ <![CDATA[Text
211
+ and
212
+ more
213
+ text.]]>
214
+ </section_>
215
+ </log>
216
+ ```
217
+
218
+
219
+ ### Attributes
220
+
221
+ Put attributes onto a section by calling ```section``` with hash arguments.
222
+
223
+ Each name/value pair in a hash becomes an attribute in the log section element.
224
+
225
+ The first argument is always the section name. Following hash arguments become attributes.
226
+
227
+ ```example.rb```:
228
+ ```ruby
229
+ require 'minitest_log'
230
+ class Example < MiniTest::Test
231
+ def test_example
232
+ MinitestLog.new('log.xml') do |log|
233
+ attrs = {:first_attr => 'first', :second_attr => 'second'}
234
+ log.section('My section with attributes', attrs, 'A Hash becomes attributes.')
235
+ more_attrs = {:third_attr => 'third'}
236
+ log.section('My section with more attributes', attrs, more_attrs, 'More attributes.')
237
+ end
238
+ end
239
+ end
240
+ ```
241
+
242
+ ```log.xml```:
243
+ ```xml
244
+ <log>
245
+ <section_ name='My section with attributes' first_attr='first' second_attr='second'>
246
+ A Hash becomes attributes.
247
+ </section_>
248
+ <section_ name='My section with more attributes' first_attr='first' second_attr='second' third_attr='third'>
249
+ More attributes.
250
+ </section_>
251
+ </log>
252
+ ```
253
+
254
+ ### Timestamps and Durations
255
+
256
+ Use symbol ```:timestamp``` or ```:duration``` to add a timestamp or a duration to a section.
257
+
258
+ ```example.rb```:
259
+ ```ruby
260
+ require 'minitest_log'
261
+ class Example < MiniTest::Test
262
+ def test_example
263
+ MinitestLog.new('log.xml') do |log|
264
+ log.section('My section with timestamp', :timestamp, 'Section with timestamp.')
265
+ log.section('My section with duration', :duration, 'Section with duration.') do
266
+ sleep(0.5)
267
+ end
268
+ log.section('My section with both', :duration, :timestamp, 'Section with both.') do
269
+ sleep(0.5)
270
+ end
271
+ end
272
+ end
273
+ end
274
+ ```
275
+
276
+ ```log.xml```:
277
+ ```xml
278
+ <log>
279
+ <section_ name='My section with timestamp' timestamp='2019-05-05-Sun-14.00.27.776'>
280
+ Section with timestamp.
281
+ </section_>
282
+ <section_ name='My section with duration' duration_seconds='0.500'>
283
+ Section with duration.
284
+ </section_>
285
+ <section_ name='My section with both' timestamp='2019-05-05-Sun-14.00.28.277' duration_seconds='0.500'>
286
+ Section with both.
287
+ </section_>
288
+ </log>
289
+ ```
290
+
291
+ ### Rescue
292
+
293
+ Rescue a section using the symbol ```:rescue```.
294
+
295
+ Any exception raised during that section's execution will be rescued and logged. Such an exception terminates the *section* (but not the *test*).
296
+
297
+ ```example.rb```:
298
+ ```ruby
299
+ require 'minitest_log'
300
+ class Example < MiniTest::Test
301
+ def test_example
302
+ MinitestLog.new('log.xml') do |log|
303
+ log.section('My rescued section', :rescue) do
304
+ raise RuntimeError.new('Boo!')
305
+ log.comment('This code will not be reached, because the section terminates.')
306
+ end
307
+ log.comment('This code will be reached, because it is not in the terminated section.')
308
+ end
309
+ end
310
+ end
311
+ ```
312
+
313
+ ```log.xml```:
314
+ ```xml
315
+ <log>
316
+ <section_ name='My rescued section'>
317
+ <rescued_exception_ class='RuntimeError' message='Boo!'>
318
+ <backtrace_>
319
+ <![CDATA[
320
+ example.rb:6:in `block (2 levels) in test_example'
321
+ example.rb:5:in `block in test_example'
322
+ example.rb:4:in `new'
323
+ example.rb:4:in `test_example'
324
+ ]]>
325
+ </backtrace_>
326
+ </rescued_exception_>
327
+ </section_>
328
+ <comment_>
329
+ This code will be reached, because it is not in the terminated section.
330
+ </comment_>
331
+ </log>
332
+ ```
333
+
334
+ ### Unrescued Exception
335
+
336
+ An exception raised in an unrescued section is logged, and the test terminates.
337
+
338
+ ```example.rb```:
339
+ ```ruby
340
+ require 'minitest_log'
341
+ class Example < MiniTest::Test
342
+ def test_example
343
+ MinitestLog.new('log.xml') do |log|
344
+ log.section('My unrescued section') do
345
+ raise RuntimeError.new('Boo!')
346
+ end
347
+ log.comment('This code will not be reached, because the test terminated.')
348
+ end
349
+ end
350
+ end
351
+ ```
352
+
353
+ ```log.xml```:
354
+ ```xml
355
+ <log>
356
+ <section_ name='My unrescued section'>
357
+ <uncaught_exception_ timestamp='2019-05-05-Sun-14.00.29.147' class='RuntimeError'>
358
+ <message_>
359
+ Boo!
360
+ </message_>
361
+ <backtrace_>
362
+ <![CDATA[
363
+ example.rb:6:in `block (2 levels) in test_example'
364
+ example.rb:5:in `block in test_example'
365
+ example.rb:4:in `new'
366
+ example.rb:4:in `test_example'
367
+ ]]>
368
+ </backtrace_>
369
+ </uncaught_exception_>
370
+ </section_>
371
+ </log>
372
+ ```
373
+
374
+ ### Potpourri
375
+
376
+ So far, examples for method ```section``` have emphasized one thing at a time.
377
+
378
+ A call to method ```section``` begins always with the section name, but after that it can have any number and any types of arguments.
379
+
380
+ Note that:
381
+
382
+ - Multiple string arguments are concatenated, left to right, to form one string in the log.
383
+ - Each hash argument's name/value pairs are used to form attributes in the log.
384
+ - Symbols ```:timestamp```, ```:duration```, and ```:rescue``` may appear anywhere among the arguments. Duplicates are ignored.
385
+
386
+ ```example.rb```:
387
+ ```ruby
388
+ require 'minitest_log'
389
+ class Test < Minitest::Test
390
+ def test_demo
391
+ MinitestLog.new('log.xml') do |log|
392
+ log.section(
393
+ 'Section with potpourri of arguments',
394
+ # Not that you would ever want to do this. :-)
395
+ :duration,
396
+ 'Word',
397
+ {:a => 0, :b => 1},
398
+ :timestamp,
399
+ ' More words',
400
+ {:c => 2, :d => 3},
401
+ :rescue,
402
+ ) do
403
+ sleep(0.5)
404
+ raise Exception.new('Boo!')
405
+ end
406
+ end
407
+ end
408
+ end
409
+ ```
410
+
411
+ ```log.xml```:
412
+ ```xml
413
+ <log>
414
+ <section_ name='Section with potpourri of arguments' a='0' b='1' timestamp='2019-05-05-Sun-14.00.26.096' c='2' d='3' duration_seconds='0.502'>
415
+ Word More words
416
+ <rescued_exception_ class='Exception' message='Boo!'>
417
+ <backtrace_>
418
+ <![CDATA[
419
+ example.rb:17:in `block (2 levels) in test_demo'
420
+ example.rb:5:in `block in test_demo'
421
+ example.rb:4:in `new'
422
+ example.rb:4:in `test_demo'
423
+ ]]>
424
+ </backtrace_>
425
+ </rescued_exception_>
426
+ </section_>
427
+ </log>
428
+ ```
429
+
430
+
431
+ ### Custom Elements
432
+
433
+ Use method ```put_element(name, *args)``` to put custom elements onto the log. The name must be text that can become a legal XML element name.
434
+
435
+ Method ```section``` just calls ```put_element``` with the name ```section```, so the remaining allowed ```*args``` are the same for both :
436
+
437
+ - A string becomes text.
438
+ - A hash-like object becomes attributes.
439
+ - An array-like object becomes a numbered list.
440
+
441
+ A call to ```put_element``` with no block generates a childless element -- one with no sub-elements (though it may still have text).
442
+
443
+ Create sub-elements for a custom element by calling ```put_element``` with a block. Whatever elements are generated by the block become sub-elements of the custom element.
444
+
445
+ ```example.rb```:
446
+ ```ruby
447
+ require 'minitest_log'
448
+ class Example < Minitest::Test
449
+ def test_example
450
+ MinitestLog.new('log.xml') do |log|
451
+ log.section('Custom elements with no children') do
452
+ log.put_element('childless_element')
453
+ log.put_element('childless_element_with_text', 'Text for this element.')
454
+ log.put_element('childless_element_with_attributes', {:a => 0, :b => 1})
455
+ end
456
+ log.section('Custom elements with children') do
457
+ log.put_element('parent_element') do
458
+ log.put_element('child_element')
459
+ end
460
+ log.put_element('parent_element_with_text', 'Text for this element.') do
461
+ log.put_element('child_element')
462
+ end
463
+ log.put_element('parent_element_with_attributes', {:a => 0, :b => 1}) do
464
+ log.put_element('child_element')
465
+ end
466
+ end
467
+ end
468
+ end
469
+ end
470
+ ```
471
+
472
+ ```log.xml```:
473
+ ```xml
474
+ <log>
475
+ <section_ name='Custom elements with no children'>
476
+ <childless_element/>
477
+ <childless_element_with_text>
478
+ Text for this element.
479
+ </childless_element_with_text>
480
+ <childless_element_with_attributes a='0' b='1'/>
481
+ </section_>
482
+ <section_ name='Custom elements with children'>
483
+ <parent_element>
484
+ <child_element/>
485
+ </parent_element>
486
+ <parent_element_with_text>
487
+ Text for this element.
488
+ <child_element/>
489
+ </parent_element_with_text>
490
+ <parent_element_with_attributes a='0' b='1'>
491
+ <child_element/>
492
+ </parent_element_with_attributes>
493
+ </section_>
494
+ </log>
495
+ ```
496
+
497
+
498
+ ### Options
499
+
500
+ #### Root Name
501
+
502
+ The default name for the XML root element is ```log```.
503
+
504
+ Override that name by specifying option ```:root_name```.
505
+
506
+ ```root_name.rb```:
507
+ ```ruby
508
+ require 'minitest_log'
509
+ class Test < Minitest::Test
510
+ def test_demo
511
+ MinitestLog.new('default_root_name.xml') do |log|
512
+ log.section('This log has the default root name.')
513
+ end
514
+ MinitestLog.new('custom_root_name.xml', :root_name => 'my_root_name') do |log|
515
+ log.section('This log has a custom root name.')
516
+ end
517
+ end
518
+ end
519
+ ```
520
+
521
+ ```default_root_name.xml```:
522
+ ```xml
523
+ <log>
524
+ <section_ name='This log has the default root name.'/>
525
+ </log>
526
+ ```
527
+
528
+ ```custom_root_name.xml```:
529
+ ```xml
530
+ <my_root_name>
531
+ <section_ name='This log has a custom root name.'/>
532
+ </my_root_name>
533
+ ```
534
+
535
+ #### XML Indentation
536
+
537
+ The default XML indentation is 2 spaces.
538
+
539
+ Override that value by specifying option ```xml_indentation```.
540
+
541
+ An indentation value of ```0``` puts each line of the log at the left, with no indentation.
542
+
543
+ An indentation value of ```-1``` puts the entire log on one line, with no whitespace at all. This format is best for logs that will be parsed in post-processing.
544
+
545
+ Note that many applications that display XML will ignore the indentation altogether, so in general it matters only when the raw XML is read (by a person) or parsed.
546
+
547
+ ```xml_indentation.rb```:
548
+ ```ruby
549
+ require 'minitest_log'
550
+ class Test < Minitest::Test
551
+ def test_demo
552
+ MinitestLog.new('default_xml_indentation.xml') do |log|
553
+ log.section('This log has the default XML indentation (2 spaces).') do
554
+ log.section('See?')
555
+ end
556
+ end
557
+ MinitestLog.new('xml_indentation_0.xml', :xml_indentation => 0) do |log|
558
+ log.section('This log has an XML indentation of 0 (no indentation).') do
559
+ log.section('See?')
560
+ end
561
+ end
562
+ MinitestLog.new('xml_indentation_-1.xml', :xml_indentation => -1) do |log|
563
+ log.section('This log has an XML indentation of -1 (all on one line).') do
564
+ log.section('See?')
565
+ end
566
+ end
567
+ end
568
+ end
569
+ ```
570
+
571
+ ```default_xml_indentation.xml```:
572
+ ```xml
573
+ <log>
574
+ <section_ name='This log has the default XML indentation (2 spaces).'>
575
+ <section_ name='See?'/>
576
+ </section_>
577
+ </log>
578
+ ```
579
+
580
+ ```xml_indentation_0.xml```:
581
+ ```xml
582
+ <log>
583
+ <section_ name='This log has an XML indentation of 0 (no indentation).'>
584
+ <section_ name='See?'/>
585
+ </section_>
586
+ </log>
587
+ ```
588
+
589
+ ```xml_indentation_-1.xml```:
590
+ ```xml
591
+ <log><section_ name='This log has an XML indentation of -1 (all on one line).'><section_ name='See?'/></section_></log>
592
+ ```
593
+
594
+ #### Summary
595
+
596
+ By default, the log does not have a summary: counts of total verdicts, failed verdicts, and errors.
597
+
598
+ Override that behavior by specifying option ```:summary``` as ```true```. This causes the log to begin with a summary.
599
+
600
+ ```summary.rb```:
601
+ ```ruby
602
+ require 'minitest_log'
603
+ class Test < Minitest::Test
604
+ def test_demo
605
+ MinitestLog.new('no_summary.xml') do |log|
606
+ log.section('This log has no summary.') do
607
+ populate_the_log(log)
608
+ end
609
+ end
610
+ MinitestLog.new('summary.xml', :summary => true) do |log|
611
+ log.section('This log has a summary.') do
612
+ populate_the_log(log)
613
+ end
614
+ end
615
+ end
616
+ def populate_the_log(log)
617
+ log.verdict_assert?(:pass, true)
618
+ log.verdict_assert?(:fail, false)
619
+ log.section('My error-producing section', :rescue) do
620
+ raise Exception.new('Boo!')
621
+ end
622
+ end
623
+ end
624
+ ```
625
+
626
+ ```no_summary.xml```:
627
+ ```xml
628
+ <log>
629
+ <section_ name='This log has no summary.'>
630
+ <verdict_ method='verdict_assert?' outcome='passed' id='pass'>
631
+ <actual_ class='TrueClass' value='true'/>
632
+ </verdict_>
633
+ <verdict_ method='verdict_assert?' outcome='failed' id='fail'>
634
+ <actual_ class='FalseClass' value='false'/>
635
+ <exception_ class='Minitest::Assertion' message='Expected false to be truthy.'>
636
+ <backtrace_>
637
+ <![CDATA[
638
+ summary.rb:17:in `populate_the_log'
639
+ summary.rb:6:in `block (2 levels) in test_demo'
640
+ summary.rb:5:in `block in test_demo'
641
+ summary.rb:4:in `new'
642
+ summary.rb:4:in `test_demo'
643
+ ]]>
644
+ </backtrace_>
645
+ </exception_>
646
+ </verdict_>
647
+ <section_ name='My error-producing section'>
648
+ <rescued_exception_ class='Exception' message='Boo!'>
649
+ <backtrace_>
650
+ <![CDATA[
651
+ summary.rb:19:in `block in populate_the_log'
652
+ summary.rb:18:in `populate_the_log'
653
+ summary.rb:6:in `block (2 levels) in test_demo'
654
+ summary.rb:5:in `block in test_demo'
655
+ summary.rb:4:in `new'
656
+ summary.rb:4:in `test_demo'
657
+ ]]>
658
+ </backtrace_>
659
+ </rescued_exception_>
660
+ </section_>
661
+ </section_>
662
+ </log>
663
+ ```
664
+
665
+ ```summary.xml```:
666
+ ```xml
667
+ <log>
668
+ <summary_ verdicts='2' failures='1' errors='1'/>
669
+ <section_ name='This log has a summary.'>
670
+ <verdict_ method='verdict_assert?' outcome='passed' id='pass'>
671
+ <actual_ class='TrueClass' value='true'/>
672
+ </verdict_>
673
+ <verdict_ method='verdict_assert?' outcome='failed' id='fail'>
674
+ <actual_ class='FalseClass' value='false'/>
675
+ <exception_ class='Minitest::Assertion' message='Expected false to be truthy.'>
676
+ <backtrace_>
677
+ <![CDATA[
678
+ summary.rb:17:in `populate_the_log'
679
+ summary.rb:11:in `block (2 levels) in test_demo'
680
+ summary.rb:10:in `block in test_demo'
681
+ summary.rb:9:in `new'
682
+ summary.rb:9:in `test_demo'
683
+ ]]>
684
+ </backtrace_>
685
+ </exception_>
686
+ </verdict_>
687
+ <section_ name='My error-producing section'>
688
+ <rescued_exception_ class='Exception' message='Boo!'>
689
+ <backtrace_>
690
+ <![CDATA[
691
+ summary.rb:19:in `block in populate_the_log'
692
+ summary.rb:18:in `populate_the_log'
693
+ summary.rb:11:in `block (2 levels) in test_demo'
694
+ summary.rb:10:in `block in test_demo'
695
+ summary.rb:9:in `new'
696
+ summary.rb:9:in `test_demo'
697
+ ]]>
698
+ </backtrace_>
699
+ </rescued_exception_>
700
+ </section_>
701
+ </section_>
702
+ </log>
703
+ ```
704
+
705
+ #### Error Verdict
706
+
707
+ By default, the log does not have an error verdict: a generated verdict that expects the error count to be 0.
708
+
709
+ Override that behavior by specifying option ```:error_verdict``` as ```true```. This causes the log to end with an error verdict.
710
+
711
+ This verdict may be useful when a log has errors, but no failed verdicts.
712
+
713
+ ```error_verdict.rb```:
714
+ ```ruby
715
+ require 'minitest_log'
716
+ class Test < Minitest::Test
717
+ def test_demo
718
+ MinitestLog.new('no_error_verdict.xml') do |log|
719
+ log.section('This log has no error verdict.') do
720
+ populate_the_log(log)
721
+ end
722
+ end
723
+ MinitestLog.new('error_verdict.xml', :error_verdict => true) do |log|
724
+ log.section('This log has an error verdict.') do
725
+ populate_the_log(log)
726
+ end
727
+ end
728
+ end
729
+ def populate_the_log(log)
730
+ log.verdict_assert?(:pass, true)
731
+ log.verdict_assert?(:fail, false)
732
+ log.section('My error-producing section', :rescue) do
733
+ raise Exception.new('Boo!')
734
+ end
735
+ end
736
+ end
737
+ ```
738
+
739
+ ```no_error_verdict.xml```:
740
+ ```xml
741
+ <log>
742
+ <section_ name='This log has no error verdict.'>
743
+ <verdict_ method='verdict_assert?' outcome='passed' id='pass'>
744
+ <actual_ class='TrueClass' value='true'/>
745
+ </verdict_>
746
+ <verdict_ method='verdict_assert?' outcome='failed' id='fail'>
747
+ <actual_ class='FalseClass' value='false'/>
748
+ <exception_ class='Minitest::Assertion' message='Expected false to be truthy.'>
749
+ <backtrace_>
750
+ <![CDATA[
751
+ error_verdict.rb:17:in `populate_the_log'
752
+ error_verdict.rb:6:in `block (2 levels) in test_demo'
753
+ error_verdict.rb:5:in `block in test_demo'
754
+ error_verdict.rb:4:in `new'
755
+ error_verdict.rb:4:in `test_demo'
756
+ ]]>
757
+ </backtrace_>
758
+ </exception_>
759
+ </verdict_>
760
+ <section_ name='My error-producing section'>
761
+ <rescued_exception_ class='Exception' message='Boo!'>
762
+ <backtrace_>
763
+ <![CDATA[
764
+ error_verdict.rb:19:in `block in populate_the_log'
765
+ error_verdict.rb:18:in `populate_the_log'
766
+ error_verdict.rb:6:in `block (2 levels) in test_demo'
767
+ error_verdict.rb:5:in `block in test_demo'
768
+ error_verdict.rb:4:in `new'
769
+ error_verdict.rb:4:in `test_demo'
770
+ ]]>
771
+ </backtrace_>
772
+ </rescued_exception_>
773
+ </section_>
774
+ </section_>
775
+ </log>
776
+ ```
777
+
778
+ ```error_verdict.xml```:
779
+ ```xml
780
+ <log>
781
+ <section_ name='This log has an error verdict.'>
782
+ <verdict_ method='verdict_assert?' outcome='passed' id='pass'>
783
+ <actual_ class='TrueClass' value='true'/>
784
+ </verdict_>
785
+ <verdict_ method='verdict_assert?' outcome='failed' id='fail'>
786
+ <actual_ class='FalseClass' value='false'/>
787
+ <exception_ class='Minitest::Assertion' message='Expected false to be truthy.'>
788
+ <backtrace_>
789
+ <![CDATA[
790
+ error_verdict.rb:17:in `populate_the_log'
791
+ error_verdict.rb:11:in `block (2 levels) in test_demo'
792
+ error_verdict.rb:10:in `block in test_demo'
793
+ error_verdict.rb:9:in `new'
794
+ error_verdict.rb:9:in `test_demo'
795
+ ]]>
796
+ </backtrace_>
797
+ </exception_>
798
+ </verdict_>
799
+ <section_ name='My error-producing section'>
800
+ <rescued_exception_ class='Exception' message='Boo!'>
801
+ <backtrace_>
802
+ <![CDATA[
803
+ error_verdict.rb:19:in `block in populate_the_log'
804
+ error_verdict.rb:18:in `populate_the_log'
805
+ error_verdict.rb:11:in `block (2 levels) in test_demo'
806
+ error_verdict.rb:10:in `block in test_demo'
807
+ error_verdict.rb:9:in `new'
808
+ error_verdict.rb:9:in `test_demo'
809
+ ]]>
810
+ </backtrace_>
811
+ </rescued_exception_>
812
+ </section_>
813
+ </section_>
814
+ <verdict_ method='verdict_assert_equal?' outcome='failed' id='error_count'>
815
+ <expected_ class='Integer' value='0'/>
816
+ <actual_ class='Integer' value='1'/>
817
+ <exception_ class='Minitest::Assertion' message='Expected: 0'>
818
+ <backtrace_>
819
+ <![CDATA[
820
+ error_verdict.rb:9:in `new'
821
+ error_verdict.rb:9:in `test_demo'
822
+ ]]>
823
+ </backtrace_>
824
+ </exception_>
825
+ </verdict_>
826
+ </log>
827
+ ```
828
+
829
+
830
+ ## Data
831
+
832
+ Put data onto the log using method ```:put_data```.
833
+
834
+ A data object ```obj``` is treated as follows:
835
+
836
+ - If ```obj.kind_of?(String)```, it is treated as a [String](#strings)
837
+ - Otherwise if ```obj.respond_to?(:each_pair)```, it is treated as [Hash-like](#hash-like-objects).
838
+ - Otherwise, it ```obj.respond_to?(:each_with_index```, it is treated as [Array-like](#array-like-objects).
839
+ - Otherwise, it is treated as "[other](#other-objects)".
840
+
841
+ ### Strings
842
+
843
+ An object that is a ```kind_of?(String)``` is logged simply.
844
+
845
+ ```kind_of_string.rb```:
846
+ ```ruby
847
+ require 'minitest_log'
848
+ class Example < MiniTest::Test
849
+ def test_example
850
+ MinitestLog.new('kind_of_string.xml') do |log|
851
+ log.section('Objects that are a kind_of?(String)') do
852
+ string = 'When you come to a fork in the road, take it. -- Yogi Berra'
853
+ log.put_data('My string', string)
854
+ end
855
+ end
856
+ end
857
+ end
858
+ ```
859
+
860
+ ```kind_of_string.xml```:
861
+ ```xml
862
+ <log>
863
+ <section_ name='Objects that are a kind_of?(String)'>
864
+ <data_ name='My string' class='String' size='59'>
865
+ When you come to a fork in the road, take it. -- Yogi Berra
866
+ </data_>
867
+ </section_>
868
+ </log>
869
+ ```
870
+
871
+ ### Hash-Like Objects
872
+
873
+ Otherwise, an object that ```respond_to?(:each_pair)``` is logged as name-value pairs.
874
+
875
+ ```each_pair.rb```:
876
+ ```ruby
877
+ require 'minitest_log'
878
+ class Example < Minitest::Test
879
+ def test_example
880
+ MinitestLog.new('each_pair.xml') do |log|
881
+ log.section('Objects logged using :each_pair') do
882
+ log.section('Hash') do
883
+ hash = {
884
+ :name => 'Ichabod Crane',
885
+ :address => '14 Main Street',
886
+ :city => 'Sleepy Hollow',
887
+ :state => 'NY',
888
+ :zipcode => '10591',
889
+ }
890
+ log.put_data('My hash', hash)
891
+ end
892
+ log.section('Struct') do
893
+ Struct.new('Foo', :x, :y, :z)
894
+ foo = Struct::Foo.new(0, 1, 2)
895
+ log.put_data('My struct', foo)
896
+ end
897
+ end
898
+ end
899
+ end
900
+ end
901
+ ```
902
+
903
+ ```each_pair.xml```:
904
+ ```xml
905
+ <log>
906
+ <section_ name='Objects logged using :each_pair'>
907
+ <section_ name='Hash'>
908
+ <data_ name='My hash' class='Hash' method=':each_pair' size='5'>
909
+ <![CDATA[
910
+ name => Ichabod Crane
911
+ address => 14 Main Street
912
+ city => Sleepy Hollow
913
+ state => NY
914
+ zipcode => 10591
915
+ ]]>
916
+ </data_>
917
+ </section_>
918
+ <section_ name='Struct'>
919
+ <data_ name='My struct' class='Struct::Foo' method=':each_pair' size='3'>
920
+ <![CDATA[
921
+ x => 0
922
+ y => 1
923
+ z => 2
924
+ ]]>
925
+ </data_>
926
+ </section_>
927
+ </section_>
928
+ </log>
929
+ ```
930
+
931
+ ### Array-Like Objects
932
+
933
+ Otherwise, an object that ```respond_to?(:each_with_index)``` is logged as a numbered list.
934
+
935
+ ```each_with_index.rb```:
936
+ ```ruby
937
+ require 'set'
938
+ require 'minitest_log'
939
+ class Example < MiniTest::Test
940
+ def test_example
941
+ MinitestLog.new('each_with_index.xml') do |log|
942
+ log.section('Objects logged using :each_with_index') do
943
+ log.section('Array') do
944
+ array = %w/apple orange peach banana strawberry pear/
945
+ log.put_data('My array', array)
946
+ end
947
+ log.section('Set') do
948
+ set = Set.new(%w/baseball football basketball hockey/)
949
+ log.put_data('My set', set)
950
+ end
951
+ end
952
+ end
953
+ end
954
+ end
955
+ ```
956
+
957
+ ```each_with_index.xml```:
958
+ ```xml
959
+ <log>
960
+ <section_ name='Objects logged using :each_with_index'>
961
+ <section_ name='Array'>
962
+ <data_ name='My array' class='Array' method=':each_with_index' size='6'>
963
+ <![CDATA[
964
+ 0: apple
965
+ 1: orange
966
+ 2: peach
967
+ 3: banana
968
+ 4: strawberry
969
+ 5: pear
970
+ ]]>
971
+ </data_>
972
+ </section_>
973
+ <section_ name='Set'>
974
+ <data_ name='My set' class='Set' method=':each_with_index' size='4'>
975
+ <![CDATA[
976
+ 0: baseball
977
+ 1: football
978
+ 2: basketball
979
+ 3: hockey
980
+ ]]>
981
+ </data_>
982
+ </section_>
983
+ </section_>
984
+ </log>
985
+ ```
986
+
987
+ ### Other Objects
988
+
989
+ Otherwise, the logger tries, successively, to log the object using ```:to_s```,
990
+ ```:inspect```, and ```:__id__```.
991
+
992
+ If all that fails, the logger raises an exception (which is not illustrated here).
993
+
994
+ ```to_s.rb```:
995
+ ```ruby
996
+ require 'uri'
997
+ require 'minitest_log'
998
+ class Example < MiniTest::Test
999
+ def test_example
1000
+ MinitestLog.new('to_s.xml') do |log|
1001
+ log.section('Objects logged using :to_s') do
1002
+ log.put_data('My integer', 0)
1003
+ log.put_data('My exception', Exception.new('Boo!'))
1004
+ log.put_data('My regexp', /Bar/)
1005
+ log.put_data('My time', Time.now)
1006
+ log.put_data('My uri,', URI('https://www.github.com'))
1007
+ end
1008
+ end
1009
+ end
1010
+ end
1011
+ ```
1012
+
1013
+ ```to_s.xml```:
1014
+ ```xml
1015
+ <log>
1016
+ <section_ name='Objects logged using :to_s'>
1017
+ <data_ name='My integer' class='Integer' method=':to_s'>
1018
+ 0
1019
+ </data_>
1020
+ <data_ name='My exception' class='Exception' method=':to_s'>
1021
+ Boo!
1022
+ </data_>
1023
+ <data_ name='My regexp' class='Regexp' method=':to_s'>
1024
+ (?-mix:Bar)
1025
+ </data_>
1026
+ <data_ name='My time' class='Time' method=':to_s'>
1027
+ 2019-05-05 14:00:22 -0500
1028
+ </data_>
1029
+ <data_ name='My uri,' class='URI::HTTPS' method=':to_s'>
1030
+ https://www.github.com
1031
+ </data_>
1032
+ </section_>
1033
+ </log>
1034
+ ```
1035
+
1036
+
1037
+ ## Verdicts
1038
+
1039
+ Use ```MinitestLog``` verdict methods to log details of ```Minitest``` assertions.
1040
+
1041
+ Each verdict method in ```MinitestLog``` is a wrapper for a corresponding ```Minitest``` assertion (or refutation).
1042
+
1043
+ An important difference between an assertion and a verdict is that a failed verdict does not exit the test. Instead, the verdict method logs the details for the assertion, regardless of the outcome, and continues test execution.
1044
+
1045
+ The verdict method returns ```true``` or ```false``` to indicate whether the verdict succeeded or failed.
1046
+
1047
+ The arguments for the verdict method and its assert method are the same, except that the verdict method adds a leading verdict identifier:
1048
+
1049
+ ```ruby
1050
+ assert_equal(exp, act)
1051
+
1052
+ verdict_assert_equal?('verdict_id', exp, act)
1053
+ ```
1054
+
1055
+ Like an assertion, a verdict also accepts an optional trailing message string.
1056
+
1057
+ The verdict identifier:
1058
+ - Is commonly a string or a symbol, but may be any object that responds to ```:to_s```.
1059
+ - Must be unique among the verdict identifiers in its *test method* (but not necessarily in its *test class*.)
1060
+
1061
+ Each verdict method has a shorter alias -- ```va``` substituting for ```verdict_assert```, and ```vr``` substituting for ```verdict_refute```:
1062
+
1063
+ Example verdict (long form and alias):
1064
+
1065
+ ```ruby
1066
+ log.verdict_assert_equal?(:my_verdict_id, exp, act, 'My message')
1067
+
1068
+ log.va_equal?(:my_verdict_id, exp, act, 'My message')
1069
+ ```
1070
+ The shorter alias not only saves keystrokes, but also *really*, *really* helps your editor with code completion.
1071
+
1072
+ Verdict methods are described below. For each, the following is given:
1073
+
1074
+ - The method's syntax.
1075
+ - An example test using the method, including both passing and failing verdicts.
1076
+ - The log output by the example test.
1077
+ - Descriptive text, adapted from [docs.ruby-lang.org](https://docs.ruby-lang.org/en/2.1.0/MiniTest/Assertions.html)
1078
+
1079
+ ### Assert Verdicts
1080
+
1081
+ #### verdict_assert?
1082
+
1083
+ ```ruby
1084
+ verdict_assert?(id, test, msg = nil)
1085
+ va?(id, test, msg = nil)
1086
+ ```
1087
+
1088
+ Fails unless ```test``` is a true value.
1089
+
1090
+ ```verdict_assert.rb```:
1091
+ ```ruby
1092
+ require 'minitest_log'
1093
+ class Example < Minitest::Test
1094
+ def test_demo_verdict
1095
+ MinitestLog.new('verdict_assert.xml') do |log|
1096
+ log.verdict_assert?(:one_id, true, 'One message')
1097
+ log.verdict_assert?(:another_id, false, 'Another message')
1098
+ end
1099
+ end
1100
+ end
1101
+ ```
1102
+
1103
+ ```verdict_assert.xml```:
1104
+ ```xml
1105
+ <log>
1106
+ <verdict_ method='verdict_assert?' outcome='passed' id='one_id' message='One message'>
1107
+ <actual_ class='TrueClass' value='true'/>
1108
+ </verdict_>
1109
+ <verdict_ method='verdict_assert?' outcome='failed' id='another_id' message='Another message'>
1110
+ <actual_ class='FalseClass' value='false'/>
1111
+ <exception_ class='Minitest::Assertion' message='Expected false to be truthy.'>
1112
+ <backtrace_>
1113
+ <![CDATA[
1114
+ verdict_assert.rb:6:in `block in test_demo_verdict'
1115
+ verdict_assert.rb:4:in `new'
1116
+ verdict_assert.rb:4:in `test_demo_verdict'
1117
+ ]]>
1118
+ </backtrace_>
1119
+ </exception_>
1120
+ </verdict_>
1121
+ </log>
1122
+ ```
1123
+
1124
+ #### verdict_assert_empty?
1125
+
1126
+ ```ruby
1127
+ verdict_assert_empty?(id, obj, msg = nil)
1128
+ va_empty?(id, obj, msg = nil)
1129
+ ```
1130
+
1131
+ Fails unless ```obj``` is empty.
1132
+
1133
+ ```verdict_assert_empty.rb```:
1134
+ ```ruby
1135
+ require 'minitest_log'
1136
+ class Example < Minitest::Test
1137
+ def test_demo_verdict
1138
+ MinitestLog.new('verdict_assert_empty.xml') do |log|
1139
+ log.verdict_assert_empty?(:one_id, [], 'One message')
1140
+ log.verdict_assert_empty?(:another_id, [:a], 'Another message')
1141
+ end
1142
+ end
1143
+ end
1144
+ ```
1145
+
1146
+ ```verdict_assert_empty.xml```:
1147
+ ```xml
1148
+ <log>
1149
+ <verdict_ method='verdict_assert_empty?' outcome='passed' id='one_id' message='One message'>
1150
+ <actual_ class='Array' value='[]'/>
1151
+ </verdict_>
1152
+ <verdict_ method='verdict_assert_empty?' outcome='failed' id='another_id' message='Another message'>
1153
+ <actual_ class='Array' value='[:a]'/>
1154
+ <exception_ class='Minitest::Assertion' message='Expected [:a] to be empty.'>
1155
+ <backtrace_>
1156
+ <![CDATA[
1157
+ verdict_assert_empty.rb:6:in `block in test_demo_verdict'
1158
+ verdict_assert_empty.rb:4:in `new'
1159
+ verdict_assert_empty.rb:4:in `test_demo_verdict'
1160
+ ]]>
1161
+ </backtrace_>
1162
+ </exception_>
1163
+ </verdict_>
1164
+ </log>
1165
+ ```
1166
+
1167
+ #### verdict_assert_equal?
1168
+
1169
+ ```ruby
1170
+ verdict_assert_equal?(id, exp, act, msg = nil)
1171
+ va_equal?(id, exp, act, msg = nil)
1172
+ ```
1173
+ Fails unless ```exp == act```.
1174
+
1175
+ For floats use verdict_assert_in_delta?.
1176
+
1177
+ ```verdict_assert_equal.rb```:
1178
+ ```ruby
1179
+ require 'minitest_log'
1180
+ class Example < Minitest::Test
1181
+ def test_demo_verdict
1182
+ MinitestLog.new('verdict_assert_equal.xml') do |log|
1183
+ log.verdict_assert_equal?(:one_id, 0, 0, 'One message')
1184
+ log.verdict_assert_equal?(:another_id, 0, 1, 'Another message')
1185
+ end
1186
+ end
1187
+ end
1188
+ ```
1189
+
1190
+ ```verdict_assert_equal.xml```:
1191
+ ```xml
1192
+ <log>
1193
+ <verdict_ method='verdict_assert_equal?' outcome='passed' id='one_id' message='One message'>
1194
+ <expected_ class='Integer' value='0'/>
1195
+ <actual_ class='Integer' value='0'/>
1196
+ </verdict_>
1197
+ <verdict_ method='verdict_assert_equal?' outcome='failed' id='another_id' message='Another message'>
1198
+ <expected_ class='Integer' value='0'/>
1199
+ <actual_ class='Integer' value='1'/>
1200
+ <exception_ class='Minitest::Assertion' message='Expected: 0'>
1201
+ <backtrace_>
1202
+ <![CDATA[
1203
+ verdict_assert_equal.rb:6:in `block in test_demo_verdict'
1204
+ verdict_assert_equal.rb:4:in `new'
1205
+ verdict_assert_equal.rb:4:in `test_demo_verdict'
1206
+ ]]>
1207
+ </backtrace_>
1208
+ </exception_>
1209
+ </verdict_>
1210
+ </log>
1211
+ ```
1212
+
1213
+ #### verdict_assert_in_delta?
1214
+
1215
+ ```ruby
1216
+ verdict_assert_in_delta?(id, exp, act, delta = 0.001, msg = nil)
1217
+ va_in_delta?(id, exp, act, delta = 0.001, msg = nil)
1218
+ ````
1219
+
1220
+ For comparing Floats. Fails unless ```exp``` and ```act``` are within ```delta``` of each other.
1221
+
1222
+ ```verdict_assert_in_delta.rb```:
1223
+ ```ruby
1224
+ require 'minitest_log'
1225
+ class Example < Minitest::Test
1226
+ def test_demo_verdict
1227
+ MinitestLog.new('verdict_assert_in_delta.xml') do |log|
1228
+ log.verdict_assert_in_delta?(:one_id, 0, 0, 1, 'One message')
1229
+ log.verdict_assert_in_delta?(:another_id, 0, 2, 1, 'Another message')
1230
+ end
1231
+ end
1232
+ end
1233
+ ```
1234
+
1235
+ ```verdict_assert_in_delta.xml```:
1236
+ ```xml
1237
+ <log>
1238
+ <verdict_ method='verdict_assert_in_delta?' outcome='passed' id='one_id' message='One message'>
1239
+ <expected_ class='Integer' value='0'/>
1240
+ <actual_ class='Integer' value='0'/>
1241
+ <delta_ class='Integer' value='1'/>
1242
+ </verdict_>
1243
+ <verdict_ method='verdict_assert_in_delta?' outcome='failed' id='another_id' message='Another message'>
1244
+ <expected_ class='Integer' value='0'/>
1245
+ <actual_ class='Integer' value='2'/>
1246
+ <delta_ class='Integer' value='1'/>
1247
+ <exception_ class='Minitest::Assertion' message='Expected |0 - 2| (2) to be &lt;= 1.'>
1248
+ <backtrace_>
1249
+ <![CDATA[
1250
+ verdict_assert_in_delta.rb:6:in `block in test_demo_verdict'
1251
+ verdict_assert_in_delta.rb:4:in `new'
1252
+ verdict_assert_in_delta.rb:4:in `test_demo_verdict'
1253
+ ]]>
1254
+ </backtrace_>
1255
+ </exception_>
1256
+ </verdict_>
1257
+ </log>
1258
+ ```
1259
+
1260
+ #### verdict_assert_in_epsilon?
1261
+
1262
+ ```ruby
1263
+ verdict_assert_in_epsilon?(id, a, b, epsilon = 0.001, msg = nil)
1264
+ va_in_epsilon?(id, a, b, epsilon = 0.001, msg = nil)
1265
+ ```
1266
+
1267
+ For comparing Floats. Fails unless ```exp``` and ```act``` have a relative error less than ```epsilon```.
1268
+
1269
+ ```verdict_assert_in_epsilon.rb```:
1270
+ ```ruby
1271
+ require 'minitest_log'
1272
+ class Example < Minitest::Test
1273
+ def test_demo_verdict
1274
+ MinitestLog.new('verdict_assert_in_epsilon.xml') do |log|
1275
+ log.verdict_assert_in_epsilon?(:one_id, 3, 2, 1, 'One message')
1276
+ log.verdict_assert_in_epsilon?(:another_id, 3, 2, 0, 'Another message')
1277
+ end
1278
+ end
1279
+ end
1280
+ ```
1281
+
1282
+ ```verdict_assert_in_epsilon.xml```:
1283
+ ```xml
1284
+ <log>
1285
+ <verdict_ method='verdict_assert_in_epsilon?' outcome='passed' id='one_id' message='One message'>
1286
+ <expected_ class='Integer' value='3'/>
1287
+ <actual_ class='Integer' value='2'/>
1288
+ <epsilon_ class='Integer' value='1'/>
1289
+ </verdict_>
1290
+ <verdict_ method='verdict_assert_in_epsilon?' outcome='failed' id='another_id' message='Another message'>
1291
+ <expected_ class='Integer' value='3'/>
1292
+ <actual_ class='Integer' value='2'/>
1293
+ <epsilon_ class='Integer' value='0'/>
1294
+ <exception_ class='Minitest::Assertion' message='Expected |3 - 2| (1) to be &lt;= 0.'>
1295
+ <backtrace_>
1296
+ <![CDATA[
1297
+ verdict_assert_in_epsilon.rb:6:in `block in test_demo_verdict'
1298
+ verdict_assert_in_epsilon.rb:4:in `new'
1299
+ verdict_assert_in_epsilon.rb:4:in `test_demo_verdict'
1300
+ ]]>
1301
+ </backtrace_>
1302
+ </exception_>
1303
+ </verdict_>
1304
+ </log>
1305
+ ```
1306
+
1307
+ #### verdict_assert_includes?
1308
+
1309
+ ```ruby
1310
+ verdict_assert_includes?(id, collection, obj, msg = nil)
1311
+ va_includes?(id, collection, obj, msg = nil)
1312
+ ```
1313
+
1314
+ Fails unless ```collection``` includes ```obj```.
1315
+
1316
+ ```verdict_assert_includes.rb```:
1317
+ ```ruby
1318
+ require 'minitest_log'
1319
+ class Example < Minitest::Test
1320
+ def test_demo_verdict
1321
+ MinitestLog.new('verdict_assert_includes.xml') do |log|
1322
+ log.verdict_assert_includes?(:one_id, [:a, :b, :c], :b, 'One message')
1323
+ log.verdict_assert_includes?(:another_id, [:a, :b, :c], :d, 'Another message')
1324
+ end
1325
+ end
1326
+ end
1327
+ ```
1328
+
1329
+ ```verdict_assert_includes.xml```:
1330
+ ```xml
1331
+ <log>
1332
+ <verdict_ method='verdict_assert_includes?' outcome='passed' id='one_id' message='One message'>
1333
+ <expected_ class='Array' value='[:a, :b, :c]'/>
1334
+ <actual_ class='Symbol' value=':b'/>
1335
+ </verdict_>
1336
+ <verdict_ method='verdict_assert_includes?' outcome='failed' id='another_id' message='Another message'>
1337
+ <expected_ class='Array' value='[:a, :b, :c]'/>
1338
+ <actual_ class='Symbol' value=':d'/>
1339
+ <exception_ class='Minitest::Assertion' message='Expected [:a, :b, :c] to include :d.'>
1340
+ <backtrace_>
1341
+ <![CDATA[
1342
+ verdict_assert_includes.rb:6:in `block in test_demo_verdict'
1343
+ verdict_assert_includes.rb:4:in `new'
1344
+ verdict_assert_includes.rb:4:in `test_demo_verdict'
1345
+ ]]>
1346
+ </backtrace_>
1347
+ </exception_>
1348
+ </verdict_>
1349
+ </log>
1350
+ ```
1351
+
1352
+ #### verdict_assert_instance_of?
1353
+
1354
+ ```ruby
1355
+ verdict_assert_instance_of?(id, cls, obj, msg = nil)
1356
+ va_instance_of?(id, cls, obj, msg = nil)
1357
+ ```
1358
+
1359
+ Fails unless ```obj``` is an instance of ```cls```.
1360
+
1361
+ ```verdict_assert_instance_of.rb```:
1362
+ ```ruby
1363
+ require 'minitest_log'
1364
+ class Example < Minitest::Test
1365
+ def test_demo_verdict
1366
+ MinitestLog.new('verdict_assert_instance_of.xml') do |log|
1367
+ log.verdict_assert_instance_of?(:one_id, String, 'my_string', 'One message')
1368
+ log.verdict_assert_instance_of?(:another_id, Integer, 'my_string', 'another message')
1369
+ end
1370
+ end
1371
+ end
1372
+ ```
1373
+
1374
+ ```verdict_assert_instance_of.xml```:
1375
+ ```xml
1376
+ <log>
1377
+ <verdict_ method='verdict_assert_instance_of?' outcome='passed' id='one_id' message='One message'>
1378
+ <expected_ class='Class' value='String'/>
1379
+ <actual_ class='String' value='&quot;my_string&quot;'/>
1380
+ </verdict_>
1381
+ <verdict_ method='verdict_assert_instance_of?' outcome='failed' id='another_id' message='another message'>
1382
+ <expected_ class='Class' value='Integer'/>
1383
+ <actual_ class='String' value='&quot;my_string&quot;'/>
1384
+ <exception_ class='Minitest::Assertion' message='Expected &quot;my_string&quot; to be an instance of Integer, not String.'>
1385
+ <backtrace_>
1386
+ <![CDATA[
1387
+ verdict_assert_instance_of.rb:6:in `block in test_demo_verdict'
1388
+ verdict_assert_instance_of.rb:4:in `new'
1389
+ verdict_assert_instance_of.rb:4:in `test_demo_verdict'
1390
+ ]]>
1391
+ </backtrace_>
1392
+ </exception_>
1393
+ </verdict_>
1394
+ </log>
1395
+ ```
1396
+
1397
+ #### verdict_assert_kind_of?
1398
+
1399
+ ```ruby
1400
+ verdict_assert_kind_of?(id, cls, obj, msg = nil)
1401
+ va_kind_of?(id, cls, obj, msg = nil)
1402
+ ```
1403
+
1404
+ Fails unless ```obj``` is a kind of ```cls```.
1405
+
1406
+ ```verdict_assert_kind_of.rb```:
1407
+ ```ruby
1408
+ require 'minitest_log'
1409
+ class Example < Minitest::Test
1410
+ def test_demo_verdict
1411
+ MinitestLog.new('verdict_assert_kind_of.xml') do |log|
1412
+ log.verdict_assert_kind_of?(:one_id, Numeric, 1.0, 'One message')
1413
+ log.verdict_assert_kind_of?(:another_id, String, 1.0, 'Another message')
1414
+ end
1415
+ end
1416
+ end
1417
+ ```
1418
+
1419
+ ```verdict_assert_kind_of.xml```:
1420
+ ```xml
1421
+ <log>
1422
+ <verdict_ method='verdict_assert_kind_of?' outcome='passed' id='one_id' message='One message'>
1423
+ <expected_ class='Class' value='Numeric'/>
1424
+ <actual_ class='Float' value='1.0'/>
1425
+ </verdict_>
1426
+ <verdict_ method='verdict_assert_kind_of?' outcome='failed' id='another_id' message='Another message'>
1427
+ <expected_ class='Class' value='String'/>
1428
+ <actual_ class='Float' value='1.0'/>
1429
+ <exception_ class='Minitest::Assertion' message='Expected 1.0 to be a kind of String, not Float.'>
1430
+ <backtrace_>
1431
+ <![CDATA[
1432
+ verdict_assert_kind_of.rb:6:in `block in test_demo_verdict'
1433
+ verdict_assert_kind_of.rb:4:in `new'
1434
+ verdict_assert_kind_of.rb:4:in `test_demo_verdict'
1435
+ ]]>
1436
+ </backtrace_>
1437
+ </exception_>
1438
+ </verdict_>
1439
+ </log>
1440
+ ```
1441
+
1442
+ #### verdict_assert_match?
1443
+
1444
+ ```ruby
1445
+ verdict_assert_match?(id, matcher, obj, msg = nil)
1446
+ va_match?(id, matcher, obj, msg = nil)
1447
+ ```
1448
+
1449
+ Fails unless ```matcher =~ obj```.
1450
+
1451
+ ```verdict_assert_match.rb```:
1452
+ ```ruby
1453
+ require 'minitest_log'
1454
+ class Example < Minitest::Test
1455
+ def test_demo_verdict
1456
+ MinitestLog.new('verdict_assert_match.xml') do |log|
1457
+ log.verdict_assert_match?(:one_id, /foo/, 'food', 'One message')
1458
+ log.verdict_assert_match?(:another_id, /foo/, 'feed', 'Another message')
1459
+ end
1460
+ end
1461
+ end
1462
+ ```
1463
+
1464
+ ```verdict_assert_match.xml```:
1465
+ ```xml
1466
+ <log>
1467
+ <verdict_ method='verdict_assert_match?' outcome='passed' id='one_id' message='One message'>
1468
+ <expected_ class='Regexp' value='/foo/'/>
1469
+ <actual_ class='String' value='&quot;food&quot;'/>
1470
+ </verdict_>
1471
+ <verdict_ method='verdict_assert_match?' outcome='failed' id='another_id' message='Another message'>
1472
+ <expected_ class='Regexp' value='/foo/'/>
1473
+ <actual_ class='String' value='&quot;feed&quot;'/>
1474
+ <exception_ class='Minitest::Assertion' message='Expected /foo/ to match &quot;feed&quot;.'>
1475
+ <backtrace_>
1476
+ <![CDATA[
1477
+ verdict_assert_match.rb:6:in `block in test_demo_verdict'
1478
+ verdict_assert_match.rb:4:in `new'
1479
+ verdict_assert_match.rb:4:in `test_demo_verdict'
1480
+ ]]>
1481
+ </backtrace_>
1482
+ </exception_>
1483
+ </verdict_>
1484
+ </log>
1485
+ ```
1486
+
1487
+ #### verdict_assert_nil?
1488
+
1489
+ ```ruby
1490
+ verdict_assert_nil?(id, obj, msg = nil)
1491
+ va_nil?(id, obj, msg = nil)
1492
+ ```
1493
+
1494
+ Fails unless ```obj``` is nil.
1495
+
1496
+ ```verdict_assert_nil.rb```:
1497
+ ```ruby
1498
+ require 'minitest_log'
1499
+ class Example < Minitest::Test
1500
+ def test_demo_verdict
1501
+ MinitestLog.new('verdict_assert_nil.xml') do |log|
1502
+ log.verdict_assert_nil?(:one_id, nil, 'One message')
1503
+ log.verdict_assert_nil?(:another_id, :a, 'Another message')
1504
+ end
1505
+ end
1506
+ end
1507
+ ```
1508
+
1509
+ ```verdict_assert_nil.xml```:
1510
+ ```xml
1511
+ <log>
1512
+ <verdict_ method='verdict_assert_nil?' outcome='passed' id='one_id' message='One message'>
1513
+ <actual_ class='NilClass' value='nil'/>
1514
+ </verdict_>
1515
+ <verdict_ method='verdict_assert_nil?' outcome='failed' id='another_id' message='Another message'>
1516
+ <actual_ class='Symbol' value=':a'/>
1517
+ <exception_ class='Minitest::Assertion' message='Expected :a to be nil.'>
1518
+ <backtrace_>
1519
+ <![CDATA[
1520
+ verdict_assert_nil.rb:6:in `block in test_demo_verdict'
1521
+ verdict_assert_nil.rb:4:in `new'
1522
+ verdict_assert_nil.rb:4:in `test_demo_verdict'
1523
+ ]]>
1524
+ </backtrace_>
1525
+ </exception_>
1526
+ </verdict_>
1527
+ </log>
1528
+ ```
1529
+
1530
+ #### verdict_assert_operator?
1531
+
1532
+ ```ruby
1533
+ verdict_assert_operator?(id, o1, op, o2 = UNDEFINED, msg = nil)
1534
+ va_operator?(id, o1, op, o2 = UNDEFINED, msg = nil)
1535
+ ````
1536
+
1537
+ For testing with binary operators.
1538
+
1539
+ ```verdict_assert_operator.rb```:
1540
+ ```ruby
1541
+ require 'minitest_log'
1542
+ class Example < Minitest::Test
1543
+ def test_demo_verdict
1544
+ MinitestLog.new('verdict_assert_operator.xml') do |log|
1545
+ log.verdict_assert_operator?(:one_id, 3, :<=, 4, 'One message')
1546
+ log.verdict_assert_operator?(:another_id, 5, :<=, 4, 'Another message')
1547
+ end
1548
+ end
1549
+ end
1550
+ ```
1551
+
1552
+ ```verdict_assert_operator.xml```:
1553
+ ```xml
1554
+ <log>
1555
+ <verdict_ method='verdict_assert_operator?' outcome='passed' id='one_id' message='One message'>
1556
+ <object_1_ class='Integer' value='3'/>
1557
+ <operator_ class='Symbol' value=':&lt;='/>
1558
+ <object_2_ class='Integer' value='4'/>
1559
+ </verdict_>
1560
+ <verdict_ method='verdict_assert_operator?' outcome='failed' id='another_id' message='Another message'>
1561
+ <object_1_ class='Integer' value='5'/>
1562
+ <operator_ class='Symbol' value=':&lt;='/>
1563
+ <object_2_ class='Integer' value='4'/>
1564
+ <exception_ class='Minitest::Assertion' message='Expected 5 to be &lt;= 4.'>
1565
+ <backtrace_>
1566
+ <![CDATA[
1567
+ verdict_assert_operator.rb:6:in `block in test_demo_verdict'
1568
+ verdict_assert_operator.rb:4:in `new'
1569
+ verdict_assert_operator.rb:4:in `test_demo_verdict'
1570
+ ]]>
1571
+ </backtrace_>
1572
+ </exception_>
1573
+ </verdict_>
1574
+ </log>
1575
+ ```
1576
+
1577
+ #### verdict_assert_output?
1578
+
1579
+ ```ruby
1580
+ verdict_assert_output?(id, stdout = nil, stderr = nil) { || ... }
1581
+ va_output?(id, stdout = nil, stderr = nil) { || ... }
1582
+ ```
1583
+
1584
+ Fails if ```stdout``` or ```stderr``` do not output the expected results. Pass in ```nil``` if you don't care about that streams output. Pass in ```''``` if you require it to be silent. Pass in a regexp if you want to pattern match.
1585
+
1586
+ NOTE: this uses capture_io, not capture_subprocess_io.
1587
+
1588
+ ```verdict_assert_output.rb```:
1589
+ ```ruby
1590
+ require 'minitest_log'
1591
+ class Example < Minitest::Test
1592
+ def test_demo_verdict
1593
+ MinitestLog.new('verdict_assert_output.xml') do |log|
1594
+ log.verdict_assert_output?(:one_id, stdout = 'Foo', stderr = 'Bar') do
1595
+ $stdout.write('Foo')
1596
+ $stderr.write('Bar')
1597
+ end
1598
+ log.verdict_assert_output?(:another_id, stdout = 'Bar', stderr = 'Foo') do
1599
+ $stdout.write('Foo')
1600
+ $stderr.write('Bar')
1601
+ end
1602
+ end
1603
+ end
1604
+ end
1605
+ ```
1606
+
1607
+ ```verdict_assert_output.xml```:
1608
+ ```xml
1609
+ <log>
1610
+ <verdict_ method='verdict_assert_output?' outcome='passed' id='one_id'>
1611
+ <stdout_ class='String' value='&quot;Foo&quot;'/>
1612
+ <stderr_ class='String' value='&quot;Bar&quot;'/>
1613
+ </verdict_>
1614
+ <verdict_ method='verdict_assert_output?' outcome='failed' id='another_id'>
1615
+ <stdout_ class='String' value='&quot;Bar&quot;'/>
1616
+ <stderr_ class='String' value='&quot;Foo&quot;'/>
1617
+ <exception_ class='Minitest::Assertion' message='In stderr.'>
1618
+ <backtrace_>
1619
+ <![CDATA[
1620
+ verdict_assert_output.rb:9:in `block in test_demo_verdict'
1621
+ verdict_assert_output.rb:4:in `new'
1622
+ verdict_assert_output.rb:4:in `test_demo_verdict'
1623
+ ]]>
1624
+ </backtrace_>
1625
+ </exception_>
1626
+ </verdict_>
1627
+ </log>
1628
+ ```
1629
+
1630
+ #### verdict_assert_predicate?
1631
+
1632
+ ```ruby
1633
+ verdict_assert_predicate?(id, o1, op, msg = nil)
1634
+ va_predicate?(id, o1, op, msg = nil)
1635
+ ```
1636
+
1637
+ For testing with predicates.
1638
+
1639
+ ```verdict_assert_predicate.rb```:
1640
+ ```ruby
1641
+ require 'minitest_log'
1642
+ class Example < Minitest::Test
1643
+ def test_demo_verdict
1644
+ MinitestLog.new('verdict_assert_predicate.xml') do |log|
1645
+ log.verdict_assert_predicate?(:one_id, '', :empty?, 'One message')
1646
+ log.verdict_assert_predicate?(:another_id, 'x', :empty?, 'Another message')
1647
+ end
1648
+ end
1649
+ end
1650
+ ```
1651
+
1652
+ ```verdict_assert_predicate.xml```:
1653
+ ```xml
1654
+ <log>
1655
+ <verdict_ method='verdict_assert_predicate?' outcome='passed' id='one_id' message='One message'>
1656
+ <object_ class='String' value='&quot;&quot;'/>
1657
+ <operator_ class='Symbol' value=':empty?'/>
1658
+ </verdict_>
1659
+ <verdict_ method='verdict_assert_predicate?' outcome='failed' id='another_id' message='Another message'>
1660
+ <object_ class='String' value='&quot;x&quot;'/>
1661
+ <operator_ class='Symbol' value=':empty?'/>
1662
+ <exception_ class='Minitest::Assertion' message='Expected &quot;x&quot; to be empty?.'>
1663
+ <backtrace_>
1664
+ <![CDATA[
1665
+ verdict_assert_predicate.rb:6:in `block in test_demo_verdict'
1666
+ verdict_assert_predicate.rb:4:in `new'
1667
+ verdict_assert_predicate.rb:4:in `test_demo_verdict'
1668
+ ]]>
1669
+ </backtrace_>
1670
+ </exception_>
1671
+ </verdict_>
1672
+ </log>
1673
+ ```
1674
+
1675
+ #### verdict_assert_raises?
1676
+
1677
+ ```ruby
1678
+ verdict_assert_raises?(id, *exp) { || ... }
1679
+ va_raises?(id, *exp) { || ... }
1680
+ ```
1681
+
1682
+ Fails unless the block raises one of ```exp```. Returns the exception matched so you can check the message, attributes, etc.
1683
+
1684
+ ```verdict_assert_raises.rb```:
1685
+ ```ruby
1686
+ require 'minitest_log'
1687
+ class Example < Minitest::Test
1688
+ def test_demo_verdict
1689
+ MinitestLog.new('verdict_assert_raises.xml') do |log|
1690
+ log.verdict_assert_raises?(:one_id, RuntimeError, 'One message') do
1691
+ raise RuntimeError.new('Boo!')
1692
+ end
1693
+ log.verdict_assert_raises?(:another_id, RuntimeError, 'Another message') do
1694
+ raise Exception.new('Boo!')
1695
+ end
1696
+ end
1697
+ end
1698
+ end
1699
+ ```
1700
+
1701
+ ```verdict_assert_raises.xml```:
1702
+ ```xml
1703
+ <log>
1704
+ <verdict_ method='verdict_assert_raises?' outcome='passed' id='one_id' message='One message'>
1705
+ <error_class_ class='Class' value='RuntimeError'/>
1706
+ </verdict_>
1707
+ <verdict_ method='verdict_assert_raises?' outcome='failed' id='another_id' message='Another message'>
1708
+ <error_class_ class='Class' value='RuntimeError'/>
1709
+ <exception_ class='Minitest::Assertion' message='[RuntimeError] exception expected, not'>
1710
+ <backtrace_>
1711
+ <![CDATA[
1712
+ verdict_assert_raises.rb:8:in `block in test_demo_verdict'
1713
+ verdict_assert_raises.rb:4:in `new'
1714
+ verdict_assert_raises.rb:4:in `test_demo_verdict'
1715
+ ]]>
1716
+ </backtrace_>
1717
+ </exception_>
1718
+ </verdict_>
1719
+ </log>
1720
+ ```
1721
+
1722
+ #### verdict_assert_respond_to?
1723
+
1724
+ ```ruby
1725
+ verdict_assert_respond_to?(id, obj, meth, msg = nil)
1726
+ va_respond_to?(id, obj, meth, msg = nil)
1727
+ ```
1728
+
1729
+ Fails unless ```obj``` responds to ```meth```.
1730
+
1731
+ ```verdict_assert_respond_to.rb```:
1732
+ ```ruby
1733
+ require 'minitest_log'
1734
+ class Example < Minitest::Test
1735
+ def test_demo_verdict
1736
+ MinitestLog.new('verdict_assert_respond_to.xml') do |log|
1737
+ log.verdict_assert_respond_to?(:one_id, 0, :succ, 'One message')
1738
+ log.verdict_assert_respond_to?(:another_id, 0, :empty?, 'Another message')
1739
+ end
1740
+ end
1741
+ end
1742
+ ```
1743
+
1744
+ ```verdict_assert_respond_to.xml```:
1745
+ ```xml
1746
+ <log>
1747
+ <verdict_ method='verdict_assert_respond_to?' outcome='passed' id='one_id' message='One message'>
1748
+ <object_ class='Integer' value='0'/>
1749
+ <method_ class='Symbol' value=':succ'/>
1750
+ </verdict_>
1751
+ <verdict_ method='verdict_assert_respond_to?' outcome='failed' id='another_id' message='Another message'>
1752
+ <object_ class='Integer' value='0'/>
1753
+ <method_ class='Symbol' value=':empty?'/>
1754
+ <exception_ class='Minitest::Assertion' message='Expected 0 (Integer) to respond to #empty?.'>
1755
+ <backtrace_>
1756
+ <![CDATA[
1757
+ verdict_assert_respond_to.rb:6:in `block in test_demo_verdict'
1758
+ verdict_assert_respond_to.rb:4:in `new'
1759
+ verdict_assert_respond_to.rb:4:in `test_demo_verdict'
1760
+ ]]>
1761
+ </backtrace_>
1762
+ </exception_>
1763
+ </verdict_>
1764
+ </log>
1765
+ ```
1766
+
1767
+ #### verdict_assert_same?
1768
+
1769
+ ```ruby
1770
+ verdict_assert_same?(id, exp, act, msg = nil)
1771
+ va_same?(id, exp, act, msg = nil)
1772
+ ```
1773
+
1774
+ Fails unless ```exp``` and ```act``` are ```equal?```.
1775
+
1776
+ ```verdict_assert_same.rb```:
1777
+ ```ruby
1778
+ require 'minitest_log'
1779
+ class Example < Minitest::Test
1780
+ def test_demo_verdict
1781
+ MinitestLog.new('verdict_assert_same.xml') do |log|
1782
+ log.verdict_assert_same?(:one_id, :foo, :foo, 'One message')
1783
+ log.verdict_assert_same?(:another_id, 'foo', 'foo', 'Another message')
1784
+ end
1785
+ end
1786
+ end
1787
+ ```
1788
+
1789
+ ```verdict_assert_same.xml```:
1790
+ ```xml
1791
+ <log>
1792
+ <verdict_ method='verdict_assert_same?' outcome='passed' id='one_id' message='One message'>
1793
+ <expected_ class='Symbol' value=':foo'/>
1794
+ <actual_ class='Symbol' value=':foo'/>
1795
+ </verdict_>
1796
+ <verdict_ method='verdict_assert_same?' outcome='failed' id='another_id' message='Another message'>
1797
+ <expected_ class='String' value='&quot;foo&quot;'/>
1798
+ <actual_ class='String' value='&quot;foo&quot;'/>
1799
+ <exception_ class='Minitest::Assertion' message='Expected &quot;foo&quot; (oid=28713420) to be the same as &quot;foo&quot; (oid=28713440).'>
1800
+ <backtrace_>
1801
+ <![CDATA[
1802
+ verdict_assert_same.rb:6:in `block in test_demo_verdict'
1803
+ verdict_assert_same.rb:4:in `new'
1804
+ verdict_assert_same.rb:4:in `test_demo_verdict'
1805
+ ]]>
1806
+ </backtrace_>
1807
+ </exception_>
1808
+ </verdict_>
1809
+ </log>
1810
+ ```
1811
+
1812
+ #### verdict_assert_silent?
1813
+
1814
+ ```ruby
1815
+ verdict_assert_silent?(id) { || ... }
1816
+ va_silent?(id) { || ... }
1817
+ ```
1818
+
1819
+ Fails if the block outputs anything to ```stderr``` or ```stdout```.
1820
+
1821
+ ```verdict_assert_silent.rb```:
1822
+ ```ruby
1823
+ require 'minitest_log'
1824
+ class Example < Minitest::Test
1825
+ def test_demo_verdict
1826
+ MinitestLog.new('verdict_assert_silent.xml') do |log|
1827
+ log.verdict_assert_silent?(:one_id) do
1828
+ end
1829
+ log.verdict_assert_silent?(:another_id) do
1830
+ $stdout.write('Foo')
1831
+ end
1832
+ end
1833
+ end
1834
+ end
1835
+ ```
1836
+
1837
+ ```verdict_assert_silent.xml```:
1838
+ ```xml
1839
+ <log>
1840
+ <verdict_ method='verdict_assert_silent?' outcome='passed' id='one_id'/>
1841
+ <verdict_ method='verdict_assert_silent?' outcome='failed' id='another_id'>
1842
+ <exception_ class='Minitest::Assertion' message='In stdout.'>
1843
+ <backtrace_>
1844
+ <![CDATA[
1845
+ verdict_assert_silent.rb:7:in `block in test_demo_verdict'
1846
+ verdict_assert_silent.rb:4:in `new'
1847
+ verdict_assert_silent.rb:4:in `test_demo_verdict'
1848
+ ]]>
1849
+ </backtrace_>
1850
+ </exception_>
1851
+ </verdict_>
1852
+ </log>
1853
+ ```
1854
+
1855
+ #### verdict_assert_throws?
1856
+
1857
+ ```ruby
1858
+ verdict_assert_throws?(id, sym, msg = nil) { || ... }
1859
+ va_throws?(id, sym, msg = nil) { || ... }
1860
+ ```
1861
+
1862
+ Fails unless the block throws ```sym```.
1863
+
1864
+ ```verdict_assert_throws.rb```:
1865
+ ```ruby
1866
+ require 'minitest_log'
1867
+ class Example < Minitest::Test
1868
+ def test_demo_verdict
1869
+ MinitestLog.new('verdict_assert_throws.xml') do |log|
1870
+ log.verdict_assert_throws?(:one_id, :foo, 'One message') do
1871
+ throw :foo
1872
+ end
1873
+ log.verdict_assert_throws?(:another_id, :foo, 'Another message') do
1874
+ throw :bar
1875
+ end
1876
+ end
1877
+ end
1878
+ end
1879
+ ```
1880
+
1881
+ ```verdict_assert_throws.xml```:
1882
+ ```xml
1883
+ <log>
1884
+ <verdict_ method='verdict_assert_throws?' outcome='passed' id='one_id' message='One message'>
1885
+ <error_class_ class='Symbol' value=':foo'/>
1886
+ </verdict_>
1887
+ <verdict_ method='verdict_assert_throws?' outcome='failed' id='another_id' message='Another message'>
1888
+ <error_class_ class='Symbol' value=':foo'/>
1889
+ <exception_ class='Minitest::Assertion' message='Expected :foo to have been thrown, not :bar.'>
1890
+ <backtrace_>
1891
+ <![CDATA[
1892
+ verdict_assert_throws.rb:8:in `block in test_demo_verdict'
1893
+ verdict_assert_throws.rb:4:in `new'
1894
+ verdict_assert_throws.rb:4:in `test_demo_verdict'
1895
+ ]]>
1896
+ </backtrace_>
1897
+ </exception_>
1898
+ </verdict_>
1899
+ </log>
1900
+ ```
1901
+
1902
+
1903
+ ### Refute Verdicts
1904
+
1905
+ #### verdict_refute?
1906
+
1907
+ ```ruby
1908
+ verdict_refute?(id, test, msg = nil)
1909
+ vr?(id, test, msg = nil)
1910
+ ```
1911
+
1912
+ Fails if ```test``` is a true value.
1913
+
1914
+ ```verdict_refute.rb```:
1915
+ ```ruby
1916
+ require 'minitest_log'
1917
+ class Example < Minitest::Test
1918
+ def test_demo_verdict
1919
+ MinitestLog.new('verdict_refute.xml') do |log|
1920
+ log.verdict_refute?(:one_id, false, 'One message')
1921
+ log.verdict_refute?(:another_id, true, 'Another message')
1922
+ end
1923
+ end
1924
+ end
1925
+ ```
1926
+
1927
+ ```verdict_refute.xml```:
1928
+ ```xml
1929
+ <log>
1930
+ <verdict_ method='verdict_refute?' outcome='passed' id='one_id' message='One message'>
1931
+ <actual_ class='FalseClass' value='false'/>
1932
+ </verdict_>
1933
+ <verdict_ method='verdict_refute?' outcome='failed' id='another_id' message='Another message'>
1934
+ <actual_ class='TrueClass' value='true'/>
1935
+ <exception_ class='Minitest::Assertion' message='Expected true to not be truthy.'>
1936
+ <backtrace_>
1937
+ <![CDATA[
1938
+ verdict_refute.rb:6:in `block in test_demo_verdict'
1939
+ verdict_refute.rb:4:in `new'
1940
+ verdict_refute.rb:4:in `test_demo_verdict'
1941
+ ]]>
1942
+ </backtrace_>
1943
+ </exception_>
1944
+ </verdict_>
1945
+ </log>
1946
+ ```
1947
+
1948
+ #### verdict_refute_empty?
1949
+
1950
+ ```ruby
1951
+ verdict_refute_empty?(id, obj, msg = nil)
1952
+ vr_empty?(id, obj, msg = nil)
1953
+ ```
1954
+
1955
+ Fails if ```obj``` is empty.
1956
+
1957
+ ```verdict_refute_empty.rb```:
1958
+ ```ruby
1959
+ require 'minitest_log'
1960
+ class Example < Minitest::Test
1961
+ def test_demo_verdict
1962
+ MinitestLog.new('verdict_refute_empty.xml') do |log|
1963
+ log.verdict_refute_empty?(:one_id, [:a], 'One message')
1964
+ log.verdict_refute_empty?(:another_id, [], 'Another message')
1965
+ end
1966
+ end
1967
+ end
1968
+ ```
1969
+
1970
+ ```verdict_refute_empty.xml```:
1971
+ ```xml
1972
+ <log>
1973
+ <verdict_ method='verdict_refute_empty?' outcome='passed' id='one_id' message='One message'>
1974
+ <actual_ class='Array' value='[:a]'/>
1975
+ </verdict_>
1976
+ <verdict_ method='verdict_refute_empty?' outcome='failed' id='another_id' message='Another message'>
1977
+ <actual_ class='Array' value='[]'/>
1978
+ <exception_ class='Minitest::Assertion' message='Expected [] to not be empty.'>
1979
+ <backtrace_>
1980
+ <![CDATA[
1981
+ verdict_refute_empty.rb:6:in `block in test_demo_verdict'
1982
+ verdict_refute_empty.rb:4:in `new'
1983
+ verdict_refute_empty.rb:4:in `test_demo_verdict'
1984
+ ]]>
1985
+ </backtrace_>
1986
+ </exception_>
1987
+ </verdict_>
1988
+ </log>
1989
+ ```
1990
+
1991
+ #### verdict_refute_equal?
1992
+
1993
+ ```ruby
1994
+ verdict_refute_equal?(id, exp, act, msg = nil)
1995
+ vr_equal?(id, exp, act, msg = nil)
1996
+ ```
1997
+ Fails if ```exp == act```.
1998
+
1999
+ For floats use verdict_refute_in_delta?.
2000
+
2001
+ ```verdict_refute_equal.rb```:
2002
+ ```ruby
2003
+ require 'minitest_log'
2004
+ class Example < Minitest::Test
2005
+ def test_demo_verdict
2006
+ MinitestLog.new('verdict_refute_equal.xml') do |log|
2007
+ log.verdict_refute_equal?(:one_id, 0, 1, 'One message')
2008
+ log.verdict_refute_equal?(:another_id, 0, 0, 'Another message')
2009
+ end
2010
+ end
2011
+ end
2012
+ ```
2013
+
2014
+ ```verdict_refute_equal.xml```:
2015
+ ```xml
2016
+ <log>
2017
+ <verdict_ method='verdict_refute_equal?' outcome='passed' id='one_id' message='One message'>
2018
+ <expected_ class='Integer' value='0'/>
2019
+ <actual_ class='Integer' value='1'/>
2020
+ </verdict_>
2021
+ <verdict_ method='verdict_refute_equal?' outcome='failed' id='another_id' message='Another message'>
2022
+ <expected_ class='Integer' value='0'/>
2023
+ <actual_ class='Integer' value='0'/>
2024
+ <exception_ class='Minitest::Assertion' message='Expected 0 to not be equal to 0.'>
2025
+ <backtrace_>
2026
+ <![CDATA[
2027
+ verdict_refute_equal.rb:6:in `block in test_demo_verdict'
2028
+ verdict_refute_equal.rb:4:in `new'
2029
+ verdict_refute_equal.rb:4:in `test_demo_verdict'
2030
+ ]]>
2031
+ </backtrace_>
2032
+ </exception_>
2033
+ </verdict_>
2034
+ </log>
2035
+ ```
2036
+
2037
+ #### verdict_refute_in_delta?
2038
+
2039
+ ```ruby
2040
+ verdict_refute_in_delta?(id, exp, act, delta = 0.001, msg = nil)
2041
+ vr_in_delta?(id, exp, act, delta = 0.001, msg = nil)
2042
+ ````
2043
+
2044
+ For comparing Floats. Fails if ```exp``` is within ```delta``` of ```act```.
2045
+
2046
+ ```verdict_refute_in_delta.rb```:
2047
+ ```ruby
2048
+ require 'minitest_log'
2049
+ class Example < Minitest::Test
2050
+ def test_demo_verdict
2051
+ MinitestLog.new('verdict_refute_in_delta.xml') do |log|
2052
+ log.verdict_refute_in_delta?(:one_id, 0, 2, 1, 'One message')
2053
+ log.verdict_refute_in_delta?(:another_id, 0, 0, 1, 'Another message')
2054
+ end
2055
+ end
2056
+ end
2057
+ ```
2058
+
2059
+ ```verdict_refute_in_delta.xml```:
2060
+ ```xml
2061
+ <log>
2062
+ <verdict_ method='verdict_refute_in_delta?' outcome='passed' id='one_id' message='One message'>
2063
+ <expected_ class='Integer' value='0'/>
2064
+ <actual_ class='Integer' value='2'/>
2065
+ <delta_ class='Integer' value='1'/>
2066
+ </verdict_>
2067
+ <verdict_ method='verdict_refute_in_delta?' outcome='failed' id='another_id' message='Another message'>
2068
+ <expected_ class='Integer' value='0'/>
2069
+ <actual_ class='Integer' value='0'/>
2070
+ <delta_ class='Integer' value='1'/>
2071
+ <exception_ class='Minitest::Assertion' message='Expected |0 - 0| (0) to not be &lt;= 1.'>
2072
+ <backtrace_>
2073
+ <![CDATA[
2074
+ verdict_refute_in_delta.rb:6:in `block in test_demo_verdict'
2075
+ verdict_refute_in_delta.rb:4:in `new'
2076
+ verdict_refute_in_delta.rb:4:in `test_demo_verdict'
2077
+ ]]>
2078
+ </backtrace_>
2079
+ </exception_>
2080
+ </verdict_>
2081
+ </log>
2082
+ ```
2083
+
2084
+ #### verdict_refute_in_epsilon?
2085
+
2086
+ ```ruby
2087
+ verdict_ refute_in_epsilon?(id, a, b, epsilon = 0.001, msg = nil)
2088
+ vr_in_epsilon?(id, a, b, epsilon = 0.001, msg = nil)
2089
+ ```
2090
+
2091
+ For comparing Floats. Fails if ```exp``` and ```act``` have a relative error less than ```epsilon```.
2092
+
2093
+ ```verdict_refute_in_epsilon.rb```:
2094
+ ```ruby
2095
+ require 'minitest_log'
2096
+ class Example < Minitest::Test
2097
+ def test_demo_verdict
2098
+ MinitestLog.new('verdict_refute_in_epsilon.xml') do |log|
2099
+ log.verdict_refute_in_epsilon?(:one_id, 3, 2, 0, 'One message')
2100
+ log.verdict_refute_in_epsilon?(:another_id, 3, 2, 1, 'Another message')
2101
+ end
2102
+ end
2103
+ end
2104
+ ```
2105
+
2106
+ ```verdict_refute_in_epsilon.xml```:
2107
+ ```xml
2108
+ <log>
2109
+ <verdict_ method='verdict_refute_in_epsilon?' outcome='passed' id='one_id' message='One message'>
2110
+ <expected_ class='Integer' value='3'/>
2111
+ <actual_ class='Integer' value='2'/>
2112
+ <epsilon_ class='Integer' value='0'/>
2113
+ </verdict_>
2114
+ <verdict_ method='verdict_refute_in_epsilon?' outcome='failed' id='another_id' message='Another message'>
2115
+ <expected_ class='Integer' value='3'/>
2116
+ <actual_ class='Integer' value='2'/>
2117
+ <epsilon_ class='Integer' value='1'/>
2118
+ <exception_ class='Minitest::Assertion' message='Expected |3 - 2| (1) to not be &lt;= 3.'>
2119
+ <backtrace_>
2120
+ <![CDATA[
2121
+ verdict_refute_in_epsilon.rb:6:in `block in test_demo_verdict'
2122
+ verdict_refute_in_epsilon.rb:4:in `new'
2123
+ verdict_refute_in_epsilon.rb:4:in `test_demo_verdict'
2124
+ ]]>
2125
+ </backtrace_>
2126
+ </exception_>
2127
+ </verdict_>
2128
+ </log>
2129
+ ```
2130
+
2131
+ #### verdict_refute_includes?
2132
+
2133
+ ```ruby
2134
+ verdict_refute_includes?(id, collection, obj, msg = nil)
2135
+ vr_includes?(id, collection, obj, msg = nil)
2136
+ ```
2137
+
2138
+ Fails if ```collection``` includes ```obj```.
2139
+
2140
+ ```verdict_refute_includes.rb```:
2141
+ ```ruby
2142
+ require 'minitest_log'
2143
+ class Example < Minitest::Test
2144
+ def test_demo_verdict
2145
+ MinitestLog.new('verdict_refute_includes.xml') do |log|
2146
+ log.verdict_refute_includes?(:one_id, [:a, :b, :c], :d, 'One message')
2147
+ log.verdict_refute_includes?(:another_id, [:a, :b, :c], :b, 'Another message')
2148
+ end
2149
+ end
2150
+ end
2151
+ ```
2152
+
2153
+ ```verdict_refute_includes.xml```:
2154
+ ```xml
2155
+ <log>
2156
+ <verdict_ method='verdict_refute_includes?' outcome='passed' id='one_id' message='One message'>
2157
+ <expected_ class='Array' value='[:a, :b, :c]'/>
2158
+ <actual_ class='Symbol' value=':d'/>
2159
+ </verdict_>
2160
+ <verdict_ method='verdict_refute_includes?' outcome='failed' id='another_id' message='Another message'>
2161
+ <expected_ class='Array' value='[:a, :b, :c]'/>
2162
+ <actual_ class='Symbol' value=':b'/>
2163
+ <exception_ class='Minitest::Assertion' message='Expected [:a, :b, :c] to not include :b.'>
2164
+ <backtrace_>
2165
+ <![CDATA[
2166
+ verdict_refute_includes.rb:6:in `block in test_demo_verdict'
2167
+ verdict_refute_includes.rb:4:in `new'
2168
+ verdict_refute_includes.rb:4:in `test_demo_verdict'
2169
+ ]]>
2170
+ </backtrace_>
2171
+ </exception_>
2172
+ </verdict_>
2173
+ </log>
2174
+ ```
2175
+
2176
+ #### verdict_refute_instance_of?
2177
+
2178
+ ```ruby
2179
+ verdict_refute_instance_of?(id, cls, obj, msg = nil)
2180
+ vr_instance_of?(id, cls, obj, msg = nil)
2181
+ ```
2182
+
2183
+ Fails if ```obj``` is an instance of ```cls```.
2184
+
2185
+ ```verdict_refute_instance_of.rb```:
2186
+ ```ruby
2187
+ require 'minitest_log'
2188
+ class Example < Minitest::Test
2189
+ def test_demo_verdict
2190
+ MinitestLog.new('verdict_refute_instance_of.xml') do |log|
2191
+ log.verdict_refute_instance_of?(:one_id, Integer, 'my_string', 'One message')
2192
+ log.verdict_refute_instance_of?(:another_id, String, 'my_string', 'another message')
2193
+ end
2194
+ end
2195
+ end
2196
+ ```
2197
+
2198
+ ```verdict_refute_instance_of.xml```:
2199
+ ```xml
2200
+ <log>
2201
+ <verdict_ method='verdict_refute_instance_of?' outcome='passed' id='one_id' message='One message'>
2202
+ <expected_ class='Class' value='Integer'/>
2203
+ <actual_ class='String' value='&quot;my_string&quot;'/>
2204
+ </verdict_>
2205
+ <verdict_ method='verdict_refute_instance_of?' outcome='failed' id='another_id' message='another message'>
2206
+ <expected_ class='Class' value='String'/>
2207
+ <actual_ class='String' value='&quot;my_string&quot;'/>
2208
+ <exception_ class='Minitest::Assertion' message='Expected &quot;my_string&quot; to not be an instance of String.'>
2209
+ <backtrace_>
2210
+ <![CDATA[
2211
+ verdict_refute_instance_of.rb:6:in `block in test_demo_verdict'
2212
+ verdict_refute_instance_of.rb:4:in `new'
2213
+ verdict_refute_instance_of.rb:4:in `test_demo_verdict'
2214
+ ]]>
2215
+ </backtrace_>
2216
+ </exception_>
2217
+ </verdict_>
2218
+ </log>
2219
+ ```
2220
+
2221
+ #### verdict_refute_kind_of?
2222
+
2223
+ ```ruby
2224
+ verdict_refute_kind_of?(id, cls, obj, msg = nil)
2225
+ vr_kind_of?(id, cls, obj, msg = nil)
2226
+ ```
2227
+
2228
+ Fails if ```obj``` is a kind of ```cls```.
2229
+
2230
+ ```verdict_refute_kind_of.rb```:
2231
+ ```ruby
2232
+ require 'minitest_log'
2233
+ class Example < Minitest::Test
2234
+ def test_demo_verdict
2235
+ MinitestLog.new('verdict_refute_kind_of.xml') do |log|
2236
+ log.verdict_refute_kind_of?(:one_id, String, 1.0, 'One message')
2237
+ log.verdict_refute_kind_of?(:another_id, Numeric, 1.0, 'Another message')
2238
+ end
2239
+ end
2240
+ end
2241
+ ```
2242
+
2243
+ ```verdict_refute_kind_of.xml```:
2244
+ ```xml
2245
+ <log>
2246
+ <verdict_ method='verdict_refute_kind_of?' outcome='passed' id='one_id' message='One message'>
2247
+ <expected_ class='Class' value='String'/>
2248
+ <actual_ class='Float' value='1.0'/>
2249
+ </verdict_>
2250
+ <verdict_ method='verdict_refute_kind_of?' outcome='failed' id='another_id' message='Another message'>
2251
+ <expected_ class='Class' value='Numeric'/>
2252
+ <actual_ class='Float' value='1.0'/>
2253
+ <exception_ class='Minitest::Assertion' message='Expected 1.0 to not be a kind of Numeric.'>
2254
+ <backtrace_>
2255
+ <![CDATA[
2256
+ verdict_refute_kind_of.rb:6:in `block in test_demo_verdict'
2257
+ verdict_refute_kind_of.rb:4:in `new'
2258
+ verdict_refute_kind_of.rb:4:in `test_demo_verdict'
2259
+ ]]>
2260
+ </backtrace_>
2261
+ </exception_>
2262
+ </verdict_>
2263
+ </log>
2264
+ ```
2265
+
2266
+ #### verdict_refute_match?
2267
+
2268
+ ```ruby
2269
+ verdict_refute_match?(id, matcher, obj, msg = nil)
2270
+ vr_match?(id, matcher, obj, msg = nil)
2271
+ ```
2272
+
2273
+ Fails if ```matcher =~ obj```.
2274
+
2275
+ ```verdict_refute_match.rb```:
2276
+ ```ruby
2277
+ require 'minitest_log'
2278
+ class Example < Minitest::Test
2279
+ def test_demo_verdict
2280
+ MinitestLog.new('verdict_refute_match.xml') do |log|
2281
+ log.verdict_refute_match?(:one_id, /foo/, 'feed', 'One message')
2282
+ log.verdict_refute_match?(:another_id, /foo/, 'food', 'Another message')
2283
+ end
2284
+ end
2285
+ end
2286
+ ```
2287
+
2288
+ ```verdict_refute_match.xml```:
2289
+ ```xml
2290
+ <log>
2291
+ <verdict_ method='verdict_refute_match?' outcome='passed' id='one_id' message='One message'>
2292
+ <expected_ class='Regexp' value='/foo/'/>
2293
+ <actual_ class='String' value='&quot;feed&quot;'/>
2294
+ </verdict_>
2295
+ <verdict_ method='verdict_refute_match?' outcome='failed' id='another_id' message='Another message'>
2296
+ <expected_ class='Regexp' value='/foo/'/>
2297
+ <actual_ class='String' value='&quot;food&quot;'/>
2298
+ <exception_ class='Minitest::Assertion' message='Expected /foo/ to not match &quot;food&quot;.'>
2299
+ <backtrace_>
2300
+ <![CDATA[
2301
+ verdict_refute_match.rb:6:in `block in test_demo_verdict'
2302
+ verdict_refute_match.rb:4:in `new'
2303
+ verdict_refute_match.rb:4:in `test_demo_verdict'
2304
+ ]]>
2305
+ </backtrace_>
2306
+ </exception_>
2307
+ </verdict_>
2308
+ </log>
2309
+ ```
2310
+
2311
+ #### verdict_refute_nil?
2312
+
2313
+ ```ruby
2314
+ verdict_refute_nil?(id, obj, msg = nil)
2315
+ vr_nil?(id, obj, msg = nil)
2316
+ ```
2317
+
2318
+ Fails if ```obj``` is nil.
2319
+
2320
+ ```verdict_refute_nil.rb```:
2321
+ ```ruby
2322
+ require 'minitest_log'
2323
+ class Example < Minitest::Test
2324
+ def test_demo_verdict
2325
+ MinitestLog.new('verdict_refute_nil.xml') do |log|
2326
+ log.verdict_refute_nil?(:one_id, :a, 'One message')
2327
+ log.verdict_refute_nil?(:another_id, nil, 'Another message')
2328
+ end
2329
+ end
2330
+ end
2331
+ ```
2332
+
2333
+ ```verdict_refute_nil.xml```:
2334
+ ```xml
2335
+ <log>
2336
+ <verdict_ method='verdict_refute_nil?' outcome='passed' id='one_id' message='One message'>
2337
+ <actual_ class='Symbol' value=':a'/>
2338
+ </verdict_>
2339
+ <verdict_ method='verdict_refute_nil?' outcome='failed' id='another_id' message='Another message'>
2340
+ <actual_ class='NilClass' value='nil'/>
2341
+ <exception_ class='Minitest::Assertion' message='Expected nil to not be nil.'>
2342
+ <backtrace_>
2343
+ <![CDATA[
2344
+ verdict_refute_nil.rb:6:in `block in test_demo_verdict'
2345
+ verdict_refute_nil.rb:4:in `new'
2346
+ verdict_refute_nil.rb:4:in `test_demo_verdict'
2347
+ ]]>
2348
+ </backtrace_>
2349
+ </exception_>
2350
+ </verdict_>
2351
+ </log>
2352
+ ```
2353
+
2354
+ #### verdict_refute_operator?
2355
+
2356
+ ```ruby
2357
+ verdict_refute_operator?(id, o1, op, o2 = UNDEFINED, msg = nil)
2358
+ vr_operator?(id, o1, op, o2 = UNDEFINED, msg = nil)
2359
+ ````
2360
+
2361
+ Fails if ```o1``` is not ```op``` ```o2```.
2362
+
2363
+ ```verdict_refute_operator.rb```:
2364
+ ```ruby
2365
+ require 'minitest_log'
2366
+ class Example < Minitest::Test
2367
+ def test_demo_verdict
2368
+ MinitestLog.new('verdict_refute_operator.xml') do |log|
2369
+ log.verdict_refute_operator?(:one_id, 5, :<=, 4, 'One message')
2370
+ log.verdict_refute_operator?(:another_id, 3, :<=, 4, 'Another message')
2371
+ end
2372
+ end
2373
+ end
2374
+ ```
2375
+
2376
+ ```verdict_refute_operator.xml```:
2377
+ ```xml
2378
+ <log>
2379
+ <verdict_ method='verdict_refute_operator?' outcome='passed' id='one_id' message='One message'>
2380
+ <object_1_ class='Integer' value='5'/>
2381
+ <operator_ class='Symbol' value=':&lt;='/>
2382
+ <object_2_ class='Integer' value='4'/>
2383
+ </verdict_>
2384
+ <verdict_ method='verdict_refute_operator?' outcome='failed' id='another_id' message='Another message'>
2385
+ <object_1_ class='Integer' value='3'/>
2386
+ <operator_ class='Symbol' value=':&lt;='/>
2387
+ <object_2_ class='Integer' value='4'/>
2388
+ <exception_ class='Minitest::Assertion' message='Expected 3 to not be &lt;= 4.'>
2389
+ <backtrace_>
2390
+ <![CDATA[
2391
+ verdict_refute_operator.rb:6:in `block in test_demo_verdict'
2392
+ verdict_refute_operator.rb:4:in `new'
2393
+ verdict_refute_operator.rb:4:in `test_demo_verdict'
2394
+ ]]>
2395
+ </backtrace_>
2396
+ </exception_>
2397
+ </verdict_>
2398
+ </log>
2399
+ ```
2400
+
2401
+ #### verdict_refute_predicate?
2402
+
2403
+ ```ruby
2404
+ verdict_refute_predicate?(id, o1, op, msg = nil)
2405
+ vr_predicate?(id, o1, op, msg = nil)
2406
+ ```
2407
+
2408
+ For testing with predicates.
2409
+
2410
+ ```verdict_refute_predicate.rb```:
2411
+ ```ruby
2412
+ require 'minitest_log'
2413
+ class Example < Minitest::Test
2414
+ def test_demo_verdict
2415
+ MinitestLog.new('verdict_refute_predicate.xml') do |log|
2416
+ log.verdict_refute_predicate?(:one_id, 'x', :empty?, 'One message')
2417
+ log.verdict_refute_predicate?(:another_id, '', :empty?, 'Another message')
2418
+ end
2419
+ end
2420
+ end
2421
+ ```
2422
+
2423
+ ```verdict_refute_predicate.xml```:
2424
+ ```xml
2425
+ <log>
2426
+ <verdict_ method='verdict_refute_predicate?' outcome='passed' id='one_id' message='One message'>
2427
+ <object_ class='String' value='&quot;x&quot;'/>
2428
+ <operator_ class='Symbol' value=':empty?'/>
2429
+ </verdict_>
2430
+ <verdict_ method='verdict_refute_predicate?' outcome='failed' id='another_id' message='Another message'>
2431
+ <object_ class='String' value='&quot;&quot;'/>
2432
+ <operator_ class='Symbol' value=':empty?'/>
2433
+ <exception_ class='Minitest::Assertion' message='Expected &quot;&quot; to not be empty?.'>
2434
+ <backtrace_>
2435
+ <![CDATA[
2436
+ verdict_refute_predicate.rb:6:in `block in test_demo_verdict'
2437
+ verdict_refute_predicate.rb:4:in `new'
2438
+ verdict_refute_predicate.rb:4:in `test_demo_verdict'
2439
+ ]]>
2440
+ </backtrace_>
2441
+ </exception_>
2442
+ </verdict_>
2443
+ </log>
2444
+ ```
2445
+
2446
+ #### verdict_refute_respond_to?
2447
+
2448
+ ```ruby
2449
+ verdict_refute_respond_to?(id, obj, meth, msg = nil)
2450
+ vr_respond_to?(id, obj, meth, msg = nil)
2451
+ ```
2452
+
2453
+ Fails if ```obj``` responds to ```meth```.
2454
+
2455
+ ```verdict_refute_respond_to.rb```:
2456
+ ```ruby
2457
+ require 'minitest_log'
2458
+ class Example < Minitest::Test
2459
+ def test_demo_verdict
2460
+ MinitestLog.new('verdict_refute_respond_to.xml') do |log|
2461
+ log.verdict_refute_respond_to?(:one_id, 0, :empty?, 'One message')
2462
+ log.verdict_refute_respond_to?(:another_id, 0, :succ, 'Another message')
2463
+ end
2464
+ end
2465
+ end
2466
+ ```
2467
+
2468
+ ```verdict_refute_respond_to.xml```:
2469
+ ```xml
2470
+ <log>
2471
+ <verdict_ method='verdict_refute_respond_to?' outcome='passed' id='one_id' message='One message'>
2472
+ <object_ class='Integer' value='0'/>
2473
+ <method_ class='Symbol' value=':empty?'/>
2474
+ </verdict_>
2475
+ <verdict_ method='verdict_refute_respond_to?' outcome='failed' id='another_id' message='Another message'>
2476
+ <object_ class='Integer' value='0'/>
2477
+ <method_ class='Symbol' value=':succ'/>
2478
+ <exception_ class='Minitest::Assertion' message='Expected 0 to not respond to succ.'>
2479
+ <backtrace_>
2480
+ <![CDATA[
2481
+ verdict_refute_respond_to.rb:6:in `block in test_demo_verdict'
2482
+ verdict_refute_respond_to.rb:4:in `new'
2483
+ verdict_refute_respond_to.rb:4:in `test_demo_verdict'
2484
+ ]]>
2485
+ </backtrace_>
2486
+ </exception_>
2487
+ </verdict_>
2488
+ </log>
2489
+ ```
2490
+
2491
+ #### verdict_refute_same?
2492
+
2493
+ ```ruby
2494
+ verdict_refute_same?(id, exp, act, msg = nil)
2495
+ vr_same?(id, exp, act, msg = nil)
2496
+ ```
2497
+
2498
+ Fails if ```exp``` is the same (by object identity) as ```act```.
2499
+
2500
+ ```verdict_refute_same.rb```:
2501
+ ```ruby
2502
+ require 'minitest_log'
2503
+ class Example < Minitest::Test
2504
+ def test_demo_verdict
2505
+ MinitestLog.new('verdict_refute_same.xml') do |log|
2506
+ log.verdict_refute_same?(:one_id, 'foo', 'foo', 'One message')
2507
+ log.verdict_refute_same?(:another_id, :foo, :foo, 'Another message')
2508
+ end
2509
+ end
2510
+ end
2511
+ ```
2512
+
2513
+ ```verdict_refute_same.xml```:
2514
+ ```xml
2515
+ <log>
2516
+ <verdict_ method='verdict_refute_same?' outcome='passed' id='one_id' message='One message'>
2517
+ <expected_ class='String' value='&quot;foo&quot;'/>
2518
+ <actual_ class='String' value='&quot;foo&quot;'/>
2519
+ </verdict_>
2520
+ <verdict_ method='verdict_refute_same?' outcome='failed' id='another_id' message='Another message'>
2521
+ <expected_ class='Symbol' value=':foo'/>
2522
+ <actual_ class='Symbol' value=':foo'/>
2523
+ <exception_ class='Minitest::Assertion' message='Expected :foo (oid=1043228) to not be the same as :foo (oid=1043228).'>
2524
+ <backtrace_>
2525
+ <![CDATA[
2526
+ verdict_refute_same.rb:6:in `block in test_demo_verdict'
2527
+ verdict_refute_same.rb:4:in `new'
2528
+ verdict_refute_same.rb:4:in `test_demo_verdict'
2529
+ ]]>
2530
+ </backtrace_>
2531
+ </exception_>
2532
+ </verdict_>
2533
+ </log>
2534
+ ```
2535
+
2536
+
2537
+
2538
+ ## Tips
2539
+
2540
+ ### Use Short Verdict Aliases
2541
+
2542
+ Use the short alias for a verdict method, to:
2543
+
2544
+ - Have less source code.
2545
+ - Allow code-completion to work *much* better (completion select list gets shorter *much* sooner).
2546
+
2547
+ Examples:
2548
+
2549
+ - ```log.va_equal?```, not ```log.verdict assert_equal?```.
2550
+ - ```log.vr_empty?```, not ```log.verdict_refute_empty?```.
2551
+
2552
+ ### Avoid Failure Clutter
2553
+
2554
+ Use verdict return values (```true```/```false```) to omit verdicts that would definitely fail. This can greatly simplify your test results.
2555
+
2556
+ In the example below, the test attempts to create a user. If the create succeeds, the test further validates, then deletes the user.
2557
+
2558
+ However, if the create fails, the test does not attempt to validate or delete the user (which attempts would fail, and might raise exceptions).
2559
+
2560
+ Thus, assuming a failed create returns ```nil```:
2561
+
2562
+ ```ruby
2563
+ user_name = 'Bill Jones'
2564
+ user = SomeApi.create_user(user_name)
2565
+ if log.verdict_refute_nil?(:user_created, user)
2566
+ log.verdict_assert_equal?(:user_name, user_name, user.name)
2567
+ SomeApi.delete_user(user.id)
2568
+ end
2569
+ ```
2570
+
2571
+ ### Facilitate Post-Processing
2572
+
2573
+ If your logs will be parsed in post-processing, you can make that go smoother by creating the logs with certain options:
2574
+
2575
+ - ```:xml_indentation => -1```: so that there's no log-generated whitespace. (But you'll still see the same indented display in your browser.)
2576
+ - ```:summary => true```: so that the counts are already computed.
2577
+ - ```:error_verdict => true```: so that a log that has errors will also have at least one failed verdict.
2578
+
2579
+ See [Options](#options)