assay 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +7 -0
  3. data/HISTORY.md +128 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +287 -0
  6. data/demo/ae/01_overview.md +98 -0
  7. data/demo/ae/03_assert.md +398 -0
  8. data/demo/ae/04_subjunctive.md +100 -0
  9. data/demo/ae/05_expect.md +136 -0
  10. data/demo/ae/06_counts.md +33 -0
  11. data/demo/ae/07_matchers.md +34 -0
  12. data/demo/ae/08_check.md +61 -0
  13. data/demo/ae/09_assay.md +124 -0
  14. data/demo/ae/applique/setup.rb +11 -0
  15. data/{test → demo/applique}/helper.rb +8 -2
  16. data/demo/applique/setup.rb +1 -0
  17. data/demo/bang/01_bang.md +220 -0
  18. data/demo/core/00_introduction.md +2 -0
  19. data/demo/core/01_assay_classes/00_introduction.md +2 -0
  20. data/demo/core/01_assay_classes/01_nil_assay.md +35 -0
  21. data/demo/core/01_assay_classes/02_boolean_assay.md +35 -0
  22. data/demo/core/01_assay_classes/03_false_assay.md +19 -0
  23. data/demo/core/01_assay_classes/03_true_assay.md +20 -0
  24. data/demo/core/01_assay_classes/04_like_assay.md +19 -0
  25. data/demo/core/01_assay_classes/05_equal_assay.md +19 -0
  26. data/demo/core/01_assay_classes/06_unequal_assay.md +35 -0
  27. data/demo/core/01_assay_classes/07_equality_assay.md +19 -0
  28. data/demo/core/01_assay_classes/08_identity_assay.md +24 -0
  29. data/demo/core/01_assay_classes/09_case_assay.md +22 -0
  30. data/demo/core/01_assay_classes/10_match_assay.md +15 -0
  31. data/demo/core/01_assay_classes/11_nomatch_assay.md +16 -0
  32. data/demo/core/01_assay_classes/12_compare_assay.md +24 -0
  33. data/demo/core/01_assay_classes/13_less_assay.md +29 -0
  34. data/demo/core/01_assay_classes/14_more_assay.md +29 -0
  35. data/demo/core/01_assay_classes/15_less_equal_assay.md +30 -0
  36. data/demo/core/01_assay_classes/16_more_equal_assay.md +29 -0
  37. data/demo/core/01_assay_classes/17_close_assay.md +42 -0
  38. data/demo/core/01_assay_classes/17_within_assay.md +42 -0
  39. data/demo/core/01_assay_classes/18_kind_assay.md +17 -0
  40. data/demo/core/01_assay_classes/19_instance_assay.md +16 -0
  41. data/demo/core/01_assay_classes/20_include_assay.md +17 -0
  42. data/demo/core/01_assay_classes/21_empty_assay.md +15 -0
  43. data/demo/core/01_assay_classes/22_respond_assay.md +15 -0
  44. data/demo/core/01_assay_classes/23_execution_assay.md +40 -0
  45. data/demo/core/01_assay_classes/23_return_assay.md +37 -0
  46. data/demo/core/01_assay_classes/24_rescue_assay.md +40 -0
  47. data/demo/core/01_assay_classes/25_raise_assay.md +40 -0
  48. data/demo/core/01_assay_classes/26_throw_assay.md +47 -0
  49. data/demo/core/01_assay_classes/27_path_assay.md +20 -0
  50. data/demo/core/01_assay_classes/28_directory_assay.md +21 -0
  51. data/demo/core/01_assay_classes/29_file_assay.md +20 -0
  52. data/demo/core/01_assay_classes/30_output_assay.md +39 -0
  53. data/demo/core/01_assay_classes/31_stdout_assay.md +21 -0
  54. data/demo/core/01_assay_classes/32_stderr_assay.md +21 -0
  55. data/demo/core/02_lookup.md +25 -0
  56. data/demo/core/03_assertor.md +117 -0
  57. data/demo/core/04_assay.md +40 -0
  58. data/demo/fluidity/00_intro.md +7 -0
  59. data/demo/fluidity/01_should.md +52 -0
  60. data/demo/fluidity/02_must.md +58 -0
  61. data/demo/fluidity/03_assert.md +71 -0
  62. data/demo/fluidity/04_other.md +35 -0
  63. data/demo/fluidity/05_object_methods.md +102 -0
  64. data/demo/minitest/01_minitest_extensions.rdoc +217 -0
  65. data/demo/minitest/02_minitest_assertions.rdoc +250 -0
  66. data/demo/rspec/00_introduction.md +16 -0
  67. data/demo/rspec/01_should.md +24 -0
  68. data/demo/rspec/02_matchers.md +176 -0
  69. data/demo/rspec/03_have.md +51 -0
  70. data/demo/rspec/04_expect.md +49 -0
  71. data/demo/rspec/applique/setup.rb +2 -0
  72. data/demo/testunit/01_testunit_assertions.md +266 -0
  73. data/lib/assay/adapter/minitest.rb +32 -21
  74. data/lib/assay/adapter/testunit.rb +31 -38
  75. data/lib/assay/ae/assert.rb +77 -0
  76. data/lib/assay/ae/assertor.rb +453 -0
  77. data/lib/assay/ae/check.rb +154 -0
  78. data/lib/assay/ae/core_ext.rb +146 -0
  79. data/lib/assay/ae/expect.rb +72 -0
  80. data/lib/assay/ae/must.rb +64 -0
  81. data/lib/assay/ae/should.rb +58 -0
  82. data/lib/assay/ae/subjunctive.rb +66 -0
  83. data/lib/assay/ae.rb +29 -0
  84. data/lib/assay/assertable.rb +21 -5
  85. data/lib/assay/assertor.rb +4 -4
  86. data/lib/assay/bang.rb +147 -0
  87. data/lib/assay/close_assay.rb +2 -2
  88. data/lib/assay/core_ext/kernel.rb +4 -8
  89. data/lib/assay/fluidity/assert.rb +27 -0
  90. data/lib/assay/fluidity/grammar.rb +157 -0
  91. data/lib/assay/fluidity/is.rb +18 -0
  92. data/lib/assay/fluidity/must.rb +38 -0
  93. data/lib/assay/fluidity/should.rb +32 -0
  94. data/lib/assay/fluidity/will.rb +36 -0
  95. data/lib/assay/fluidity.rb +6 -0
  96. data/lib/assay/less_assay.rb +7 -1
  97. data/lib/assay/less_equal_assay.rb +7 -1
  98. data/lib/assay/minitest/assertions.rb +495 -0
  99. data/lib/assay/minitest/extensions.rb +496 -0
  100. data/lib/assay/minitest.rb +24 -0
  101. data/lib/assay/more_assay.rb +7 -1
  102. data/lib/assay/more_equal_assay.rb +7 -1
  103. data/lib/assay/rspec/expect.rb +151 -0
  104. data/lib/assay/rspec/have.rb +201 -0
  105. data/lib/assay/rspec/matchers.rb +272 -0
  106. data/lib/assay/rspec/operatics.rb +60 -0
  107. data/lib/assay/rspec/should.rb +49 -0
  108. data/lib/assay/rspec.rb +13 -0
  109. data/lib/assay/testunit/assertions.rb +484 -0
  110. data/lib/assay/testunit.rb +9 -0
  111. data/lib/assay/version.rb +3 -0
  112. data/lib/assay.rb +7 -21
  113. metadata +211 -80
  114. data/.ruby +0 -51
  115. data/COPYING.rdoc +0 -38
  116. data/HISTORY.rdoc +0 -65
  117. data/QED.rdoc +0 -1143
  118. data/README.rdoc +0 -173
  119. data/lib/assay.yml +0 -51
  120. data/test/case_compare_assay.rb +0 -59
  121. data/test/case_empty_assay.rb +0 -51
  122. data/test/case_equal_assay.rb +0 -53
  123. data/test/case_equality_assay.rb +0 -55
  124. data/test/case_false_assay.rb +0 -48
  125. data/test/case_identity_assay.rb +0 -51
  126. data/test/case_include_assay.rb +0 -51
  127. data/test/case_instance_assay.rb +0 -51
  128. data/test/case_kind_assay.rb +0 -51
  129. data/test/case_less_assay.rb +0 -53
  130. data/test/case_less_equal_assay.rb +0 -53
  131. data/test/case_like_assay.rb +0 -57
  132. data/test/case_match_assay.rb +0 -45
  133. data/test/case_more_assay.rb +0 -53
  134. data/test/case_more_equal_assay.rb +0 -53
  135. data/test/case_nil_assay.rb +0 -48
  136. data/test/case_nomatch_assay.rb +0 -47
  137. data/test/case_raise_assay.rb +0 -51
  138. data/test/case_respond_assay.rb +0 -51
  139. data/test/case_throw_assay.rb +0 -51
  140. data/test/case_true_assay.rb +0 -48
  141. data/test/case_unequal_assay.rb +0 -55
  142. data/test/case_within_assay.rb +0 -61
