detest 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/detest/inochi.rb +3 -3
- data/man/man1/detest.1 +420 -389
- metadata +8 -8
data/lib/detest/inochi.rb
CHANGED
@@ -18,12 +18,12 @@ module Detest
|
|
18
18
|
##
|
19
19
|
# Number of this release of this project.
|
20
20
|
#
|
21
|
-
VERSION = '3.1.
|
21
|
+
VERSION = '3.1.2'
|
22
22
|
|
23
23
|
##
|
24
24
|
# Date of this release of this project.
|
25
25
|
#
|
26
|
-
RELDATE = '2010-08-
|
26
|
+
RELDATE = '2010-08-10'
|
27
27
|
|
28
28
|
##
|
29
29
|
# Description of this release of this project.
|
@@ -74,7 +74,7 @@ module Detest
|
|
74
74
|
# }
|
75
75
|
#
|
76
76
|
DEVTIME = {
|
77
|
-
'inochi' => [ '>= 5.0.
|
77
|
+
'inochi' => [ '>= 5.0.1', '< 6' ],
|
78
78
|
}
|
79
79
|
|
80
80
|
# establish gem version dependencies
|
data/man/man1/detest.1
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
.\" Title: detest
|
3
3
|
.\" Author: [see the "AUTHORS" section]
|
4
4
|
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
|
5
|
-
.\" Date: 08/
|
5
|
+
.\" Date: 08/10/2010
|
6
6
|
.\" Manual: \ \&
|
7
|
-
.\" Source: \ \& 3.1.
|
7
|
+
.\" Source: \ \& 3.1.2
|
8
8
|
.\" Language: English
|
9
9
|
.\"
|
10
|
-
.TH "DETEST" "1" "08/
|
10
|
+
.TH "DETEST" "1" "08/10/2010" "\ \& 3\&.1\&.2" "\ \&"
|
11
11
|
.\" -----------------------------------------------------------------
|
12
12
|
.\" * set default formatting
|
13
13
|
.\" -----------------------------------------------------------------
|
@@ -346,6 +346,252 @@ require \'detest/auto\'
|
|
346
346
|
.\}
|
347
347
|
.sp
|
348
348
|
See the API documentation for more information and examples\&.
|
349
|
+
.SH "ASSERTIONS"
|
350
|
+
.SS "Writing assertions"
|
351
|
+
.sp
|
352
|
+
The following methods accept a block parameter and assert something about the result of executing that block\&. They also accept an optional message, which is shown in their failure reports if they fail\&.
|
353
|
+
.TS
|
354
|
+
tab(:);
|
355
|
+
lt lt
|
356
|
+
lt lt
|
357
|
+
lt lt
|
358
|
+
lt lt
|
359
|
+
lt lt.
|
360
|
+
T{
|
361
|
+
.sp
|
362
|
+
T()
|
363
|
+
T}:T{
|
364
|
+
.sp
|
365
|
+
assert true (not nil and not false) \(em API documentation
|
366
|
+
T}
|
367
|
+
T{
|
368
|
+
.sp
|
369
|
+
F()
|
370
|
+
T}:T{
|
371
|
+
.sp
|
372
|
+
assert not true (nil or false) \(em API documentation
|
373
|
+
T}
|
374
|
+
T{
|
375
|
+
.sp
|
376
|
+
N()
|
377
|
+
T}:T{
|
378
|
+
.sp
|
379
|
+
assert that the value is nil \(em API documentation
|
380
|
+
T}
|
381
|
+
T{
|
382
|
+
.sp
|
383
|
+
E()
|
384
|
+
T}:T{
|
385
|
+
.sp
|
386
|
+
assert that an execption is raised \(em API documentation
|
387
|
+
T}
|
388
|
+
T{
|
389
|
+
.sp
|
390
|
+
C()
|
391
|
+
T}:T{
|
392
|
+
.sp
|
393
|
+
assert that a symbol is thrown \(em API documentation
|
394
|
+
T}
|
395
|
+
.TE
|
396
|
+
.sp 1
|
397
|
+
.sp
|
398
|
+
For the T() and F() methods, you may alternatively pass the condition to be asserted as the first argument (instead of passing it as a block)\&. This might result in a more pleasing syntax, depending on your taste:
|
399
|
+
.sp
|
400
|
+
.if n \{\
|
401
|
+
.RS 4
|
402
|
+
.\}
|
403
|
+
.nf
|
404
|
+
my_ticket = rand()
|
405
|
+
winning_ticket = rand()
|
406
|
+
|
407
|
+
# passing the condition as a block:
|
408
|
+
T("I won?! Dream on\&.") { my_ticket != winning_ticket }
|
409
|
+
F("I won?! Dream on\&.") { my_ticket == winning_ticket }
|
410
|
+
|
411
|
+
# passing the condition as an argument:
|
412
|
+
T my_ticket != winning_ticket, "I won?! Dream on\&."
|
413
|
+
F my_ticket == winning_ticket, "I won?! Dream on\&."
|
414
|
+
.fi
|
415
|
+
.if n \{\
|
416
|
+
.RE
|
417
|
+
.\}
|
418
|
+
.SS "Negating assertions"
|
419
|
+
.sp
|
420
|
+
The following methods are the \fIopposite\fR of normal assertions\&.
|
421
|
+
.TS
|
422
|
+
tab(:);
|
423
|
+
lt lt
|
424
|
+
lt lt
|
425
|
+
lt lt
|
426
|
+
lt lt
|
427
|
+
lt lt.
|
428
|
+
T{
|
429
|
+
.sp
|
430
|
+
T!()
|
431
|
+
T}:T{
|
432
|
+
.sp
|
433
|
+
same as F() \(em API documentation
|
434
|
+
T}
|
435
|
+
T{
|
436
|
+
.sp
|
437
|
+
F!()
|
438
|
+
T}:T{
|
439
|
+
.sp
|
440
|
+
same as T() \(em API documentation
|
441
|
+
T}
|
442
|
+
T{
|
443
|
+
.sp
|
444
|
+
N!()
|
445
|
+
T}:T{
|
446
|
+
.sp
|
447
|
+
assert that value is not nil \(em API documentation
|
448
|
+
T}
|
449
|
+
T{
|
450
|
+
.sp
|
451
|
+
E!()
|
452
|
+
T}:T{
|
453
|
+
.sp
|
454
|
+
assert that an exception is \fInot\fR raised \(em API documentation
|
455
|
+
T}
|
456
|
+
T{
|
457
|
+
.sp
|
458
|
+
C!()
|
459
|
+
T}:T{
|
460
|
+
.sp
|
461
|
+
assert that a symbol is \fInot\fR thrown \(em API documentation
|
462
|
+
T}
|
463
|
+
.TE
|
464
|
+
.sp 1
|
465
|
+
.SS "Sampling assertions"
|
466
|
+
.sp
|
467
|
+
The following methods let you \fIcheck the outcome\fR of an assertion without recording a success or failure in the test execution report\&.
|
468
|
+
.TS
|
469
|
+
tab(:);
|
470
|
+
lt lt
|
471
|
+
lt lt
|
472
|
+
lt lt
|
473
|
+
lt lt
|
474
|
+
lt lt.
|
475
|
+
T{
|
476
|
+
.sp
|
477
|
+
T?()
|
478
|
+
T}:T{
|
479
|
+
.sp
|
480
|
+
returns true if T() passes; false otherwise \(em API documentation
|
481
|
+
T}
|
482
|
+
T{
|
483
|
+
.sp
|
484
|
+
F?()
|
485
|
+
T}:T{
|
486
|
+
.sp
|
487
|
+
returns true if F() passes; false otherwise \(em API documentation
|
488
|
+
T}
|
489
|
+
T{
|
490
|
+
.sp
|
491
|
+
N?()
|
492
|
+
T}:T{
|
493
|
+
.sp
|
494
|
+
returns true if N() passes; false otherwise \(em API documentation
|
495
|
+
T}
|
496
|
+
T{
|
497
|
+
.sp
|
498
|
+
E?()
|
499
|
+
T}:T{
|
500
|
+
.sp
|
501
|
+
returns true if E() passes; false otherwise \(em API documentation
|
502
|
+
T}
|
503
|
+
T{
|
504
|
+
.sp
|
505
|
+
C?()
|
506
|
+
T}:T{
|
507
|
+
.sp
|
508
|
+
returns true if C() passes; false otherwise \(em API documentation
|
509
|
+
T}
|
510
|
+
.TE
|
511
|
+
.sp 1
|
512
|
+
.SS "Assertion failure reports"
|
513
|
+
.sp
|
514
|
+
Assertions failures are reported in the following manner:
|
515
|
+
.sp
|
516
|
+
.if n \{\
|
517
|
+
.RS 4
|
518
|
+
.\}
|
519
|
+
.nf
|
520
|
+
\- fail: block must yield true (!nil && !false)
|
521
|
+
call:
|
522
|
+
\- test/simple\&.rb:17
|
523
|
+
\- test/simple\&.rb:3
|
524
|
+
code: |\-
|
525
|
+
[12\&.\&.22] in test/simple\&.rb
|
526
|
+
12
|
527
|
+
13 D "with more nested tests" do
|
528
|
+
14 x = 5
|
529
|
+
15
|
530
|
+
16 T { x > 2 } # passes
|
531
|
+
=> 17 F { x > 2 } # fails
|
532
|
+
18 E { x\&.hello } # passes
|
533
|
+
19 end
|
534
|
+
20 end
|
535
|
+
21
|
536
|
+
22 # equivalent of before(:each) or setup()
|
537
|
+
bind: test/simple\&.rb:17
|
538
|
+
vars:
|
539
|
+
x: (Fixnum) 5
|
540
|
+
y: (Fixnum) 83
|
541
|
+
.fi
|
542
|
+
.if n \{\
|
543
|
+
.RE
|
544
|
+
.\}
|
545
|
+
.sp
|
546
|
+
Failure reports are composed of the following sections:
|
547
|
+
.TS
|
548
|
+
tab(:);
|
549
|
+
lt lt
|
550
|
+
lt lt
|
551
|
+
lt lt
|
552
|
+
lt lt
|
553
|
+
lt lt.
|
554
|
+
T{
|
555
|
+
.sp
|
556
|
+
:fail
|
557
|
+
T}:T{
|
558
|
+
.sp
|
559
|
+
Description of the assertion failure\&.
|
560
|
+
T}
|
561
|
+
T{
|
562
|
+
.sp
|
563
|
+
:call
|
564
|
+
T}:T{
|
565
|
+
.sp
|
566
|
+
Stack trace leading to the point of failure\&.
|
567
|
+
T}
|
568
|
+
T{
|
569
|
+
.sp
|
570
|
+
:code
|
571
|
+
T}:T{
|
572
|
+
.sp
|
573
|
+
Source code surrounding the point of failure\&.
|
574
|
+
T}
|
575
|
+
T{
|
576
|
+
.sp
|
577
|
+
:bind
|
578
|
+
T}:T{
|
579
|
+
.sp
|
580
|
+
Source location of values in :vars section\&.
|
581
|
+
T}
|
582
|
+
T{
|
583
|
+
.sp
|
584
|
+
:vars
|
585
|
+
T}:T{
|
586
|
+
.sp
|
587
|
+
Local variables visible at the point of failure\&.
|
588
|
+
T}
|
589
|
+
.TE
|
590
|
+
.sp 1
|
591
|
+
.sp
|
592
|
+
After the failure is reported, you will be placed into a debugger to investigate the failure if the Detest\&.debug option is enabled\&.
|
593
|
+
.sp
|
594
|
+
Assertion failure reports can be accessed at any time within the test execution trace provided by the Detest\&.trace() method\&.
|
349
595
|
.SH "TESTS"
|
350
596
|
.SS "Defining tests"
|
351
597
|
.sp
|
@@ -370,9 +616,25 @@ end
|
|
370
616
|
A test may contain nested tests, as illustrated above\&.
|
371
617
|
.SS "Insulating tests"
|
372
618
|
.sp
|
373
|
-
The D!() method defines a new test that is explicitly insulated from the tests that contain it and also from the top\-level Ruby environment\&.
|
619
|
+
The D!() method defines a new test that is explicitly insulated from the tests that contain it and also from the top\-level Ruby environment\&.
|
374
620
|
.sp
|
375
621
|
Inside an insulated test, you are free to mix\-in (using the \fBextend\fR keyword, not the \fBinclude\fR keyword) any modules your test logic needs\&. You can also define your own constants, methods, classes, and modules here\&.
|
622
|
+
.if n \{\
|
623
|
+
.sp
|
624
|
+
.\}
|
625
|
+
.RS 4
|
626
|
+
.it 1 an-trap
|
627
|
+
.nr an-no-space-flag 1
|
628
|
+
.nr an-break-flag 1
|
629
|
+
.br
|
630
|
+
.ps +1
|
631
|
+
\fBNote\fR
|
632
|
+
.ps -1
|
633
|
+
.br
|
634
|
+
.sp
|
635
|
+
Root\-level calls to the D() method are insulated by default\&.
|
636
|
+
.sp .5v
|
637
|
+
.RE
|
376
638
|
.PP
|
377
639
|
\fBExample\ \&1.\ \&Insulated and uninsulated tests\fR
|
378
640
|
.sp
|
@@ -423,24 +685,14 @@ Detest will output the following:
|
|
423
685
|
\- an inner, insulated test:
|
424
686
|
\-\-\-
|
425
687
|
pass: 10
|
426
|
-
time: 0\&.
|
688
|
+
time: 0\&.009158971
|
427
689
|
.fi
|
428
690
|
.if n \{\
|
429
691
|
.RE
|
430
692
|
.\}
|
431
693
|
.SS "Sharing tests"
|
432
|
-
.TS
|
433
|
-
tab(:);
|
434
|
-
lt lt
|
435
|
-
lt lt
|
436
|
-
lt lt.
|
437
|
-
T{
|
438
|
-
.sp
|
439
|
-
S()
|
440
|
-
T}:T{
|
441
694
|
.sp
|
442
|
-
|
443
|
-
|
695
|
+
The S() method is a mechanism for sharing code\&. It can be used in two ways:
|
444
696
|
.sp
|
445
697
|
.RS 4
|
446
698
|
.ie n \{\
|
@@ -463,23 +715,10 @@ When called with a block, it shares the given block (under a given identifier) f
|
|
463
715
|
.\}
|
464
716
|
When called without a block, it injects a previously shared block (under a given identifier) into the environment where it is called\&.
|
465
717
|
.RE
|
466
|
-
T}
|
467
|
-
T{
|
468
718
|
.sp
|
469
|
-
S!()
|
470
|
-
T}:T{
|
719
|
+
The S!() method is a combination of the two uses of the S() method: it lets you simultaneously share a block of code while injecting it into the environment where that method is called\&.
|
471
720
|
.sp
|
472
|
-
|
473
|
-
T}
|
474
|
-
T{
|
475
|
-
.sp
|
476
|
-
S?()
|
477
|
-
T}:T{
|
478
|
-
.sp
|
479
|
-
Checks whether any code has been shared under a given identifier\&.
|
480
|
-
T}
|
481
|
-
.TE
|
482
|
-
.sp 1
|
721
|
+
The S?() method checks whether any code has been shared under a given identifier\&.
|
483
722
|
.PP
|
484
723
|
\fBExample\ \&2.\ \&Sharing code between tests\fR
|
485
724
|
.sp
|
@@ -539,32 +778,16 @@ Detest will output the following:
|
|
539
778
|
\- Power is power!
|
540
779
|
\-\-\-
|
541
780
|
pass: 3
|
542
|
-
time: 0\&.
|
781
|
+
time: 0\&.007596486
|
543
782
|
.fi
|
544
783
|
.if n \{\
|
545
784
|
.RE
|
546
785
|
.\}
|
547
786
|
.SS "Logging information"
|
548
|
-
.TS
|
549
|
-
tab(:);
|
550
|
-
lt lt
|
551
|
-
lt lt.
|
552
|
-
T{
|
553
787
|
.sp
|
554
|
-
I()
|
555
|
-
T}:T{
|
556
|
-
.sp
|
557
|
-
Mechanism for inserting arbitrary Ruby objects into the test execution report\&. You can think of this method as being a way \fIto inform\fR someone\&.
|
558
|
-
T}
|
559
|
-
T{
|
560
|
-
.sp
|
561
|
-
I!()
|
562
|
-
T}:T{
|
788
|
+
The I() method is a mechanism for inserting arbitrary Ruby objects into the test execution report\&. You can think of this method as being a way \fIto inform\fR someone\&.
|
563
789
|
.sp
|
564
|
-
|
565
|
-
T}
|
566
|
-
.TE
|
567
|
-
.sp 1
|
790
|
+
The I!() method starts the interactive debugger at the location where it is called\&. You can think of this method as being a way \fIto investigate\fR the state of your program\&.
|
568
791
|
.PP
|
569
792
|
\fBExample\ \&3.\ \&Logging information in the execution report\fR
|
570
793
|
.sp
|
@@ -603,7 +826,7 @@ Detest will output the following:
|
|
603
826
|
\- Preparing spell to defeat mortal foes\&.\&.\&.
|
604
827
|
\- Magician:
|
605
828
|
\- Preparing rabbits to pull from hat\&.\&.\&.
|
606
|
-
\-
|
829
|
+
\- 8
|
607
830
|
\- Calculator:
|
608
831
|
\- 3\&.141592653589793
|
609
832
|
\- \- 1
|
@@ -613,391 +836,137 @@ Detest will output the following:
|
|
613
836
|
\- b
|
614
837
|
\- c
|
615
838
|
\- foo: bar!
|
616
|
-
\-\-\-
|
617
|
-
time: 0\&.
|
618
|
-
.fi
|
619
|
-
.if n \{\
|
620
|
-
.RE
|
621
|
-
.\}
|
622
|
-
.SS "Execution hooks"
|
623
|
-
.sp
|
624
|
-
A \fBhook\fR is a scheduled point of entry into the test execution process\&. The following \fBhook methods\fR allow you to register a block of code to execute when a hook occurs:
|
625
|
-
.TS
|
626
|
-
tab(:);
|
627
|
-
lt lt
|
628
|
-
lt lt
|
629
|
-
lt lt
|
630
|
-
lt lt.
|
631
|
-
T{
|
632
|
-
.sp
|
633
|
-
D\&.<()
|
634
|
-
T}:T{
|
635
|
-
.sp
|
636
|
-
Calls the given block \fIbefore each\fR child test\&.
|
637
|
-
T}
|
638
|
-
T{
|
639
|
-
.sp
|
640
|
-
D\&.>()
|
641
|
-
T}:T{
|
642
|
-
.sp
|
643
|
-
Calls the given block \fIafter each\fR child test\&.
|
644
|
-
T}
|
645
|
-
T{
|
646
|
-
.sp
|
647
|
-
D\&.<<()
|
648
|
-
T}:T{
|
649
|
-
.sp
|
650
|
-
Calls the given block \fIbefore all\fR child tests\&.
|
651
|
-
T}
|
652
|
-
T{
|
653
|
-
.sp
|
654
|
-
D\&.>>()
|
655
|
-
T}:T{
|
656
|
-
.sp
|
657
|
-
Calls the given block \fIafter all\fR child tests\&.
|
658
|
-
T}
|
659
|
-
.TE
|
660
|
-
.sp 1
|
661
|
-
.sp
|
662
|
-
A hook method can be called multiple times\&. Each additional call schedules more logic to be executed during the hook:
|
663
|
-
.sp
|
664
|
-
.if n \{\
|
665
|
-
.RS 4
|
666
|
-
.\}
|
667
|
-
.nf
|
668
|
-
D \&.< { puts "do something" }
|
669
|
-
D \&.< { puts "do something more!" }
|
670
|
-
.fi
|
671
|
-
.if n \{\
|
672
|
-
.RE
|
673
|
-
.\}
|
674
|
-
.PP
|
675
|
-
\fBExample\ \&4.\ \&Using hooks to perform before and after actions\fR
|
676
|
-
.sp
|
677
|
-
When the following test is run:
|
678
|
-
.sp
|
679
|
-
.if n \{\
|
680
|
-
.RS 4
|
681
|
-
.\}
|
682
|
-
.nf
|
683
|
-
require \'detest/auto\'
|
684
|
-
|
685
|
-
D "outer test" do
|
686
|
-
D \&.< { I "(outer hook) before each" }
|
687
|
-
D \&.> { I "(outer hook) after each" }
|
688
|
-
D \&.<< { I "(outer hook) before all" }
|
689
|
-
D \&.>> { I "(outer hook) after all" }
|
690
|
-
|
691
|
-
D "inner test 1" do
|
692
|
-
D \&.< { I "(inner hook) before each" }
|
693
|
-
D \&.> { I "(inner hook) after each" }
|
694
|
-
D \&.<< { I "(inner hook) before all" }
|
695
|
-
D \&.>> { I "(inner hook) after all" }
|
696
|
-
|
697
|
-
D "inner test 1\&.1" do
|
698
|
-
I "hello world"
|
699
|
-
end
|
700
|
-
end
|
701
|
-
|
702
|
-
D "inner test 2" do
|
703
|
-
I "goodbye world"
|
704
|
-
end
|
705
|
-
|
706
|
-
D \&.< { I "(outer hook) before each, again" }
|
707
|
-
D \&.> { I "(outer hook) after each, again" }
|
708
|
-
end
|
709
|
-
.fi
|
710
|
-
.if n \{\
|
711
|
-
.RE
|
712
|
-
.\}
|
713
|
-
.sp
|
714
|
-
Detest will output the following:
|
715
|
-
.sp
|
716
|
-
.if n \{\
|
717
|
-
.RS 4
|
718
|
-
.\}
|
719
|
-
.nf
|
720
|
-
\-\-\-
|
721
|
-
\- outer test:
|
722
|
-
\- (outer hook) before all
|
723
|
-
\- (outer hook) before each
|
724
|
-
\- (outer hook) before each, again
|
725
|
-
\- inner test 1:
|
726
|
-
\- (inner hook) before all
|
727
|
-
\- (inner hook) before each
|
728
|
-
\- inner test 1\&.1:
|
729
|
-
\- hello world
|
730
|
-
\- (inner hook) after each
|
731
|
-
\- (inner hook) after all
|
732
|
-
\- (outer hook) after each
|
733
|
-
\- (outer hook) after each, again
|
734
|
-
\- (outer hook) before each
|
735
|
-
\- (outer hook) before each, again
|
736
|
-
\- inner test 2:
|
737
|
-
\- goodbye world
|
738
|
-
\- (outer hook) after each
|
739
|
-
\- (outer hook) after each, again
|
740
|
-
\- (outer hook) after all
|
741
|
-
\-\-\-
|
742
|
-
time: 0\&.007706195
|
743
|
-
.fi
|
744
|
-
.if n \{\
|
745
|
-
.RE
|
746
|
-
.\}
|
747
|
-
.SH "ASSERTIONS"
|
748
|
-
.SS "Writing assertions"
|
749
|
-
.sp
|
750
|
-
The following methods accept a block parameter and assert something about the result of executing that block\&. They also accept an optional message, which is shown in their failure reports if they fail\&.
|
751
|
-
.TS
|
752
|
-
tab(:);
|
753
|
-
lt lt
|
754
|
-
lt lt
|
755
|
-
lt lt
|
756
|
-
lt lt
|
757
|
-
lt lt.
|
758
|
-
T{
|
759
|
-
.sp
|
760
|
-
T()
|
761
|
-
T}:T{
|
762
|
-
.sp
|
763
|
-
assert true (not nil and not false)
|
764
|
-
T}
|
765
|
-
T{
|
766
|
-
.sp
|
767
|
-
F()
|
768
|
-
T}:T{
|
769
|
-
.sp
|
770
|
-
assert not true (nil or false)
|
771
|
-
T}
|
772
|
-
T{
|
773
|
-
.sp
|
774
|
-
N()
|
775
|
-
T}:T{
|
776
|
-
.sp
|
777
|
-
assert that the value is nil
|
778
|
-
T}
|
779
|
-
T{
|
780
|
-
.sp
|
781
|
-
E()
|
782
|
-
T}:T{
|
783
|
-
.sp
|
784
|
-
assert that an execption is raised
|
785
|
-
T}
|
786
|
-
T{
|
787
|
-
.sp
|
788
|
-
C()
|
789
|
-
T}:T{
|
790
|
-
.sp
|
791
|
-
assert that a symbol is thrown
|
792
|
-
T}
|
793
|
-
.TE
|
794
|
-
.sp 1
|
795
|
-
.sp
|
796
|
-
For the T() and F() methods, you may alternatively pass the condition to be asserted as the first argument (instead of passing it as a block)\&. This might result in a more pleasing syntax, depending on your taste:
|
797
|
-
.sp
|
798
|
-
.if n \{\
|
799
|
-
.RS 4
|
800
|
-
.\}
|
801
|
-
.nf
|
802
|
-
D "Lottery" do
|
803
|
-
winning_ticket = rand()
|
804
|
-
|
805
|
-
D "My chances of winning" do
|
806
|
-
my_ticket = rand()
|
807
|
-
|
808
|
-
#
|
809
|
-
# Option 1: passing the condition as a block:
|
810
|
-
#
|
811
|
-
F("I won?! Dream on\&.") { my_ticket == winning_ticket }
|
812
|
-
|
813
|
-
#
|
814
|
-
# Option 2: passing the condition as an argument:
|
815
|
-
#
|
816
|
-
F my_ticket == winning_ticket, "I won?! Dream on\&."
|
817
|
-
|
818
|
-
end
|
819
|
-
end
|
839
|
+
\-\-\-
|
840
|
+
time: 0\&.002930334
|
820
841
|
.fi
|
821
842
|
.if n \{\
|
822
843
|
.RE
|
823
844
|
.\}
|
824
|
-
.SS "
|
825
|
-
.sp
|
826
|
-
The following methods are the \fIopposite\fR of normal assertions\&.
|
827
|
-
.TS
|
828
|
-
tab(:);
|
829
|
-
lt lt
|
830
|
-
lt lt
|
831
|
-
lt lt
|
832
|
-
lt lt
|
833
|
-
lt lt.
|
834
|
-
T{
|
835
|
-
.sp
|
836
|
-
T!()
|
837
|
-
T}:T{
|
838
|
-
.sp
|
839
|
-
same as F()
|
840
|
-
T}
|
841
|
-
T{
|
842
|
-
.sp
|
843
|
-
F!()
|
844
|
-
T}:T{
|
845
|
-
.sp
|
846
|
-
same as T()
|
847
|
-
T}
|
848
|
-
T{
|
849
|
-
.sp
|
850
|
-
N!()
|
851
|
-
T}:T{
|
852
|
-
.sp
|
853
|
-
assert that value is not nil
|
854
|
-
T}
|
855
|
-
T{
|
856
|
-
.sp
|
857
|
-
E!()
|
858
|
-
T}:T{
|
859
|
-
.sp
|
860
|
-
assert that an exception is \fInot\fR raised
|
861
|
-
T}
|
862
|
-
T{
|
863
|
-
.sp
|
864
|
-
C!()
|
865
|
-
T}:T{
|
866
|
-
.sp
|
867
|
-
assert that a symbol is \fInot\fR thrown
|
868
|
-
T}
|
869
|
-
.TE
|
870
|
-
.sp 1
|
871
|
-
.SS "Sampling assertions"
|
845
|
+
.SS "Execution hooks"
|
872
846
|
.sp
|
873
|
-
|
847
|
+
A \fBhook\fR is a scheduled point of entry into the test execution process\&. The following \fBhook methods\fR allow you to register a block of code to execute when a hook occurs:
|
874
848
|
.TS
|
875
849
|
tab(:);
|
876
850
|
lt lt
|
877
851
|
lt lt
|
878
852
|
lt lt
|
879
|
-
lt lt
|
880
853
|
lt lt.
|
881
854
|
T{
|
882
855
|
.sp
|
883
|
-
|
884
|
-
T}:T{
|
885
|
-
.sp
|
886
|
-
returns true if T() passes; false otherwise
|
887
|
-
T}
|
888
|
-
T{
|
889
|
-
.sp
|
890
|
-
F?()
|
856
|
+
D\&.<()
|
891
857
|
T}:T{
|
892
858
|
.sp
|
893
|
-
|
859
|
+
calls the given block \fIbefore each\fR child test \(em API documentation
|
894
860
|
T}
|
895
861
|
T{
|
896
862
|
.sp
|
897
|
-
|
863
|
+
D\&.>()
|
898
864
|
T}:T{
|
899
865
|
.sp
|
900
|
-
|
866
|
+
calls the given block \fIafter each\fR child test \(em API documentation
|
901
867
|
T}
|
902
868
|
T{
|
903
869
|
.sp
|
904
|
-
|
870
|
+
D\&.<<()
|
905
871
|
T}:T{
|
906
872
|
.sp
|
907
|
-
|
873
|
+
calls the given block \fIbefore all\fR child tests \(em API documentation
|
908
874
|
T}
|
909
875
|
T{
|
910
876
|
.sp
|
911
|
-
|
877
|
+
D\&.>>()
|
912
878
|
T}:T{
|
913
879
|
.sp
|
914
|
-
|
880
|
+
calls the given block \fIafter all\fR child tests \(em API documentation
|
915
881
|
T}
|
916
882
|
.TE
|
917
883
|
.sp 1
|
918
|
-
.SS "Assertion failure reports"
|
919
884
|
.sp
|
920
|
-
|
885
|
+
A hook method can be called multiple times\&. Each additional call schedules more logic to be executed during the hook:
|
921
886
|
.sp
|
922
887
|
.if n \{\
|
923
888
|
.RS 4
|
924
889
|
.\}
|
925
890
|
.nf
|
926
|
-
|
927
|
-
|
928
|
-
\- test/simple\&.rb:17
|
929
|
-
\- test/simple\&.rb:3
|
930
|
-
code: |\-
|
931
|
-
[12\&.\&.22] in test/simple\&.rb
|
932
|
-
12
|
933
|
-
13 D "with more nested tests" do
|
934
|
-
14 x = 5
|
935
|
-
15
|
936
|
-
16 T { x > 2 } # passes
|
937
|
-
=> 17 F { x > 2 } # fails
|
938
|
-
18 E { x\&.hello } # passes
|
939
|
-
19 end
|
940
|
-
20 end
|
941
|
-
21
|
942
|
-
22 # equivalent of before(:each) or setup()
|
943
|
-
bind: test/simple\&.rb:17
|
944
|
-
vars:
|
945
|
-
x: (Fixnum) 5
|
946
|
-
y: (Fixnum) 83
|
891
|
+
D \&.< { puts "do something" }
|
892
|
+
D \&.< { puts "do something more!" }
|
947
893
|
.fi
|
948
894
|
.if n \{\
|
949
895
|
.RE
|
950
896
|
.\}
|
897
|
+
.PP
|
898
|
+
\fBExample\ \&4.\ \&Using hooks to perform before and after actions\fR
|
951
899
|
.sp
|
952
|
-
|
953
|
-
.TS
|
954
|
-
tab(:);
|
955
|
-
lt lt
|
956
|
-
lt lt
|
957
|
-
lt lt
|
958
|
-
lt lt
|
959
|
-
lt lt.
|
960
|
-
T{
|
961
|
-
.sp
|
962
|
-
:fail
|
963
|
-
T}:T{
|
964
|
-
.sp
|
965
|
-
Description of the assertion failure\&.
|
966
|
-
T}
|
967
|
-
T{
|
968
|
-
.sp
|
969
|
-
:call
|
970
|
-
T}:T{
|
971
|
-
.sp
|
972
|
-
Stack trace leading to the point of failure\&.
|
973
|
-
T}
|
974
|
-
T{
|
975
|
-
.sp
|
976
|
-
:code
|
977
|
-
T}:T{
|
978
|
-
.sp
|
979
|
-
Source code surrounding the point of failure\&.
|
980
|
-
T}
|
981
|
-
T{
|
982
|
-
.sp
|
983
|
-
:bind
|
984
|
-
T}:T{
|
985
|
-
.sp
|
986
|
-
Source location of values in :vars section\&.
|
987
|
-
T}
|
988
|
-
T{
|
989
|
-
.sp
|
990
|
-
:vars
|
991
|
-
T}:T{
|
900
|
+
When the following test is run:
|
992
901
|
.sp
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
.
|
902
|
+
.if n \{\
|
903
|
+
.RS 4
|
904
|
+
.\}
|
905
|
+
.nf
|
906
|
+
require \'detest/auto\'
|
907
|
+
|
908
|
+
D "outer test" do
|
909
|
+
D \&.< { I "(outer hook) before each" }
|
910
|
+
D \&.> { I "(outer hook) after each" }
|
911
|
+
D \&.<< { I "(outer hook) before all" }
|
912
|
+
D \&.>> { I "(outer hook) after all" }
|
913
|
+
|
914
|
+
D "inner test 1" do
|
915
|
+
D \&.< { I "(inner hook) before each" }
|
916
|
+
D \&.> { I "(inner hook) after each" }
|
917
|
+
D \&.<< { I "(inner hook) before all" }
|
918
|
+
D \&.>> { I "(inner hook) after all" }
|
919
|
+
|
920
|
+
D "inner test 1\&.1" do
|
921
|
+
I "hello world"
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
925
|
+
D "inner test 2" do
|
926
|
+
I "goodbye world"
|
927
|
+
end
|
928
|
+
|
929
|
+
D \&.< { I "(outer hook) before each, again" }
|
930
|
+
D \&.> { I "(outer hook) after each, again" }
|
931
|
+
end
|
932
|
+
.fi
|
933
|
+
.if n \{\
|
934
|
+
.RE
|
935
|
+
.\}
|
997
936
|
.sp
|
998
|
-
|
937
|
+
Detest will output the following:
|
999
938
|
.sp
|
1000
|
-
|
939
|
+
.if n \{\
|
940
|
+
.RS 4
|
941
|
+
.\}
|
942
|
+
.nf
|
943
|
+
\-\-\-
|
944
|
+
\- outer test:
|
945
|
+
\- (outer hook) before all
|
946
|
+
\- (outer hook) before each
|
947
|
+
\- (outer hook) before each, again
|
948
|
+
\- inner test 1:
|
949
|
+
\- (inner hook) before all
|
950
|
+
\- (inner hook) before each
|
951
|
+
\- inner test 1\&.1:
|
952
|
+
\- hello world
|
953
|
+
\- (inner hook) after each
|
954
|
+
\- (inner hook) after all
|
955
|
+
\- (outer hook) after each
|
956
|
+
\- (outer hook) after each, again
|
957
|
+
\- (outer hook) before each
|
958
|
+
\- (outer hook) before each, again
|
959
|
+
\- inner test 2:
|
960
|
+
\- goodbye world
|
961
|
+
\- (outer hook) after each
|
962
|
+
\- (outer hook) after each, again
|
963
|
+
\- (outer hook) after all
|
964
|
+
\-\-\-
|
965
|
+
time: 0\&.009311863
|
966
|
+
.fi
|
967
|
+
.if n \{\
|
968
|
+
.RE
|
969
|
+
.\}
|
1001
970
|
.SH "EMULATION"
|
1002
971
|
.sp
|
1003
972
|
Detest can emulate several popular testing libraries:
|
@@ -1819,6 +1788,68 @@ Its exit status will indicate whether all tests have passed\&. It may also print
|
|
1819
1788
|
.sp
|
1820
1789
|
Fork this project on GitHub and send a pull request\&.
|
1821
1790
|
.SH "HISTORY"
|
1791
|
+
.SS "Version 3\&.1\&.2 (2010\-08\-10)"
|
1792
|
+
.sp
|
1793
|
+
This release adds links to API documentation beside methods mentioned in the help manual and restores metadata that was missing in the gem release package\&.
|
1794
|
+
.PP
|
1795
|
+
\fBHousekeeping\fR
|
1796
|
+
.sp
|
1797
|
+
.RS 4
|
1798
|
+
.ie n \{\
|
1799
|
+
\h'-04'\(bu\h'+03'\c
|
1800
|
+
.\}
|
1801
|
+
.el \{\
|
1802
|
+
.sp -1
|
1803
|
+
.IP \(bu 2.3
|
1804
|
+
.\}
|
1805
|
+
Upgrade to Inochi 5\&.0\&.1 to fix metadata generation in gemspec\&.
|
1806
|
+
.RE
|
1807
|
+
.sp
|
1808
|
+
.RS 4
|
1809
|
+
.ie n \{\
|
1810
|
+
\h'-04'\(bu\h'+03'\c
|
1811
|
+
.\}
|
1812
|
+
.el \{\
|
1813
|
+
.sp -1
|
1814
|
+
.IP \(bu 2.3
|
1815
|
+
.\}
|
1816
|
+
Introduce assertions before tests in help manual\&.
|
1817
|
+
.RE
|
1818
|
+
.sp
|
1819
|
+
.RS 4
|
1820
|
+
.ie n \{\
|
1821
|
+
\h'-04'\(bu\h'+03'\c
|
1822
|
+
.\}
|
1823
|
+
.el \{\
|
1824
|
+
.sp -1
|
1825
|
+
.IP \(bu 2.3
|
1826
|
+
.\}
|
1827
|
+
Make use of AsciiDoc admonitions and icon images\&.
|
1828
|
+
.RE
|
1829
|
+
.sp
|
1830
|
+
.RS 4
|
1831
|
+
.ie n \{\
|
1832
|
+
\h'-04'\(bu\h'+03'\c
|
1833
|
+
.\}
|
1834
|
+
.el \{\
|
1835
|
+
.sp -1
|
1836
|
+
.IP \(bu 2.3
|
1837
|
+
.\}
|
1838
|
+
Add links into API documentation for core methods\&.
|
1839
|
+
.RE
|
1840
|
+
.sp
|
1841
|
+
.RS 4
|
1842
|
+
.ie n \{\
|
1843
|
+
\h'-04'\(bu\h'+03'\c
|
1844
|
+
.\}
|
1845
|
+
.el \{\
|
1846
|
+
.sp -1
|
1847
|
+
.IP \(bu 2.3
|
1848
|
+
.\}
|
1849
|
+
Add test case to ensure that
|
1850
|
+
E()
|
1851
|
+
returns the exception that was raised\&.
|
1852
|
+
.RE
|
1822
1853
|
.SS "Version 3\&.1\&.1 (2010\-08\-08)"
|
1823
1854
|
.sp
|
1824
1855
|
This release adds forgotten nil assertions and updates the help manual\&.
|
metadata
CHANGED
@@ -5,16 +5,16 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 3
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 3.1.
|
8
|
+
- 2
|
9
|
+
version: 3.1.2
|
10
10
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
|
11
|
+
authors:
|
12
|
+
- Suraj N. Kurapati
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-10 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 5
|
30
30
|
- 0
|
31
|
-
-
|
32
|
-
version: 5.0.
|
31
|
+
- 1
|
32
|
+
version: 5.0.1
|
33
33
|
- - <
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
segments:
|
@@ -37,7 +37,7 @@ dependencies:
|
|
37
37
|
version: "6"
|
38
38
|
type: :development
|
39
39
|
version_requirements: *id001
|
40
|
-
description:
|
40
|
+
description: Detest is an assertion testing library for the Ruby programming language. It features a simple assertion vocabulary, instant debuggability
|
41
41
|
of failures, and flexibility in composing tests.
|
42
42
|
email:
|
43
43
|
executables:
|
44
44
|
- detest
|