assay 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.ruby +46 -41
  2. data/COPYING.rdoc +38 -0
  3. data/HISTORY.rdoc +18 -1
  4. data/QED.rdoc +1100 -0
  5. data/README.rdoc +139 -16
  6. data/lib/assay.rb +82 -29
  7. data/lib/assay.yml +46 -41
  8. data/lib/assay/{adapters → adapter}/minitest.rb +0 -0
  9. data/lib/assay/{adapters → adapter}/testunit.rb +0 -0
  10. data/lib/assay/assertable.rb +174 -0
  11. data/lib/assay/assertion.rb +98 -124
  12. data/lib/assay/assertor.rb +187 -0
  13. data/lib/assay/boolean_assay.rb +15 -0
  14. data/lib/assay/case_assay.rb +17 -0
  15. data/lib/assay/compare_assay.rb +38 -0
  16. data/lib/assay/core_ext/kernel.rb +52 -0
  17. data/lib/assay/core_ext/na.rb +9 -0
  18. data/lib/assay/directory_assay.rb +20 -0
  19. data/lib/assay/empty_assay.rb +17 -0
  20. data/lib/assay/equal_assay.rb +35 -0
  21. data/lib/assay/equality_assay.rb +18 -0
  22. data/lib/assay/execution_assay.rb +59 -0
  23. data/lib/assay/false_assay.rb +17 -0
  24. data/lib/assay/file_assay.rb +17 -0
  25. data/lib/assay/identity_assay.rb +49 -0
  26. data/lib/assay/include_assay.rb +17 -0
  27. data/lib/assay/instance_assay.rb +17 -0
  28. data/lib/assay/kind_assay.rb +18 -0
  29. data/lib/assay/less_assay.rb +18 -0
  30. data/lib/assay/less_equal_assay.rb +25 -0
  31. data/lib/assay/like_assay.rb +17 -0
  32. data/lib/assay/match_assay.rb +17 -0
  33. data/lib/assay/more_assay.rb +18 -0
  34. data/lib/assay/more_equal_assay.rb +25 -0
  35. data/lib/assay/nil_assay.rb +15 -0
  36. data/lib/assay/nomatch_assay.rb +17 -0
  37. data/lib/assay/output_assay.rb +35 -0
  38. data/lib/assay/path_assay.rb +17 -0
  39. data/lib/assay/raise_assay.rb +109 -0
  40. data/lib/assay/rescue_assay.rb +55 -0
  41. data/lib/assay/respond_assay.rb +17 -0
  42. data/lib/assay/return_assay.rb +46 -0
  43. data/lib/assay/silent_assay.rb +59 -0
  44. data/lib/assay/stderr_assay.rb +30 -0
  45. data/lib/assay/stdout_assay.rb +30 -0
  46. data/lib/assay/throw_assay.rb +89 -0
  47. data/lib/assay/true_assay.rb +20 -0
  48. data/lib/assay/unequal_assay.rb +37 -0
  49. data/lib/assay/within_assay.rb +39 -0
  50. data/test/case_compare_assay.rb +59 -0
  51. data/test/case_empty_assay.rb +51 -0
  52. data/test/case_equal_assay.rb +53 -0
  53. data/test/case_equality_assay.rb +55 -0
  54. data/test/case_false_assay.rb +48 -0
  55. data/test/case_identity_assay.rb +51 -0
  56. data/test/case_include_assay.rb +51 -0
  57. data/test/case_instance_assay.rb +51 -0
  58. data/test/case_kind_assay.rb +51 -0
  59. data/test/case_less_assay.rb +53 -0
  60. data/test/case_less_equal_assay.rb +53 -0
  61. data/test/case_like_assay.rb +57 -0
  62. data/test/case_match_assay.rb +45 -0
  63. data/test/case_more_assay.rb +53 -0
  64. data/test/case_more_equal_assay.rb +53 -0
  65. data/test/case_nil_assay.rb +48 -0
  66. data/test/case_nomatch_assay.rb +47 -0
  67. data/test/case_raise_assay.rb +51 -0
  68. data/test/case_respond_assay.rb +51 -0
  69. data/test/case_throw_assay.rb +51 -0
  70. data/test/case_true_assay.rb +48 -0
  71. data/test/case_unequal_assay.rb +55 -0
  72. data/test/case_within_assay.rb +61 -0
  73. data/test/helper.rb +36 -0
  74. metadata +135 -108
  75. data/APACHE2.txt +0 -205
  76. data/NOTICE.rdoc +0 -18
  77. data/lib/assay/assertions/compare_failure.rb +0 -61
  78. data/lib/assay/assertions/delta_failure.rb +0 -80
  79. data/lib/assay/assertions/empty_failure.rb +0 -76
  80. data/lib/assay/assertions/equality_failure.rb +0 -100
  81. data/lib/assay/assertions/execution_failure.rb +0 -90
  82. data/lib/assay/assertions/false_failure.rb +0 -72
  83. data/lib/assay/assertions/identity_failure.rb +0 -85
  84. data/lib/assay/assertions/instance_failure.rb +0 -76
  85. data/lib/assay/assertions/kind_failure.rb +0 -80
  86. data/lib/assay/assertions/match_failure.rb +0 -85
  87. data/lib/assay/assertions/nil_failure.rb +0 -75
  88. data/lib/assay/assertions/raise_failure.rb +0 -134
  89. data/lib/assay/assertions/response_failure.rb +0 -86
  90. data/lib/assay/assertions/same_failure.rb +0 -82
  91. data/lib/assay/assertions/throw_failure.rb +0 -122
  92. data/lib/assay/assertions/true_failure.rb +0 -79
  93. data/lib/assay/matcher.rb +0 -48
  94. data/qed/01_failure_classes.rdoc +0 -75
  95. data/qed/02_assertives.rdoc +0 -118
  96. data/qed/03_matchers.rdoc +0 -118
  97. data/qed/04_lookup.rdoc +0 -10