@@ -0,0 +1,22 @@
1
+ ## CaseAssay
2
+
3
+ The `CaseAssay` class defines an assertion for case equality using the `#===`
4
+ method.
5
+
6
+ assert CaseAssay.pass?(1, 1)
7
+ assert CaseAssay.pass?(1, 1.0)
8
+ assert CaseAssay.pass?(/a/, 'a')
9
+ assert CaseAssay.pass?(String, 'foo')
10
+
11
+ refute CaseAssay.pass?(1, 2)
12
+ refute CaseAssay.pass?(1, 'foo')
13
+
14
+ And conversely,
15
+
16
+ assert CaseAssay.fail?(1, 2)
17
+ assert CaseAssay.fail?(1, 'foo')
18
+
19
+ refute CaseAssay.fail?(1, 1)
20
+ refute CaseAssay.fail?(1, 1.0)
21
+ refute CaseAssay.fail?(/a/, 'a')
22
+ refute CaseAssay.fail?(String, 'foo')
@@ -0,0 +1,15 @@
1
+ ## MatchAssay
2
+
3
+ The `MatchAssay` class defines an assertion for matching using the `#=~`
4
+ method.
5
+
6
+ assert MatchAssay.pass?('a', /a/)
7
+
8
+ refute MatchAssay.pass?('a', /b/)
9
+
10
+ And conversely,
11
+
12
+ assert MatchAssay.fail?('a', /b/)
13
+
14
+ refute MatchAssay.fail?('a', /a/)
15
+
@@ -0,0 +1,16 @@
1
+ ## NoMatchAssay
2
+
3
+ The `NoMatchAssay` class defines an assertion for matching using the `#!~`
4
+ method. As of Ruby 1.9, the `#!~` method is redefinable independent of `#=~`,
5
+ so a separate assertion class is needed to cover it.
6
+
7
+ assert NoMatchAssay.pass?('a', /b/)
8
+
9
+ refute NoMatchAssay.pass?('a', /a/)
10
+
11
+ And conversely,
12
+
13
+ assert NoMatchAssay.fail?('a', /a/)
14
+
15
+ refute NoMatchAssay.fail?('a', /b/)
16
+
@@ -0,0 +1,24 @@
1
+ ## CompareAssay
2
+
3
+ The `CompareAssay` class defines an assertion of comparison around the `#<=>`
4
+ method. Since `#<=>` can return either a `1`, `0` or `-1`, an extra criterion
5
+ is needed when making testing the assertion.
6
+
7
+ assert CompareAssay.pass?(1, 1, 0)
8
+ assert CompareAssay.pass?(1, 2, -1)
9
+ assert CompareAssay.pass?(2, 1, 1)
10
+
11
+ refute CompareAssay.pass?(1, 1, 1)
12
+ refute CompareAssay.pass?(1, 1, -1)
13
+
14
+ refute CompareAssay.pass?(1, 'foo', 0)
15
+
16
+ And conversely,
17
+
18
+ assert CompareAssay.fail?(1, 1, 1)
19
+ assert CompareAssay.fail?(1, 1, -1)
20
+
21
+ refute CompareAssay.fail?(1, 1, 0)
22
+ refute CompareAssay.fail?(1, 2, -1)
23
+ refute CompareAssay.fail?(2, 1, 1)
24
+
@@ -0,0 +1,29 @@
1
+ ## LessAssay
2
+
3
+ The `LessAssay` class defines an assertion of comparison around the `#<`
4
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
5
+ mixin, so `LessAssay` is a subclass of `ComapreAssay`, though techincally
6
+ the `#<` method can be defined independently.
7
+
8
+ assert LessAssay.pass?( 1, 2)
9
+ assert LessAssay.pass?(-1, 0)
10
+
11
+ refute LessAssay.pass?(1, 1)
12
+ refute LessAssay.pass?(1, 0)
13
+
14
+ And conversely,
15
+
16
+ assert LessAssay.fail?(1, 1)
17
+ assert LessAssay.fail?(1, 0)
18
+
19
+ refute LessAssay.fail?( 1, 2)
20
+ refute LessAssay.fail?(-1, 0)
21
+
22
+ This applies to any type of object that defines `#<=`, not just numbers.
23
+
24
+ assert LessAssay.pass?('a', 'b')
25
+ refute LessAssay.pass?('b', 'a')
26
+
27
+ assert LessAssay.fail?('b', 'a')
28
+ refute LessAssay.fail?('a', 'b')
29
+
@@ -0,0 +1,29 @@
1
+ ## MoreAssay
2
+
3
+ The `MoreAssay` class defines an assertion of comparison around the `#>`
4
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
5
+ mixin, so `MoreAssay` is a subclass of `ComapreAssay`, though techincally
6
+ the `#>` method can be defined indenpendently.
7
+
8
+ assert MoreAssay.pass?(2, 1)
9
+ assert MoreAssay.pass?(0, -1)
10
+ assert MoreAssay.pass?(1, 0)
11
+
12
+ refute MoreAssay.pass?(1, 1)
13
+ refute MoreAssay.pass?(1, 2)
14
+
15
+ And conversely,
16
+
17
+ assert MoreAssay.fail?(1, 1)
18
+ assert MoreAssay.fail?(0, 1)
19
+
20
+ refute MoreAssay.fail?(2, 1)
21
+ refute MoreAssay.fail?(0, -1)
22
+
23
+ This applies to any type of object that defines `#>`, not just numbers.
24
+
25
+ assert MoreAssay.pass?('b', 'a')
26
+ refute MoreAssay.pass?('a', 'b')
27
+
28
+ assert MoreAssay.fail?('a', 'b')
29
+ refute MoreAssay.fail?('b', 'a')
@@ -0,0 +1,30 @@
1
+ ## LessEqualAssay
2
+
3
+ The `LessEqualAssay` class defines an assertion of comparison around the `#<=`
4
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
5
+ mixin, so `LessEqualAssay` is a subclass of `ComapreAssay`, though techincally
6
+ the `#<=` method can be defined indenpendently.
7
+
8
+ assert LessEqualAssay.pass?( 1, 2)
9
+ assert LessEqualAssay.pass?(-1, 0)
10
+ assert LessEqualAssay.pass?( 1, 1)
11
+
12
+ refute LessEqualAssay.pass?(1, 0)
13
+
14
+ And conversely,
15
+
16
+ assert LessEqualAssay.fail?(1, 0)
17
+
18
+ refute LessEqualAssay.fail?( 1, 1)
19
+ refute LessEqualAssay.fail?( 1, 2)
20
+ refute LessEqualAssay.fail?(-1, 0)
21
+
22
+ This applies to any type of object that defines `#<=`, not just numbers.
23
+
24
+ assert LessEqualAssay.pass?('a', 'b')
25
+ refute LessEqualAssay.pass?('b', 'a')
26
+
27
+ assert LessEqualAssay.fail?('b', 'a')
28
+ refute LessEqualAssay.fail?('a', 'b')
29
+
30
+
@@ -0,0 +1,29 @@
1
+ ## MoreEqualAssay
2
+
3
+ The `MoreEqualAssay` class defines an assertion of comparison around the `#>=`
4
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
5
+ mixin, so `MoreEqualAssay` is a subclass of `ComapreAssay`, though techincally
6
+ the `#>=` method can be defined indenpendently.
7
+
8
+ assert MoreEqualAssay.pass?(2, 1)
9
+ assert MoreEqualAssay.pass?(0, -1)
10
+ assert MoreEqualAssay.pass?(1, 1)
11
+
12
+ refute MoreEqualAssay.pass?(0, 1)
13
+
14
+ And conversely,
15
+
16
+ assert MoreEqualAssay.fail?(0, 1)
17
+
18
+ refute MoreEqualAssay.fail?( 1, 1)
19
+ refute MoreEqualAssay.fail?( 2, 1)
20
+ refute MoreEqualAssay.fail?( 0, -1)
21
+
22
+ This applies to any type of object that defines `#<=`, not just numbers.
23
+
24
+ assert MoreEqualAssay.pass?('b', 'a')
25
+ refute MoreEqualAssay.pass?('a', 'b')
26
+
27
+ assert MoreEqualAssay.fail?('a', 'b')
28
+ refute MoreEqualAssay.fail?('b', 'a')
29
+
@@ -0,0 +1,42 @@
1
+ ## CloseAssay
2
+
3
+ The `CloseAssay` class defines an assertion for matching that two values
4
+ are within a relative difference.
5
+
6
+ assert CloseAssay.pass?(1, 1, 0)
7
+ assert CloseAssay.pass?(1, 1.1, 0.1)
8
+
9
+ refute CloseAssay.pass?(1, 2, 0)
10
+ refute CloseAssay.pass?(1, 1.2, 0.1)
11
+
12
+ And conversely,
13
+
14
+ assert CloseAssay.fail?(1, 2, 0)
15
+ assert CloseAssay.fail?(1, 1.2, 0.1)
16
+
17
+ refute CloseAssay.fail?(1, 1, 0)
18
+ refute CloseAssay.fail?(1, 1.1, 0.1)
19
+
20
+ The object do not have to be numbers necessaity, just so long as they
21
+ are comparable and subtractable.
22
+
23
+ time = Time.now
24
+
25
+ assert CloseAssay.pass?(time, time+1, 2)
26
+
27
+ Making assertions,
28
+
29
+ assert CloseAssay.assert!(10, 11, 1)
30
+
31
+ expect ::CloseAssay do
32
+ CloseAssay.assert!(10, 15, 0.25)
33
+ end
34
+
35
+ And refutations,
36
+
37
+ assert CloseAssay.refute!(10, 11, 0.01)
38
+
39
+ expect ::CloseAssay do
40
+ CloseAssay.refute!(10, 11, 1)
41
+ end
42
+
@@ -0,0 +1,42 @@
1
+ ## WithinAssay
2
+
3
+ The `WithinAssay` class defines an assertion for matching that two values
4
+ lie with a range.
5
+
6
+ assert WithinAssay.pass?(1, 1, 0)
7
+ assert WithinAssay.pass?(1, 1.1, 0.1)
8
+
9
+ refute WithinAssay.pass?(1, 2, 0)
10
+ refute WithinAssay.pass?(1, 1.2, 0.1)
11
+
12
+ And conversely,
13
+
14
+ assert WithinAssay.fail?(1, 2, 0)
15
+ assert WithinAssay.fail?(1, 1.2, 0.1)
16
+
17
+ refute WithinAssay.fail?(1, 1, 0)
18
+ refute WithinAssay.fail?(1, 1.1, 0.1)
19
+
20
+ The object do not have to be numbers necessaity, just so long as they
21
+ are comparable and subtractable.
22
+
23
+ time = Time.now
24
+
25
+ assert WithinAssay.pass?(time, time+1, 2)
26
+
27
+ Making assertions,
28
+
29
+ assert WithinAssay.assert!(10, 11, 1)
30
+
31
+ expect ::WithinAssay do
32
+ WithinAssay.assert!(10, 15, 2)
33
+ end
34
+
35
+ And refutations,
36
+
37
+ assert WithinAssay.refute!(10, 11, 0.1)
38
+
39
+ expect ::WithinAssay do
40
+ WithinAssay.refute!(10, 11, 1)
41
+ end
42
+
@@ -0,0 +1,17 @@
1
+ ## KindAssay
2
+
3
+ The `KindAssay` asserts that an object is a class or any ancestor
4
+ of that class.
5
+
6
+ assert KindAssay.pass?(1, Integer)
7
+ assert KindAssay.pass?(1, Numeric)
8
+
9
+ refute KindAssay.pass?(1, String)
10
+
11
+ And conversely,
12
+
13
+ assert KindAssay.fail?(1, String)
14
+
15
+ refute KindAssay.fail?(1, Integer)
16
+ refute KindAssay.fail?(1, Numeric)
17
+
@@ -0,0 +1,16 @@
1
+ ## InstanceAssay
2
+
3
+ The `InstanceAssay` asserts that an object is an instance of a specific class.
4
+
5
+ assert InstanceAssay.pass?(1, Integer)
6
+
7
+ refute InstanceAssay.pass?(1, Numeric)
8
+ refute InstanceAssay.pass?(1, String)
9
+
10
+ And conversely,
11
+
12
+ assert InstanceAssay.fail?(1, String)
13
+ assert InstanceAssay.fail?(1, Numeric)
14
+
15
+ refute InstanceAssay.fail?(1, Integer)
16
+
@@ -0,0 +1,17 @@
1
+ ## IncludeAssay
2
+
3
+ The `IncludeAssay` asserts that a collection includes a specific member, using
4
+ the `#include?` method.
5
+
6
+ assert IncludeAssay.pass?([1], 1)
7
+
8
+ refute IncludeAssay.pass?([], 1)
9
+ refute IncludeAssay.pass?([2], 1)
10
+
11
+ And conversely,
12
+
13
+ assert IncludeAssay.fail?([], 1)
14
+ assert IncludeAssay.fail?([2], 1)
15
+
16
+ refute IncludeAssay.fail?([1], 1)
17
+
@@ -0,0 +1,15 @@
1
+ ## EmptyAssay
2
+
3
+ The `EmptyAssay` asserts that a collection includes no members, using the
4
+ `#empty?` method.
5
+
6
+ assert EmptyAssay.pass?([])
7
+
8
+ refute EmptyAssay.pass?([1])
9
+
10
+ And conversely,
11
+
12
+ assert EmptyAssay.fail?([1])
13
+
14
+ refute EmptyAssay.fail?([])
15
+
@@ -0,0 +1,15 @@
1
+ ## RespondAssay
2
+
3
+ The `RespondAssay` asserts if a an object responds to a message using
4
+ then `#respond_to?` method.
5
+
6
+ assert RespondAssay.pass?('a', :to_s)
7
+
8
+ refute RespondAssay.pass?('a', :foo)
9
+
10
+ And conversely,
11
+
12
+ assert RespondAssay.fail?('a', :foo)
13
+
14
+ refute RespondAssay.fail?('a', :to_s)
15
+
@@ -0,0 +1,40 @@
1
+ ## ExecutionAssay
2
+
3
+ The `ExecutionAssay` asserts that a procedure runs without error and returns
4
+ a result other than `false` or `nil`. It is not particularly useful, because
5
+ what it does is effectively what testing in itself does. So it is rather
6
+ redundant. However, it serves as the base class for the more specific
7
+ `ReturnAssay`.
8
+
9
+ assert ExecutionAssay.pass?{ true }
10
+ assert ExecutionAssay.pass?{ :foo }
11
+
12
+ refute ExecutionAssay.pass?{ nil }
13
+ refute ExecutionAssay.pass?{ false }
14
+ refute ExecutionAssay.pass?{ raise }
15
+
16
+ And conversely,
17
+
18
+ assert ExecutionAssay.fail?{ raise }
19
+ assert ExecutionAssay.fail?{ nil }
20
+ assert ExecutionAssay.fail?{ false }
21
+
22
+ refute ExecutionAssay.fail?{ true }
23
+ refute ExecutionAssay.fail?{ :foo }
24
+
25
+ Making assertions,
26
+
27
+ assert ExecutionAssay.assert!{ true }
28
+
29
+ expect ::ExecutionAssay do
30
+ assert ExecutionAssay.assert!{ false }
31
+ end
32
+
33
+ And refutations,
34
+
35
+ assert ExecutionAssay.refute!{ false }
36
+
37
+ expect ::ExecutionAssay do
38
+ assert ExecutionAssay.refute!{ true }
39
+ end
40
+
@@ -0,0 +1,37 @@
1
+ ## ReturnAssay
2
+
3
+ The `ReturnAssay` asserts that a procedure runs without error and returns
4
+ a specified result.
5
+
6
+ assert ReturnAssay.pass?(:foo){ :foo }
7
+ assert ReturnAssay.pass?(true){ true }
8
+
9
+ refute ReturnAssay.pass?(:foo){ :bar }
10
+ refute ReturnAssay.pass?(:foo){ true }
11
+ refute ReturnAssay.pass?(:foo){ raise }
12
+
13
+ And conversely,
14
+
15
+ assert ReturnAssay.fail?(:foo){ :bar }
16
+ assert ReturnAssay.fail?(:foo){ true }
17
+ assert ReturnAssay.fail?(:foo){ raise }
18
+
19
+ refute ReturnAssay.fail?(:foo){ :foo }
20
+ refute ReturnAssay.fail?(true){ true }
21
+
22
+ Making assertions,
23
+
24
+ assert ReturnAssay.assert!(true){ true }
25
+
26
+ expect ::ReturnAssay do
27
+ assert ReturnAssay.assert!(:foo){ :bar }
28
+ end
29
+
30
+ And refutations,
31
+
32
+ assert ReturnAssay.refute!(:foo){ :bar }
33
+
34
+ expect ::ReturnAssay do
35
+ assert ReturnAssay.refute!(:foo){ :foo }
36
+ end
37
+
@@ -0,0 +1,40 @@
1
+ ## RescueAssay
2
+
3
+ The `RescueAssay` asserts that a procedure will raise a specific error.
4
+
5
+ assert RescueAssay.pass?{ raise }
6
+ assert RescueAssay.pass?(RuntimeError){ raise }
7
+ assert RescueAssay.pass?(ArgumentError){ raise ArgumentError }
8
+ assert RescueAssay.pass?(Exception){ raise ArgumentError }
9
+
10
+ refute RescueAssay.pass?{ raise Exception }
11
+ refute RescueAssay.pass?(RuntimeError){ nil }
12
+ refute RescueAssay.pass?(ArgumentError){ raise }
13
+
14
+ And conversely,
15
+
16
+ assert RescueAssay.fail?{ raise Exception }
17
+ assert RescueAssay.fail?(RuntimeError){ nil }
18
+ assert RescueAssay.fail?(ArgumentError){ raise }
19
+
20
+ refute RescueAssay.fail?{ raise }
21
+ refute RescueAssay.fail?(RuntimeError){ raise }
22
+ refute RescueAssay.fail?(ArgumentError){ raise ArgumentError }
23
+ refute RescueAssay.fail?(Exception){ raise ArgumentError }
24
+
25
+ Making assertions,
26
+
27
+ assert RescueAssay.assert!(RuntimeError){ raise }
28
+
29
+ expect ::RescueAssay do
30
+ RaiseAssay.assert!(RuntimeError){ nil }
31
+ end
32
+
33
+ And refutations,
34
+
35
+ assert RescueAssay.refute!(RuntimeError){ nil }
36
+
37
+ expect ::RescueAssay do
38
+ RaiseAssay.refute!(RuntimeError){ raise }
39
+ end
40
+
@@ -0,0 +1,40 @@
1
+ ## RaiseAssay
2
+
3
+ The `RaiseAssay` asserts that a procedure will raise a specific error.
4
+
5
+ assert RaiseAssay.pass?{ raise }
6
+ assert RaiseAssay.pass?(RuntimeError){ raise }
7
+ assert RaiseAssay.pass?(ArgumentError){ raise ArgumentError }
8
+
9
+ refute RaiseAssay.pass?{ raise Exception }
10
+ refute RaiseAssay.pass?(Exception){ raise ArgumentError }
11
+ refute RaiseAssay.pass?(StandardError){ nil }
12
+ refute RaiseAssay.pass?(ArgumentError){ raise }
13
+
14
+ And conversely,
15
+
16
+ assert RaiseAssay.fail?{ raise Exception }
17
+ assert RaiseAssay.fail?(RuntimeError){ nil }
18
+ assert RaiseAssay.fail?(ArgumentError){ raise }
19
+ assert RaiseAssay.fail?(Exception){ raise ArgumentError }
20
+
21
+ refute RaiseAssay.fail?{ raise }
22
+ refute RaiseAssay.fail?(RuntimeError){ raise }
23
+ refute RaiseAssay.fail?(ArgumentError){ raise ArgumentError }
24
+
25
+ Making assertions,
26
+
27
+ assert RaiseAssay.assert!(RuntimeError){ raise }
28
+
29
+ expect ::RaiseAssay do
30
+ RaiseAssay.assert!(RuntimeError){ nil }
31
+ end
32
+
33
+ And refutations,
34
+
35
+ assert RaiseAssay.refute!(RuntimeError){ nil }
36
+
37
+ expect ::RaiseAssay do
38
+ RaiseAssay.refute!(RuntimeError){ raise }
39
+ end
40
+
@@ -0,0 +1,47 @@
1
+ ## ThrowAssay
2
+
3
+ The `ThrowAssay` asserts that a procedure will call `throw` and optionally
4
+ of a specific type.
5
+
6
+ assert ThrowAssay.pass?(:foo){ throw :foo }
7
+ refute ThrowAssay.pass?(:foo){ throw :bar }
8
+
9
+ And conversely,
10
+
11
+ assert ThrowAssay.fail?(:foo){ throw :bar }
12
+ refute ThrowAssay.fail?(:foo){ throw :foo }
13
+
14
+ In addition `ThrowAssay` can assert that there is a throw, regardless
15
+ of tag.
16
+
17
+ assert ThrowAssay.pass?{ throw :foo }
18
+ refute ThrowAssay.pass?{ nil }
19
+
20
+ And converselry,
21
+
22
+ assert ThrowAssay.fail?{ nil }
23
+ refute ThrowAssay.fail?{ throw :bar }
24
+
25
+ Making assertions, notice that the `#assert!` method requires a `nil`
26
+ argument in order to test for any throw. This is not needed on the
27
+ `#pass?` method because the `#pass` method can't take aditional options
28
+ for setting the message or backtrace.
29
+
30
+ assert ThrowAssay.assert!(nil){ throw :foo }
31
+
32
+ assert ThrowAssay.assert!(nil, :message=>"optional message"){
33
+ throw :foo
34
+ }
35
+
36
+ expect ThrowAssay do
37
+ ThrowAssay.assert!(nil){ 'nothing' }
38
+ end
39
+
40
+ And refutations,
41
+
42
+ assert ThrowAssay.refute!(:foo){ throw :bar }
43
+
44
+ expect ThrowAssay do
45
+ ThrowAssay.refute!(:foo){ throw :foo }
46
+ end
47
+
@@ -0,0 +1,20 @@
1
+ ## PathAssay
2
+
3
+ The `PathAssay` asserts that a file-system path exists.
4
+
5
+ file = __FILE__
6
+ dir = File.dirname(file)
7
+ dne = __FILE__ + '~'
8
+
9
+ assert PathAssay.pass?(file)
10
+ assert PathAssay.pass?(dir)
11
+
12
+ refute PathAssay.pass?(dne)
13
+
14
+ And conversely,
15
+
16
+ assert PathAssay.fail?(dne)
17
+
18
+ refute PathAssay.fail?(file)
19
+ refute PathAssay.fail?(dir)
20
+
@@ -0,0 +1,21 @@
1
+ ## DirectoryAssay
2
+
3
+ The `DirectoryAssay` asserts that a file-system path exists
4
+ and it is a directory.
5
+
6
+ file = __FILE__
7
+ dir = File.dirname(file)
8
+ dne = __FILE__ + '~'
9
+
10
+ assert DirectoryAssay.pass?(dir)
11
+
12
+ refute DirectoryAssay.pass?(file)
13
+ refute DirectoryAssay.pass?(dne)
14
+
15
+ And conversely,
16
+
17
+ assert DirectoryAssay.fail?(file)
18
+ assert DirectoryAssay.fail?(dne)
19
+
20
+ refute DirectoryAssay.fail?(dir)
21
+
@@ -0,0 +1,20 @@
1
+ ## FileAssay
2
+
3
+ The `FileAssay` asserts that a file-system path exists and it is a file.
4
+
5
+ file = __FILE__
6
+ dir = File.dirname(file)
7
+ dne = __FILE__ + '~'
8
+
9
+ assert FileAssay.pass?(file)
10
+
11
+ refute FileAssay.pass?(dir)
12
+ refute FileAssay.pass?(dne)
13
+
14
+ And conversely,
15
+
16
+ assert FileAssay.fail?(dir)
17
+ assert FileAssay.fail?(dne)
18
+
19
+ refute FileAssay.fail?(file)
20
+
@@ -0,0 +1,39 @@
1
+ ## OutputAssay
2
+
3
+ The `OutputAssay` asserts that a output is sent to either `$stdout` or `$stderr`.
4
+
5
+ Let's do the simple stdout case first.
6
+
7
+ assert OutputAssay.pass?('foo'){ puts 'foo' }
8
+
9
+ refute OutputAssay.pass?('foo'){ nil }
10
+ refute OutputAssay.pass?('foo'){ puts 'bar' }
11
+
12
+ And conversely,
13
+
14
+ refute OutputAssay.fail?('foo'){ puts 'foo' }
15
+
16
+ assert OutputAssay.fail?('foo'){ nil }
17
+ assert OutputAssay.fail?('foo'){ puts 'bar' }
18
+
19
+ Now the same for `$stderr`.
20
+
21
+ assert OutputAssay.pass?('foo'){ $stderr.puts 'foo' }
22
+
23
+ refute OutputAssay.pass?('foo'){ nil }
24
+ refute OutputAssay.pass?('foo'){ $stderr.puts 'bar' }
25
+
26
+ And conversely,
27
+
28
+ refute OutputAssay.fail?('foo'){ $stderr.puts 'foo' }
29
+
30
+ assert OutputAssay.fail?('foo'){ nil }
31
+ assert OutputAssay.fail?('foo'){ $stderr.puts 'bar' }
32
+
33
+ The OutputAssay uses `#===` to test the match so we can also
34
+ match against a regular expression.
35
+
36
+ assert OutputAssay.pass?(/f/){ puts 'foo' }
37
+
38
+ assert OutputAssay.pass?(/f/){ $stderr.puts 'foo' }
39
+