data/.ruby CHANGED
@@ -1,44 +1,49 @@
1
- ---
2
- spec_version: 1.0.0
3
- replaces: []
4
-
5
- loadpath:
6
- - lib
7
- name: assay
8
- repositories: {}
9
-
10
- conflicts: []
11
-
12
- engine_check: []
13
-
14
- title: Assay
15
- resources:
16
- code: http://github.com/rubyworks/assay
17
- docs: http://rubydoc.info/gems/assay
18
- home: http://rubydoc.info/gems/assay
19
- maintainers: []
20
-
21
- requires:
22
- - group: []
23
-
24
- name: ansi
25
- version: ">=1.2.5"
26
- - group:
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Thomas Sawyer
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer
9
+ year: '2009'
10
+ license: BSD-2-Clause
11
+ replacements: []
12
+ alternatives: []
13
+ requirements:
14
+ - name: ansi
15
+ - name: brass
16
+ - name: detroit
17
+ groups:
27
18
  - build
28
- name: redline
29
- version: 0+
30
- - group:
19
+ development: true
20
+ - name: qed
21
+ groups:
31
22
  - test
32
- name: qed
33
- version: 0+
34
- suite: rubyworks
35
- manifest: MANIFEST.txt
36
- version: 0.2.0
37
- licenses:
38
- - Apache 2.0
39
- copyright: Copyright (c) 2007 Thomas Sawyer
40
- authors:
41
- - Thomas Sawyer
42
- description: The Assay project defines Assertions in the same way that Ruby defines Exceptions. An asserition then simply becomes an extension to an Exception class.
23
+ development: true
24
+ dependencies: []
25
+ conflicts: []
26
+ repositories:
27
+ - uri: git@github.com:rubyworks/assay.git
28
+ scm: git
29
+ name: upstream
30
+ resources:
31
+ home: http://rubydoc.info/gems/assay
32
+ docs: http://rubydoc.info/gems/assay
33
+ code: http://github.com/rubyworks/assay
34
+ mail: http://groups.google.com/groups/rubyworks-mailinglist
35
+ extra: {}
36
+ load_path:
37
+ - lib
38
+ revision: 0
39
+ created: '2009-08-21'
43
40
  summary: Class-based Assertions Framework
44
- created: 2009-08-21
41
+ title: Assay
42
+ version: 0.4.0
43
+ name: assay
44
+ description: ! 'The Assay project defines Assertions in the same way that Ruby defines
45
+ Exceptions.
46
+
47
+ An asserition then simply becomes an extension to an Exception class.'
48
+ organization: Rubyworks
49
+ date: '2012-01-25'
@@ -0,0 +1,38 @@
1
+ = COPYRIGHT
2
+
3
+ == NOTICES
4
+
5
+ === Assay
6
+
7
+ Copyright:: (c) 2012 RubyWorks
8
+ License:: (r) BSD-2-Clause
9
+ Website:: http://rubyworks.github.com/assay
10
+
11
+ == LICENSES
12
+
13
+ === BSD-2-Clause License
14
+
15
+ Assay
16
+
17
+ Copyright (c) 2012 Rubyworks. All rights reserved.
18
+
19
+ Redistribution and use in source and binary forms, with or without
20
+ modification, are permitted provided that the following conditions are met:
21
+
22
+ 1. Redistributions of source code must retain the above copyright notice,
23
+ this list of conditions and the following disclaimer.
24
+
25
+ 2. Redistributions in binary form must reproduce the above copyright
26
+ notice, this list of conditions and the following disclaimer in the
27
+ documentation and/or other materials provided with the distribution.
28
+
29
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
30
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
34
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
36
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
38
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,5 +1,22 @@
1
1
  = HISTORY
2
2
 
3
+ == 0.4.0 | 1012-01-25
4
+
5
+ Version 0.4 is a very polished partial rewrite of the Assay project.
6
+ This release sheds all ancillary code to separate projects. The
7
+ compatibility layers are now `assay-testunit`, `assay-minitest` and
8
+ `assay-rspec`. The built-in grammar is now the `fluidity` project.
9
+ All assertion classes now end with `Assay` suffix instead of `Failure`
10
+ and they are defined at the toplevel.
11
+
12
+ Changes:
13
+
14
+ * Spin-off all ancillary code, leaving only core functionality.
15
+ * Polish and semi-rewrite code.
16
+ * Renamed all Assertion subclasses form xxxFailure to xxxAssay.
17
+ * Add many new Assertion subclasses.
18
+
19
+
3
20
  == 0.3.0 | 2011-05-07
4
21
 
5
22
  This release fix the interface of the assertive methods so they accept
@@ -17,7 +34,7 @@ This release of Assay is in good working order and can now be used
17
34
  by other frameworks such as A.E. The only caveats at this point
18
35
  are the Matcher API, which is still a bit unstable as the names of
19
36
  some of its methods may yet change, and the error messages
20
- for the vairous Failure classes still need improvement.
37
+ for the various Failure classes still need improvement.
21
38
 
22
39
  Changes:
23
40
 
@@ -0,0 +1,1100 @@
1
+ Assay is an foundational assertion framework.
2
+
3
+
4
+ # Assay Classes
5
+
6
+
7
+ ## NilAssay
8
+
9
+ The `NilAssay` asserts that an object reference is `nil`.
10
+ Reference to any other object will fail.
11
+
12
+ assert NilAssay.pass?(nil)
13
+
14
+ refute NilAssay.pass?(true)
15
+ refute NilAssay.pass?(false)
16
+ refute NilAssay.pass?("foo")
17
+
18
+ And conversely,
19
+
20
+ assert NilAssay.fail?(true)
21
+ assert NilAssay.fail?(false)
22
+ assert NilAssay.fail?("foo")
23
+
24
+ refute NilAssay.fail?(nil)
25
+
26
+ Making assertions,
27
+
28
+ assert NilAssay.assert!(nil)
29
+
30
+ expect ::NilAssay do
31
+ NilAssay.assert!(true)
32
+ end
33
+
34
+ And refutations,
35
+
36
+ assert NilAssay.refute!(true)
37
+
38
+ expect ::NilAssay do
39
+ NilAssay.refute!(nil)
40
+ end
41
+
42
+
43
+ ## BooleanAssay
44
+
45
+ The `BooleanAssay` asserts that an object reference is `nil`.
46
+ Reference to any other object will fail.
47
+
48
+ assert BooleanAssay.pass?(true)
49
+ assert BooleanAssay.pass?(false)
50
+
51
+ refute BooleanAssay.pass?(nil)
52
+ refute BooleanAssay.pass?("foo")
53
+
54
+ And conversely,
55
+
56
+ assert BooleanAssay.fail?(nil)
57
+ assert BooleanAssay.fail?("foo")
58
+
59
+ refute BooleanAssay.fail?(true)
60
+ refute BooleanAssay.fail?(false)
61
+
62
+ Making assertions,
63
+
64
+ assert BooleanAssay.assert!(true)
65
+
66
+ expect ::BooleanAssay do
67
+ BooleanAssay.assert!(nil)
68
+ end
69
+
70
+ And refutations,
71
+
72
+ assert BooleanAssay.refute!(nil)
73
+
74
+ expect ::BooleanAssay do
75
+ BooleanAssay.refute!(true)
76
+ end
77
+
78
+
79
+ ## FalseAssay
80
+
81
+ The `FalseAssay` class asserts that an object is `false.
82
+ Reference to any other object will fail.
83
+
84
+ assert FalseAssay.pass?(false)
85
+
86
+ refute FalseAssay.pass?(true)
87
+ refute FalseAssay.pass?(nil)
88
+ refute FalseAssay.pass?('foo')
89
+
90
+ And conversely,
91
+
92
+ assert FalseAssay.fail?(true)
93
+ assert FalseAssay.fail?(nil)
94
+ assert FalseAssay.fail?('foo')
95
+
96
+ refute FalseAssay.fail?(false)
97
+
98
+
99
+ ## TrueAssay
100
+
101
+ The `TrueAssay` class asserts that an object is `true`.
102
+ Reference to any other object will fail.
103
+
104
+ assert TrueAssay.pass?(true)
105
+
106
+ refute TrueAssay.pass?(false)
107
+ refute TrueAssay.pass?(nil)
108
+ refute TrueAssay.pass?('foo')
109
+
110
+ And conversely,
111
+
112
+ assert TrueAssay.fail?(false)
113
+ assert TrueAssay.fail?(nil)
114
+ assert TrueAssay.fail?('foo')
115
+
116
+ refute TrueAssay.fail?(true)
117
+
118
+
119
+
120
+ ## LikeAssay
121
+
122
+ The `LikeAssay` is a very ... assertion. It is a comparison that
123
+ evaluates to true for any of Ruby's many "equal" operators, `equal?`
124
+ (same as `identical?`), `eql?`, `==`, `===` and `=~`. If any one
125
+ of these evaluates to true, than two objects can be said to be alike.
126
+
127
+ assert LikeAssay.pass?(1, 1)
128
+ assert LikeAssay.pass?(1, 1.0)
129
+ assert LikeAssay.pass?("1", /\d/)
130
+
131
+ refute LikeAssay.pass?(1, "1")
132
+ refute LikeAssay.pass?("1", /\D/)
133
+
134
+ And conversely,
135
+
136
+ assert LikeAssay.fail?(1, "1")
137
+ assert LikeAssay.fail?("1", /\D/)
138
+
139
+
140
+ ## EqualAssay
141
+
142
+ The `EqualAssay` class defines an assertion for equality based on the `==` method.
143
+
144
+ assert EqualAssay.pass?(1, 1)
145
+ assert EqualAssay.pass?(1, 1.0)
146
+
147
+ refute EqualAssay.pass?(1, 2)
148
+ refute EqualAssay.pass?(1, 'foo')
149
+
150
+ And conversely,
151
+
152
+ assert EqualAssay.fail?(1, 2)
153
+ assert EqualAssay.fail?(1, 'foo')
154
+
155
+ refute EqualAssay.fail?(1, 1)
156
+ refute EqualAssay.fail?(1, 1.0)
157
+
158
+
159
+
160
+ ## UnequalAssay
161
+
162
+ The `UnequalAssay` class defines an assertion for equality based on the `!=`
163
+ method, which in Ruby 1.8 is a redefinable method all it's own.
164
+
165
+ assert UnequalAssay.pass?(1, 2)
166
+ assert UnequalAssay.pass?(1, 'foo')
167
+
168
+ refute UnequalAssay.pass?(1, 1)
169
+ refute UnequalAssay.pass?(1, 1.0)
170
+
171
+ And conversely,
172
+
173
+ assert UnequalAssay.fail?(1, 1)
174
+ assert UnequalAssay.fail?(1, 1.0)
175
+
176
+ refute UnequalAssay.fail?(1, 2)
177
+ refute UnequalAssay.fail?(1, 'foo')
178
+
179
+ Making assertions,
180
+
181
+ assert UnequalAssay.assert!(10, 20)
182
+
183
+ expect ::UnequalAssay do
184
+ UnequalAssay.assert!(10, 10)
185
+ end
186
+
187
+ And refutations,
188
+
189
+ assert UnequalAssay.refute!(10, 10)
190
+
191
+ expect ::UnequalAssay do
192
+ UnequalAssay.refute!(10, 20)
193
+ end
194
+
195
+
196
+ ## EqualityAssay
197
+
198
+ The `EqualityAssay` class defines an assertion for strict equality via
199
+ the `eql?` method.
200
+
201
+ assert EqualityAssay.pass?(1, 1)
202
+
203
+ refute EqualityAssay.pass?(1, 1.0)
204
+ refute EqualityAssay.pass?(1, 2)
205
+ refute EqualityAssay.pass?(1, 'foo')
206
+
207
+ And conversely,
208
+
209
+ assert EqualityAssay.fail?(1, 2)
210
+ assert EqualityAssay.fail?(1, 1.0)
211
+ assert EqualityAssay.fail?(1, 'foo')
212
+
213
+ refute EqualityAssay.fail?(1, 1)
214
+
215
+
216
+ ## IdentityAssay
217
+
218
+ The `IdentityAssay` class defines an assertion for identity comparison via
219
+ the `#identical?` method, which is an alias for the `#equal?` method.
220
+ We have choosen not to use the term `equal` to avoid confusion with the
221
+ ordinary `==` type of equality.
222
+
223
+ assert IdentityAssay.pass?(1, 1)
224
+ assert IdentityAssay.pass?(:a, :a)
225
+
226
+ refute IdentityAssay.pass?('a', 'a')
227
+ refute IdentityAssay.pass?(1, 1.0)
228
+ refute IdentityAssay.pass?(1, 2)
229
+ refute IdentityAssay.pass?(1, 'foo')
230
+
231
+ And conversely,
232
+
233
+ assert IdentityAssay.fail?(1, 2)
234
+ assert IdentityAssay.fail?(1, 1.0)
235
+ assert IdentityAssay.fail?(1, 'foo')
236
+ assert IdentityAssay.fail?('a', 'a')
237
+
238
+ refute IdentityAssay.fail?(1, 1)
239
+ refute IdentityAssay.fail?(:a, :a)
240
+
241
+ ## CaseAssay
242
+
243
+ The `CaseAssay` class defines an assertion for case equality using the `#===`
244
+ method.
245
+
246
+ assert CaseAssay.pass?(1, 1)
247
+ assert CaseAssay.pass?(1, 1.0)
248
+ assert CaseAssay.pass?(/a/, 'a')
249
+ assert CaseAssay.pass?(String, 'foo')
250
+
251
+ refute CaseAssay.pass?(1, 2)
252
+ refute CaseAssay.pass?(1, 'foo')
253
+
254
+ And conversely,
255
+
256
+ assert CaseAssay.fail?(1, 2)
257
+ assert CaseAssay.fail?(1, 'foo')
258
+
259
+ refute CaseAssay.fail?(1, 1)
260
+ refute CaseAssay.fail?(1, 1.0)
261
+ refute CaseAssay.fail?(/a/, 'a')
262
+ refute CaseAssay.fail?(String, 'foo')
263
+
264
+ ## MatchAssay
265
+
266
+ The `MatchAssay` class defines an assertion for matching using the `#=~`
267
+ method.
268
+
269
+ assert MatchAssay.pass?('a', /a/)
270
+
271
+ refute MatchAssay.pass?('a', /b/)
272
+
273
+ And conversely,
274
+
275
+ assert MatchAssay.fail?('a', /b/)
276
+
277
+ refute MatchAssay.fail?('a', /a/)
278
+
279
+
280
+ ## NoMatchAssay
281
+
282
+ The `NoMatchAssay` class defines an assertion for matching using the `#!~`
283
+ method. As of Ruby 1.9, the `#!~` method is redefinable independent of `#=~`,
284
+ so a separate assertion class is needed to cover it.
285
+
286
+ assert NoMatchAssay.pass?('a', /b/)
287
+
288
+ refute NoMatchAssay.pass?('a', /a/)
289
+
290
+ And conversely,
291
+
292
+ assert NoMatchAssay.fail?('a', /a/)
293
+
294
+ refute NoMatchAssay.fail?('a', /b/)
295
+
296
+
297
+ ## CompareAssay
298
+
299
+ The `CompareAssay` class defines an assertion of comparison around the `#<=>`
300
+ method. Since `#<=>` can return either a `1`, `0` or `-1`, an extra criterion
301
+ is needed when making testing the assertion.
302
+
303
+ assert CompareAssay.pass?(1, 1, 0)
304
+ assert CompareAssay.pass?(1, 2, -1)
305
+ assert CompareAssay.pass?(2, 1, 1)
306
+
307
+ refute CompareAssay.pass?(1, 1, 1)
308
+ refute CompareAssay.pass?(1, 1, -1)
309
+
310
+ refute CompareAssay.pass?(1, 'foo', 0)
311
+
312
+ And conversely,
313
+
314
+ assert CompareAssay.fail?(1, 1, 1)
315
+ assert CompareAssay.fail?(1, 1, -1)
316
+
317
+ refute CompareAssay.fail?(1, 1, 0)
318
+ refute CompareAssay.fail?(1, 2, -1)
319
+ refute CompareAssay.fail?(2, 1, 1)
320
+
321
+
322
+ ## LessAssay
323
+
324
+ The `LessAssay` class defines an assertion of comparison around the `#<`
325
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
326
+ mixin, so `LessAssay` is a subclass of `ComapreAssay`, though techincally
327
+ the `#<` method can be defined independently.
328
+
329
+ assert LessAssay.pass?( 1, 2)
330
+ assert LessAssay.pass?(-1, 0)
331
+
332
+ refute LessAssay.pass?(1, 1)
333
+ refute LessAssay.pass?(1, 0)
334
+
335
+ And conversely,
336
+
337
+ assert LessAssay.fail?(1, 1)
338
+ assert LessAssay.fail?(1, 0)
339
+
340
+ refute LessAssay.fail?( 1, 2)
341
+ refute LessAssay.fail?(-1, 0)
342
+
343
+ This applies to any type of object that defines `#<=`, not just numbers.
344
+
345
+ assert LessAssay.pass?('a', 'b')
346
+ refute LessAssay.pass?('b', 'a')
347
+
348
+ assert LessAssay.fail?('b', 'a')
349
+ refute LessAssay.fail?('a', 'b')
350
+
351
+
352
+ ## MoreAssay
353
+
354
+ The `MoreAssay` class defines an assertion of comparison around the `#>`
355
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
356
+ mixin, so `MoreAssay` is a subclass of `ComapreAssay`, though techincally
357
+ the `#>` method can be defined indenpendently.
358
+
359
+ assert MoreAssay.pass?(2, 1)
360
+ assert MoreAssay.pass?(0, -1)
361
+ assert MoreAssay.pass?(1, 0)
362
+
363
+ refute MoreAssay.pass?(1, 1)
364
+ refute MoreAssay.pass?(1, 2)
365
+
366
+ And conversely,
367
+
368
+ assert MoreAssay.fail?(1, 1)
369
+ assert MoreAssay.fail?(0, 1)
370
+
371
+ refute MoreAssay.fail?(2, 1)
372
+ refute MoreAssay.fail?(0, -1)
373
+
374
+ This applies to any type of object that defines `#>`, not just numbers.
375
+
376
+ assert MoreAssay.pass?('b', 'a')
377
+ refute MoreAssay.pass?('a', 'b')
378
+
379
+ assert MoreAssay.fail?('a', 'b')
380
+ refute MoreAssay.fail?('b', 'a')
381
+
382
+ ## LessEqualAssay
383
+
384
+ The `LessEqualAssay` class defines an assertion of comparison around the `#<=`
385
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
386
+ mixin, so `LessEqualAssay` is a subclass of `ComapreAssay`, though techincally
387
+ the `#<=` method can be defined indenpendently.
388
+
389
+ assert LessEqualAssay.pass?( 1, 2)
390
+ assert LessEqualAssay.pass?(-1, 0)
391
+ assert LessEqualAssay.pass?( 1, 1)
392
+
393
+ refute LessEqualAssay.pass?(1, 0)
394
+
395
+ And conversely,
396
+
397
+ assert LessEqualAssay.fail?(1, 0)
398
+
399
+ refute LessEqualAssay.fail?( 1, 1)
400
+ refute LessEqualAssay.fail?( 1, 2)
401
+ refute LessEqualAssay.fail?(-1, 0)
402
+
403
+ This applies to any type of object that defines `#<=`, not just numbers.
404
+
405
+ assert LessEqualAssay.pass?('a', 'b')
406
+ refute LessEqualAssay.pass?('b', 'a')
407
+
408
+ assert LessEqualAssay.fail?('b', 'a')
409
+ refute LessEqualAssay.fail?('a', 'b')
410
+
411
+
412
+
413
+ ## MoreEqualAssay
414
+
415
+ The `MoreEqualAssay` class defines an assertion of comparison around the `#>=`
416
+ method. This method usually depends on the `#<=>` method via Ruby's Comparable
417
+ mixin, so `MoreEqualAssay` is a subclass of `ComapreAssay`, though techincally
418
+ the `#>=` method can be defined indenpendently.
419
+
420
+ assert MoreEqualAssay.pass?(2, 1)
421
+ assert MoreEqualAssay.pass?(0, -1)
422
+ assert MoreEqualAssay.pass?(1, 1)
423
+
424
+ refute MoreEqualAssay.pass?(0, 1)
425
+
426
+ And conversely,
427
+
428
+ assert MoreEqualAssay.fail?(0, 1)
429
+
430
+ refute MoreEqualAssay.fail?( 1, 1)
431
+ refute MoreEqualAssay.fail?( 2, 1)
432
+ refute MoreEqualAssay.fail?( 0, -1)
433
+
434
+ This applies to any type of object that defines `#<=`, not just numbers.
435
+
436
+ assert MoreEqualAssay.pass?('b', 'a')
437
+ refute MoreEqualAssay.pass?('a', 'b')
438
+
439
+ assert MoreEqualAssay.fail?('a', 'b')
440
+ refute MoreEqualAssay.fail?('b', 'a')
441
+
442
+
443
+ ## WithinAssay
444
+
445
+ The `WithinAssay` class defines an assertion for matching that two values
446
+ lie with a range.
447
+
448
+ assert WithinAssay.pass?(1, 1, 0)
449
+ assert WithinAssay.pass?(1, 1.1, 0.1)
450
+
451
+ refute WithinAssay.pass?(1, 2, 0)
452
+ refute WithinAssay.pass?(1, 1.2, 0.1)
453
+
454
+ And conversely,
455
+
456
+ assert WithinAssay.fail?(1, 2, 0)
457
+ assert WithinAssay.fail?(1, 1.2, 0.1)
458
+
459
+ refute WithinAssay.fail?(1, 1, 0)
460
+ refute WithinAssay.fail?(1, 1.1, 0.1)
461
+
462
+ The object do not have to be numbers necessaity, just so long as they
463
+ are comparable and subtractable.
464
+
465
+ time = Time.now
466
+
467
+ assert WithinAssay.pass?(time, time+1, 2)
468
+
469
+ Making assertions,
470
+
471
+ assert WithinAssay.assert!(10, 11, 1)
472
+
473
+ expect ::WithinAssay do
474
+ WithinAssay.assert!(10, 15, 2)
475
+ end
476
+
477
+ And refutations,
478
+
479
+ assert WithinAssay.refute!(10, 11, 0.1)
480
+
481
+ expect ::WithinAssay do
482
+ WithinAssay.refute!(10, 11, 1)
483
+ end
484
+
485
+
486
+ ## KindAssay
487
+
488
+ The `KindAssay` asserts that an object is a class or any ancestor
489
+ of that class.
490
+
491
+ assert KindAssay.pass?(1, Fixnum)
492
+ assert KindAssay.pass?(1, Numeric)
493
+
494
+ refute KindAssay.pass?(1, String)
495
+
496
+ And conversely,
497
+
498
+ assert KindAssay.fail?(1, String)
499
+
500
+ refute KindAssay.fail?(1, Fixnum)
501
+ refute KindAssay.fail?(1, Numeric)
502
+
503
+
504
+ ## InstanceAssay
505
+
506
+ The `InstanceAssay` asserts that an object is an instance of a specific class.
507
+
508
+ assert InstanceAssay.pass?(1, Fixnum)
509
+
510
+ refute InstanceAssay.pass?(1, Numeric)
511
+ refute InstanceAssay.pass?(1, String)
512
+
513
+ And conversely,
514
+
515
+ assert InstanceAssay.fail?(1, String)
516
+ assert InstanceAssay.fail?(1, Numeric)
517
+
518
+ refute InstanceAssay.fail?(1, Fixnum)
519
+
520
+
521
+ ## IncludeAssay
522
+
523
+ The `IncludeAssay` asserts that a collection includes a specific member, using
524
+ the `#include?` method.
525
+
526
+ assert IncludeAssay.pass?([1], 1)
527
+
528
+ refute IncludeAssay.pass?([], 1)
529
+ refute IncludeAssay.pass?([2], 1)
530
+
531
+ And conversely,
532
+
533
+ assert IncludeAssay.fail?([], 1)
534
+ assert IncludeAssay.fail?([2], 1)
535
+
536
+ refute IncludeAssay.fail?([1], 1)
537
+
538
+
539
+ ## EmptyAssay
540
+
541
+ The `EmptyAssay` asserts that a collection includes no members, using the
542
+ `#empty?` method.
543
+
544
+ assert EmptyAssay.pass?([])
545
+
546
+ refute EmptyAssay.pass?([1])
547
+
548
+ And conversely,
549
+
550
+ assert EmptyAssay.fail?([1])
551
+
552
+ refute EmptyAssay.fail?([])
553
+
554
+
555
+ ## RespondAssay
556
+
557
+ The `RespondAssay` asserts if a an object responds to a message using
558
+ then `#respond_to?` method.
559
+
560
+ assert RespondAssay.pass?('a', :to_s)
561
+
562
+ refute RespondAssay.pass?('a', :foo)
563
+
564
+ And conversely,
565
+
566
+ assert RespondAssay.fail?('a', :foo)
567
+
568
+ refute RespondAssay.fail?('a', :to_s)
569
+
570
+
571
+ ## ExecutionAssay
572
+
573
+ The `ExecutionAssay` asserts that a procedure runs without error and returns
574
+ a result other than `false` or `nil`. It is not particularly useful, because
575
+ what it does is effectively what testing in itself does. So it is rather
576
+ redundant. However, it serves as the base class for the more specific
577
+ `ReturnAssay`.
578
+
579
+ assert ExecutionAssay.pass?{ true }
580
+ assert ExecutionAssay.pass?{ :foo }
581
+
582
+ refute ExecutionAssay.pass?{ nil }
583
+ refute ExecutionAssay.pass?{ false }
584
+ refute ExecutionAssay.pass?{ raise }
585
+
586
+ And conversely,
587
+
588
+ assert ExecutionAssay.fail?{ raise }
589
+ assert ExecutionAssay.fail?{ nil }
590
+ assert ExecutionAssay.fail?{ false }
591
+
592
+ refute ExecutionAssay.fail?{ true }
593
+ refute ExecutionAssay.fail?{ :foo }
594
+
595
+ Making assertions,
596
+
597
+ assert ExecutionAssay.assert!{ true }
598
+
599
+ expect ::ExecutionAssay do
600
+ assert ExecutionAssay.assert!{ false }
601
+ end
602
+
603
+ And refutations,
604
+
605
+ assert ExecutionAssay.refute!{ false }
606
+
607
+ expect ::ExecutionAssay do
608
+ assert ExecutionAssay.refute!{ true }
609
+ end
610
+
611
+
612
+ ## ReturnAssay
613
+
614
+ The `ReturnAssay` asserts that a procedure runs without error and returns
615
+ a specified result.
616
+
617
+ assert ReturnAssay.pass?(:foo){ :foo }
618
+ assert ReturnAssay.pass?(true){ true }
619
+
620
+ refute ReturnAssay.pass?(:foo){ :bar }
621
+ refute ReturnAssay.pass?(:foo){ true }
622
+ refute ReturnAssay.pass?(:foo){ raise }
623
+
624
+ And conversely,
625
+
626
+ assert ReturnAssay.fail?(:foo){ :bar }
627
+ assert ReturnAssay.fail?(:foo){ true }
628
+ assert ReturnAssay.fail?(:foo){ raise }
629
+
630
+ refute ReturnAssay.fail?(:foo){ :foo }
631
+ refute ReturnAssay.fail?(true){ true }
632
+
633
+ Making assertions,
634
+
635
+ assert ReturnAssay.assert!(true){ true }
636
+
637
+ expect ::ReturnAssay do
638
+ assert ReturnAssay.assert!(:foo){ :bar }
639
+ end
640
+
641
+ And refutations,
642
+
643
+ assert ReturnAssay.refute!(:foo){ :bar }
644
+
645
+ expect ::ReturnAssay do
646
+ assert ReturnAssay.refute!(:foo){ :foo }
647
+ end
648
+
649
+
650
+ ## RescueAssay
651
+
652
+ The `RescueAssay` asserts that a procedure will raise a specific error.
653
+
654
+ assert RescueAssay.pass?{ raise }
655
+ assert RescueAssay.pass?(RuntimeError){ raise }
656
+ assert RescueAssay.pass?(ArgumentError){ raise ArgumentError }
657
+ assert RescueAssay.pass?(Exception){ raise ArgumentError }
658
+
659
+ refute RescueAssay.pass?{ raise Exception }
660
+ refute RescueAssay.pass?(RuntimeError){ nil }
661
+ refute RescueAssay.pass?(ArgumentError){ raise }
662
+
663
+ And conversely,
664
+
665
+ assert RescueAssay.fail?{ raise Exception }
666
+ assert RescueAssay.fail?(RuntimeError){ nil }
667
+ assert RescueAssay.fail?(ArgumentError){ raise }
668
+
669
+ refute RescueAssay.fail?{ raise }
670
+ refute RescueAssay.fail?(RuntimeError){ raise }
671
+ refute RescueAssay.fail?(ArgumentError){ raise ArgumentError }
672
+ refute RescueAssay.fail?(Exception){ raise ArgumentError }
673
+
674
+ Making assertions,
675
+
676
+ assert RescueAssay.assert!(RuntimeError){ raise }
677
+
678
+ expect ::RescueAssay do
679
+ RaiseAssay.assert!(RuntimeError){ nil }
680
+ end
681
+
682
+ And refutations,
683
+
684
+ assert RescueAssay.refute!(RuntimeError){ nil }
685
+
686
+ expect ::RescueAssay do
687
+ RaiseAssay.refute!(RuntimeError){ raise }
688
+ end
689
+
690
+
691
+ ## RaiseAssay
692
+
693
+ The `RaiseAssay` asserts that a procedure will raise a specific error.
694
+
695
+ assert RaiseAssay.pass?{ raise }
696
+ assert RaiseAssay.pass?(RuntimeError){ raise }
697
+ assert RaiseAssay.pass?(ArgumentError){ raise ArgumentError }
698
+
699
+ refute RaiseAssay.pass?{ raise Exception }
700
+ refute RaiseAssay.pass?(Exception){ raise ArgumentError }
701
+ refute RaiseAssay.pass?(StandardError){ nil }
702
+ refute RaiseAssay.pass?(ArgumentError){ raise }
703
+
704
+ And conversely,
705
+
706
+ assert RaiseAssay.fail?{ raise Exception }
707
+ assert RaiseAssay.fail?(RuntimeError){ nil }
708
+ assert RaiseAssay.fail?(ArgumentError){ raise }
709
+ assert RaiseAssay.fail?(Exception){ raise ArgumentError }
710
+
711
+ refute RaiseAssay.fail?{ raise }
712
+ refute RaiseAssay.fail?(RuntimeError){ raise }
713
+ refute RaiseAssay.fail?(ArgumentError){ raise ArgumentError }
714
+
715
+ Making assertions,
716
+
717
+ assert RaiseAssay.assert!(RuntimeError){ raise }
718
+
719
+ expect ::RaiseAssay do
720
+ RaiseAssay.assert!(RuntimeError){ nil }
721
+ end
722
+
723
+ And refutations,
724
+
725
+ assert RaiseAssay.refute!(RuntimeError){ nil }
726
+
727
+ expect ::RaiseAssay do
728
+ RaiseAssay.refute!(RuntimeError){ raise }
729
+ end
730
+
731
+
732
+ ## ThrowAssay
733
+
734
+ The `ThrowAssay` asserts that a procedure will call `throw` and optionally
735
+ of a specific type.
736
+
737
+ assert ThrowAssay.pass?(:foo){ throw :foo }
738
+ refute ThrowAssay.pass?(:foo){ throw :bar }
739
+
740
+ And conversely,
741
+
742
+ assert ThrowAssay.fail?(:foo){ throw :bar }
743
+ refute ThrowAssay.fail?(:foo){ throw :foo }
744
+
745
+ In addition `ThrowAssay` can assert that there is a throw, regardless
746
+ of tag.
747
+
748
+ assert ThrowAssay.pass?{ throw :foo }
749
+ refute ThrowAssay.pass?{ nil }
750
+
751
+ And converselry,
752
+
753
+ assert ThrowAssay.fail?{ nil }
754
+ refute ThrowAssay.fail?{ throw :bar }
755
+
756
+ Making assertions, notice that the `#assert!` method requires a `nil`
757
+ argument in order to test for any throw. This is not needed on the
758
+ `#pass?` method because the `#pass` method can't take aditional options
759
+ for setting the message or backtrace.
760
+
761
+ assert ThrowAssay.assert!(nil){ throw :foo }
762
+
763
+ assert ThrowAssay.assert!(nil, :message=>"optional message"){
764
+ throw :foo
765
+ }
766
+
767
+ expect ThrowAssay do
768
+ ThrowAssay.assert!(nil){ 'nothing' }
769
+ end
770
+
771
+ And refutations,
772
+
773
+ assert ThrowAssay.refute!(:foo){ throw :bar }
774
+
775
+ expect ThrowAssay do
776
+ ThrowAssay.refute!(:foo){ throw :foo }
777
+ end
778
+
779
+
780
+ ## PathAssay
781
+
782
+ The `PathAssay` asserts that a file-system path exists.
783
+
784
+ file = __FILE__
785
+ dir = File.dirname(file)
786
+ dne = __FILE__ + '~'
787
+
788
+ assert PathAssay.pass?(file)
789
+ assert PathAssay.pass?(dir)
790
+
791
+ refute PathAssay.pass?(dne)
792
+
793
+ And conversely,
794
+
795
+ assert PathAssay.fail?(dne)
796
+
797
+ refute PathAssay.fail?(file)
798
+ refute PathAssay.fail?(dir)
799
+
800
+
801
+ ## DirectoryAssay
802
+
803
+ The `DirectoryAssay` asserts that a file-system path exists
804
+ and it is a directory.
805
+
806
+ file = __FILE__
807
+ dir = File.dirname(file)
808
+ dne = __FILE__ + '~'
809
+
810
+ assert DirectoryAssay.pass?(dir)
811
+
812
+ refute DirectoryAssay.pass?(file)
813
+ refute DirectoryAssay.pass?(dne)
814
+
815
+ And conversely,
816
+
817
+ assert DirectoryAssay.fail?(file)
818
+ assert DirectoryAssay.fail?(dne)
819
+
820
+ refute DirectoryAssay.fail?(dir)
821
+
822
+
823
+ ## FileAssay
824
+
825
+ The `FileAssay` asserts that a file-system path exists and it is a file.
826
+
827
+ file = __FILE__
828
+ dir = File.dirname(file)
829
+ dne = __FILE__ + '~'
830
+
831
+ assert FileAssay.pass?(file)
832
+
833
+ refute FileAssay.pass?(dir)
834
+ refute FileAssay.pass?(dne)
835
+
836
+ And conversely,
837
+
838
+ assert FileAssay.fail?(dir)
839
+ assert FileAssay.fail?(dne)
840
+
841
+ refute FileAssay.fail?(file)
842
+
843
+
844
+ ## OutputAssay
845
+
846
+ The `OutputAssay` asserts that a output is sent to either `$stdout` or `$stderr`.
847
+
848
+ Let's do the simple stdout case first.
849
+
850
+ assert OutputAssay.pass?('foo'){ puts 'foo' }
851
+
852
+ refute OutputAssay.pass?('foo'){ nil }
853
+ refute OutputAssay.pass?('foo'){ puts 'bar' }
854
+
855
+ And conversely,
856
+
857
+ refute OutputAssay.fail?('foo'){ puts 'foo' }
858
+
859
+ assert OutputAssay.fail?('foo'){ nil }
860
+ assert OutputAssay.fail?('foo'){ puts 'bar' }
861
+
862
+ Now the same for `$stderr`.
863
+
864
+ assert OutputAssay.pass?('foo'){ $stderr.puts 'foo' }
865
+
866
+ refute OutputAssay.pass?('foo'){ nil }
867
+ refute OutputAssay.pass?('foo'){ $stderr.puts 'bar' }
868
+
869
+ And conversely,
870
+
871
+ refute OutputAssay.fail?('foo'){ $stderr.puts 'foo' }
872
+
873
+ assert OutputAssay.fail?('foo'){ nil }
874
+ assert OutputAssay.fail?('foo'){ $stderr.puts 'bar' }
875
+
876
+ The OutputAssay uses `#===` to test the match so we can also
877
+ match against a regular expression.
878
+
879
+ assert OutputAssay.pass?(/f/){ puts 'foo' }
880
+
881
+ assert OutputAssay.pass?(/f/){ $stderr.puts 'foo' }
882
+
883
+
884
+ ## StdoutAssay
885
+
886
+ The `StdoutAssay` asserts that a output is sent to `$stdout`.
887
+
888
+ assert StdoutAssay.pass?('foo'){ puts 'foo' }
889
+
890
+ refute StdoutAssay.pass?('foo'){ nil }
891
+ refute StdoutAssay.pass?('foo'){ puts 'bar' }
892
+
893
+ And conversely,
894
+
895
+ refute StdoutAssay.fail?('foo'){ puts 'foo' }
896
+
897
+ assert StdoutAssay.fail?('foo'){ nil }
898
+ assert StdoutAssay.fail?('foo'){ puts 'bar' }
899
+
900
+ The StdoutAssay uses `#===` to test the match so we can also
901
+ match against a regular expression.
902
+
903
+ assert StdoutAssay.pass?(/f/){ puts 'foo' }
904
+
905
+
906
+ ## StderrAssay
907
+
908
+ The `StderrAssay` asserts that a output is sent to `$stderr`.
909
+
910
+ assert StderrAssay.pass?('foo'){ $stderr.puts 'foo' }
911
+
912
+ refute StderrAssay.pass?('foo'){ nil }
913
+ refute StderrAssay.pass?('foo'){ $stderr.puts 'bar' }
914
+
915
+ And conversely,
916
+
917
+ refute StderrAssay.fail?('foo'){ $stderr.puts 'foo' }
918
+
919
+ assert StderrAssay.fail?('foo'){ nil }
920
+ assert StderrAssay.fail?('foo'){ $stderr.puts 'bar' }
921
+
922
+ The StderrAssay uses `#===` to test the match so we can also
923
+ match against a regular expression.
924
+
925
+ assert StderrAssay.pass?(/f/){ $stderr.puts 'foo' }
926
+
927
+
928
+ # Asay Lookup
929
+
930
+ Assay classes are indexed by both name and associated operation, so they
931
+ can be looked-up by either. The indexes are stored as class attributes of
932
+ the Assertion base class.
933
+
934
+ Let's lookup the class for `==` equality.
935
+
936
+ Assertion.by_operator(:==) #=> ::EqualAssay
937
+
938
+ Let's lookup the assertion class for `#empty?`.
939
+
940
+ Assertion.by_operator(:empty?) #=> ::EmptyAssay
941
+
942
+ If we wish to lookup by assertive name instead of operator, we can use
943
+ the `by_name` method instead.
944
+
945
+ Assertion.by_name(:empty) #=> ::EmptyAssay
946
+
947
+ We can also use the `Assay.lookup` module method, which will lookup an assay
948
+ class by either assertion name or associated operator.
949
+
950
+ Assay.lookup(:==) #=> ::EqualAssay
951
+ Assay.lookup(:empty?) #=> ::EmptyAssay
952
+
953
+
954
+ # Assay as Assertor
955
+
956
+ Assay classes can be converted to assertors, otherwise known as *matchers* in
957
+ RSpec circles. The idea behind Assertors is that they can be initialized with
958
+ pre-set criteria and then applied to target subjects.
959
+
960
+ ## Standard Target Matching
961
+
962
+ assertor = EqualAssay[1]
963
+
964
+ assertor.assert!(1)
965
+
966
+ expect EqualAssay do
967
+ assertor.assert!(2)
968
+ end
969
+
970
+ ## Partial Arguments
971
+
972
+ assertor = LessAssay[1,__]
973
+
974
+ We can apply the assertor using the `#pass!` method.
975
+
976
+ assertor.assert!(2)
977
+
978
+ Likewise we can assert the negated expression using `#fail!`.
979
+
980
+ assertor.refute!(0)
981
+
982
+ Assay partial a very versile because they allow any argument to become
983
+ the target of a assertor.
984
+
985
+ assertor = CompareAssay[2,1,__]
986
+
987
+ assertor.assert!(1)
988
+ assertor.refute!(0)
989
+
990
+ ## Match Operator
991
+
992
+ The `#=~` method is an alias for `#assert!`.
993
+
994
+ assertor = EqualAssay[1]
995
+ assertor =~ 1
996
+
997
+ Conversely, `#!~` method is an alias for `#refute!`.
998
+
999
+ assertor !~ 2
1000
+
1001
+ ## Case Operator
1002
+
1003
+ The `#===` method is also an alias for `#assert!`.
1004
+
1005
+ assertor === 1
1006
+
1007
+ This allows the `case` statement to be used in an intersting way.
1008
+
1009
+ case 10
1010
+ when KindAssay[Numeric]
1011
+ when EqualAssay[10.0]
1012
+ end
1013
+
1014
+ ## Negated Assertors
1015
+
1016
+ Assertors can also be negated so that pass and fail methods swap behaviors.
1017
+
1018
+ assertor = EqualityAssay[1]
1019
+
1020
+ assertor.not =~ 2
1021
+ assertor.not !~ 1
1022
+
1023
+ For conveience we can also negate the assertor using the `~` unary operator.
1024
+
1025
+ !assertor === 2
1026
+
1027
+ ## Just Cheking
1028
+
1029
+ Assertors can also be used just to test the assertion without actually
1030
+ raising the associated exception.
1031
+
1032
+ assertor = EqualityAssay[__,1]
1033
+
1034
+ assertor.pass?(1)
1035
+ assertor.fail?(2)
1036
+
1037
+ ## RSpec Compatability
1038
+
1039
+ RSpec compatibality is provided via neccessary method alias, in particular
1040
+ `#matches?` and `#does_not_match?`.
1041
+
1042
+ assertor = EqualityAssay[__,1]
1043
+
1044
+ assert assertor.matches?(1)
1045
+ assert assertor.does_not_match?(2)
1046
+
1047
+ Error messages are handle by RSpec by `#failure_message_for_should` and
1048
+ `#failure_message_for_should_not`.
1049
+
1050
+ assertor.failure_message_for_should(1)
1051
+ assertor.failure_message_for_should_not(2)
1052
+
1053
+
1054
+ # Assay Class Methods
1055
+
1056
+ ## Metadata
1057
+
1058
+ Assay support full project metadata access thanks to the `.ruby`
1059
+ standard.
1060
+
1061
+ Assay.metadata['name'] #=> 'assay'
1062
+
1063
+ The metadata also dynamically translates into constants, so we
1064
+ can work with this information in the traditional fashion.
1065
+
1066
+ Assay::NAME #=> 'assay'
1067
+
1068
+ ## Color Messages
1069
+
1070
+ We can have some Assay error messages use ANSI color output by
1071
+ setting the `Assay.color` setting to `true`.
1072
+
1073
+ Assay.color = true
1074
+
1075
+ Keep in mind that this requires the `ansi` library.
1076
+
1077
+ In particular it is the equality related assertions that utilize color
1078
+ output when the objects compared are large. This helps the developer
1079
+ pinpint the differences quickly.
1080
+
1081
+ expect EqualAssay do
1082
+ EqualAssay['really long string'] === 'other string'
1083
+ end
1084
+
1085
+ ## Lookup Assay Classes
1086
+
1087
+ Assay tracks all created Assay classes by both associated operation
1088
+ and assertive name.
1089
+
1090
+ Assay.lookup_by_operator(:==) #=> EqualAssay
1091
+
1092
+ Assay.lookup_by_name(:equal) #=> EqualAssay
1093
+
1094
+ We can look for either with just `lookup`.
1095
+
1096
+ Assay.lookup(:==) #=> EqualAssay
1097
+ Assay.lookup(:equal) #=> EqualAssay
1098
+
1099
+
1100
+