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,484 @@
1
+ module Assay; end
2
+ module Assay::TestUnit
3
+
4
+ # This module holds the Test::Unit assertion methods for Test::Unit
5
+ # compatibility.
6
+ #
7
+ # While it does not provide 100% of Test::Unit assertions at the moment,
8
+ # compatibility will improved with upcoming releases.
9
+ #
10
+ # @see http://test-unit.rubyforge.org/test-unit/en/
11
+ #
12
+ # @todo Should we adjust error message to be like Test::Units ?
13
+ #
14
+ module Assertions
15
+
16
+ #
17
+ #def assert_alias_method(object, alias_name, original_name, message = nil)
18
+ #end
19
+
20
+ #
21
+ # Passes if actual is like expected, where `like` means satisfyin any one
22
+ # of `#===`, `#==`, `#eql?` or `#equal?` calls.
23
+ #
24
+ # This is not strictly a Test::Unit assertion but is added here to cover
25
+ # all of Assay's availabe assertion classes.
26
+ #
27
+ def assert_alike(exp, act, msg=nil)
28
+ LikeAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
29
+ end
30
+
31
+ #
32
+ # Passes if actual is NOT like expected, where `like` means satisfyin any
33
+ # one of `#===`, `#==`, `#eql?` or `#equal?` calls.
34
+ #
35
+ def assert_not_alike(exp, act, msg=nil)
36
+ LikeAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
37
+ end
38
+
39
+ #
40
+ #
41
+ #
42
+ def assert_block(message="assert_block failed.", &block)
43
+ ExecutionAssay.assert!(:message=>message, &block)
44
+ end
45
+
46
+ #
47
+ # Passes if `boolean` is either `true` or `false`.
48
+ #
49
+ def assert_boolean(boolean, message=nil)
50
+ BooleanAssay.assert!(boolean, :message=>message)
51
+ end
52
+
53
+ #
54
+ # Passes if `boolean` is not either `true` or `false`.
55
+ #
56
+ def assert_not_boolean(boolean, message=nil)
57
+ BooleanAssay.refute!(boolean, :message=>message)
58
+ end
59
+
60
+ # Passes if `object` satisify compaision by `operator`.
61
+ #
62
+ def assert_compare(receiver, operator, operand, message=nil)
63
+ case operator.to_sym
64
+ when :<
65
+ LessAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
66
+ when :<=
67
+ LessEqualAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
68
+ when :>
69
+ MoreAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
70
+ when :>=
71
+ MoreEqualAssay.assert!(receiver, operand, :message=>message, :backtrace=>caller)
72
+ when :==
73
+ EqualAssay.assert!(operand, receiver, :message=>message, :backtrace=>caller)
74
+ else
75
+ raise ArgumentError, "comparision operator must be one of <, <=, >, >= or '=='"
76
+ end
77
+ end
78
+
79
+ #
80
+ #
81
+ #
82
+ #def assert_const_defined(object, constant_name, message=nil)
83
+ #end
84
+
85
+ #
86
+ #
87
+ #
88
+ #def assert_not_const_defined(object, constant_name, message=nil)
89
+ #end
90
+
91
+ # Passes if object is empty.
92
+ #
93
+ # assert_empty(object)
94
+ #
95
+ def assert_empty(exp, msg=nil)
96
+ EmptyAssay.assert!(exp, :message=>msg, :backtrace=>caller)
97
+ end
98
+
99
+ # Passes if object is not empty.
100
+ #
101
+ # refute_empty(object)
102
+ #
103
+ def assert_not_empty(exp, msg=nil)
104
+ EmptyAssay.refute!(exp, :message=>msg, :backtrace=>caller)
105
+ end
106
+
107
+ # Passes if expected == +actual.
108
+ #
109
+ # Note that the ordering of arguments is important,
110
+ # since a helpful error message is generated when this
111
+ # one fails that tells you the values of expected and actual.
112
+ #
113
+ # assert_equal 'MY STRING', 'my string'.upcase
114
+ #
115
+ def assert_equal(exp, act, msg=nil)
116
+ EqualAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
117
+ end
118
+
119
+ # Passes if expected != actual
120
+ #
121
+ # assert_not_equal 'some string', 5
122
+ #
123
+ def assert_not_equal(exp, act, msg=nil)
124
+ EqualAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
125
+ end
126
+
127
+ #
128
+ #def assert_fail_assertion(message = nil)
129
+ #end
130
+
131
+ #
132
+ # Passed if object is +false+.
133
+ #
134
+ # assert_false(false)
135
+ #
136
+ def assert_false(exp, msg=nil)
137
+ FalseAssay.assert!(exp, :message=>msg, :backtrace=>caller)
138
+ end
139
+
140
+ #
141
+ # Passed if object is not +false+.
142
+ #
143
+ # assert_not_false(false)
144
+ #
145
+ def assert_not_false(exp, msg=nil)
146
+ FalseAssay.refute!(exp, :message=>msg, :backtrace=>caller)
147
+ end
148
+
149
+ #
150
+ # Passes if expected and actual are equal within `delta` absolte tolerance.
151
+ #
152
+ # assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
153
+ #
154
+ def assert_in_delta(exp, act, delta, msg=nil)
155
+ WithinAssay.assert!(act, exp, delta, :message=>msg, :backtrace=>caller)
156
+ end
157
+
158
+ #
159
+ # Passes if expected and actual are NOT equal within `delta` absolute tolerance.
160
+ #
161
+ # assert_not_in_delta 0.05, (50000.0 / 10**6), 0.00001
162
+ #
163
+ def assert_not_in_delta(exp, act, delta, msg=nil)
164
+ WithinAssay.refute!(act, exp, delta, :message=>msg, :backtrace=>caller)
165
+ end
166
+
167
+ #
168
+ # Passes if `exp` and `act` are within `epsilon` relative tolerance.
169
+ #
170
+ def assert_in_epsilon(exp, act, epsilon=0.001, message=nil)
171
+ exp = epsilon if exp.zero? # why does minitest do this?
172
+ CloseAssay.assert!(act, exp, epsilon, :message=>message, :backtrace=>caller)
173
+ end
174
+
175
+ #
176
+ # Passes if `exp` and `act` are NOT within `epsilon` relative tolerance.
177
+ #
178
+ def assert_not_in_epsilon(exp, act, epsilon=0.001, message=nil)
179
+ exp = epsilon if exp.zero?
180
+ CloseAssay.refute!(act, exp, epsilon, :message=>message, :backtrace=>caller)
181
+ end
182
+
183
+ #
184
+ # Passes if `collection` contains `member`.
185
+ #
186
+ def assert_includes(collection, member, message=nil)
187
+ IncludeAssay.assert!(collection, member, :message=>message, :backtrace=>caller)
188
+ end
189
+
190
+ #
191
+ # Passes if `collection` does not contain `member`.
192
+ #
193
+ def assert_not_includes(collection, member, message=nil)
194
+ IncludeAssay.refute!(collection, member, :message=>message, :backtrace=>caller)
195
+ end
196
+
197
+ #
198
+ # Passes if object is an instance of class.
199
+ #
200
+ # assert_instance_of(String, 'foo')
201
+ #
202
+ def assert_instance_of(cls, obj, msg=nil)
203
+ InstanceAssay.assert!(obj, cls, :message=>msg, :backtrace=>caller)
204
+ end
205
+
206
+ #
207
+ # Passes if object is not an instance of class.
208
+ #
209
+ # assert_not_instance_of(String, 500)
210
+ #
211
+ def assert_not_instance_of(cls, obj, msg=nil)
212
+ InstanceAssay.refute!(obj, cls, :message=>msg, :backtrace=>caller)
213
+ end
214
+
215
+ #
216
+ # Passes if object .kind_of? klass
217
+ #
218
+ # assert_kind_of(Object, 'foo')
219
+ #
220
+ def assert_kind_of(cls, obj, msg=nil)
221
+ KindAssay.assert!(obj, cls, :message=>msg, :backtrace=>caller)
222
+ end
223
+
224
+ #
225
+ # Passes if object .kind_of? klass
226
+ #
227
+ # assert_not_kind_of(Object, 'foo')
228
+ #
229
+ def assert_not_kind_of(cls, obj, msg=nil)
230
+ KindAssay.refute!(obj, cls, :message=>msg, :backtrace=>caller)
231
+ end
232
+
233
+ # Passes if object matches pattern using `#=~` method.
234
+ #
235
+ # assert_match(/\d+/, 'five, 6, seven')
236
+ #
237
+ def assert_match(pattern, string, msg=nil)
238
+ MatchAssay.assert!(string, pattern, :message=>msg, :backtrace=>caller)
239
+ end
240
+
241
+ # Passes if object does not match pattern using `#=~` method.
242
+ #
243
+ # assert_no_match(/two/, 'one 2 three')
244
+ #
245
+ def assert_not_match(pattern, string, msg=nil)
246
+ MatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)
247
+ end
248
+
249
+ # Passes if object has no match pattern using `#!~` method.
250
+ #
251
+ # assert_no_match(/two/, 'one 2 three')
252
+ #
253
+ def assert_no_match(pattern, string, msg=nil)
254
+ NoMatchAssay.assert!(string, pattern, :message=>msg, :backtrace=>caller)
255
+ end
256
+
257
+ ## Passes if object has a match pattern using `#!~` method.
258
+ ##
259
+ ## assert_not_no_match(/two/, 'one two three')
260
+ ##
261
+ #def assert_not_no_match(pattern, string, msg=nil)
262
+ # NoMatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)
263
+ #end
264
+
265
+ # Passed if object is +nil+.
266
+ #
267
+ # assert_nil(nil)
268
+ #
269
+ def assert_nil(exp, msg=nil)
270
+ NilAssay.assert!(exp, :message=>msg, :backtrace=>caller)
271
+ end
272
+
273
+ # Passed if object is not +nil+.
274
+ #
275
+ # assert_not_nil(true)
276
+ #
277
+ def assert_not_nil(exp, msg=nil)
278
+ NilAssay.refute!(exp, :message=>msg, :backtrace=>caller)
279
+ end
280
+
281
+ #
282
+ #
283
+ #
284
+ def assert_predicate(object, predicate, message = nil)
285
+ ExecutionAssay.assert!(:message=>message) do
286
+ object.__send__(predicate)
287
+ end
288
+ end
289
+
290
+ #
291
+ #
292
+ #
293
+ def assert_not_predicate(object, predicate, message = nil)
294
+ ExecutionAssay.refute!(:message=>message) do
295
+ object.__send__(predicate)
296
+ end
297
+ end
298
+
299
+ #
300
+ # Passes if +object+ respond_to? +methods+.
301
+ #
302
+ # assert_respond_to 'bugbear', :slice
303
+ #
304
+ def assert_respond_to(reciever, method, msg=nil)
305
+ RespondAssay.assert!(reciever, method, :message=>msg, :backtrace=>caller)
306
+ end
307
+ alias_method :assert_responds_to, :assert_respond_to
308
+
309
+ #
310
+ # Passes if +object+ does not respond_to? +methods+.
311
+ #
312
+ # assert_not_respond_to 'bugbear', :slice
313
+ #
314
+ def assert_not_respond_to(reciever, method, msg=nil)
315
+ RespondAssay.refute!(reciever, method, :message=>msg, :backtrace=>caller)
316
+ end
317
+
318
+ # Passes if +expected+ .eql? +actual+.
319
+ #
320
+ # Note that the ordering of arguments is important,
321
+ # since a helpful error message is generated when this
322
+ # one fails that tells you the values of expected and actual.
323
+ #
324
+ # assert_equivalent 'MY STRING', 'my string'.upcase
325
+ #
326
+ def assert_equivalent(exp, act, msg=nil)
327
+ EqualityAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
328
+ end
329
+
330
+ # Passes if +criterion+ is NOT equivalent to +actual+ as tested using `#eql?`.
331
+ #
332
+ # assert_not_equivalent 1, 1.0
333
+ #
334
+ def assert_not_equivalent(criterion, act, msg=nil)
335
+ EqualityAssay.refute!(act, criterion, :message=>msg, :backtrace=>caller)
336
+ end
337
+
338
+ #
339
+ #
340
+ # TODO: Is this supposed to be restricted in some way?
341
+ def assert_operator(receiver, operator, operand, message=nil)
342
+ ExecutionAssay.assert!(:message=>message, :backtrace=>caller) do
343
+ receiver.__send__(operator, operand)
344
+ end
345
+ end
346
+
347
+ #
348
+ #
349
+ #
350
+ def assert_path_exist(path, message=nil)
351
+ PathAssay.assert!(path, :message=>message, :backtrace=>caller)
352
+ end
353
+
354
+ #
355
+ #
356
+ #
357
+ def assert_path_not_exist(path, message=nil)
358
+ PathAssay.refute!(path, :message=>message, :backtrace=>caller)
359
+ end
360
+
361
+ #
362
+ # Passes if the block raises a given exception.
363
+ #
364
+ # assert_raise RuntimeError do
365
+ # raise 'Boom!!!'
366
+ # end
367
+ #
368
+ def assert_raise(exception, message=nil, &block)
369
+ RaiseAssay.assert!(exception, :message=>message, :backtrace=>caller, &block)
370
+ end
371
+
372
+ alias_method :assert_raises, :assert_raise
373
+
374
+ #
375
+ # Passes if the block *does not* raise a given exceptions.
376
+ #
377
+ # assert_not_raised IOError do
378
+ # raise 'Boom!!!'
379
+ # end
380
+ #
381
+ def assert_not_raised(exception, message=nil, &block) #:yeild:
382
+ RaiseAssay.refute!(exception, :message=>message, :backtrace=>caller, &block)
383
+ end
384
+
385
+ #
386
+ # Passes if the block yields successfully.
387
+ #
388
+ # assert_nothing_raised "Couldn't do the thing" do
389
+ # do_the_thing
390
+ # end
391
+ #
392
+ def assert_nothing_raised(message=nil, &block)
393
+ RescueAssay.refute!(Exception, :message=>message, :backtrace=>caller, &block)
394
+ end
395
+
396
+ #
397
+ # Passes if the block raises a given exception.
398
+ #
399
+ # assert_raise_kind_of RuntimeError do
400
+ # raise 'Boom!!!'
401
+ # end
402
+ #
403
+ def assert_raise_kind_of(exception_class, message=nil, &block)
404
+ RescueAssay.assert!(exception_class, :message=>message, :backtrace=>caller, &block)
405
+ end
406
+
407
+ #
408
+ #def assert_raise_message(*args, &block)
409
+ #end
410
+
411
+ #
412
+ # Passes if actual is the same exact object as expected.
413
+ #
414
+ # assert_same(object, object)
415
+ #
416
+ def assert_same(exp, act, msg=nil)
417
+ IdentityAssay.assert!(act, exp, :message=>msg, :backtrace=>caller)
418
+ end
419
+
420
+ #
421
+ # Passes if actual is not the same exact object as expected.
422
+ #
423
+ # assert_not_same(object, other)
424
+ #
425
+ def assert_not_same(exp, act, msg=nil)
426
+ IdentityAssay.refute!(act, exp, :message=>msg, :backtrace=>caller)
427
+ end
428
+
429
+ #
430
+ #
431
+ #
432
+ #def assert_send(send_array, message=nil)
433
+ #end
434
+
435
+ #
436
+ # Passes if the block throws `expected` object.
437
+ #
438
+ # assert_throw :done do
439
+ # throw :done
440
+ # end
441
+ #
442
+ def assert_throw(expected, msg=nil, &blk)
443
+ ThrowAssay.assert!(expected, :message=>msg, :backtrace=>caller, &blk)
444
+ end
445
+
446
+ alias_method :assert_throws, :assert_throw
447
+
448
+ #
449
+ # Passes if the block does not throws `expected` object.
450
+ #
451
+ # assert_not_thrown :done do
452
+ # throw :chimp
453
+ # end
454
+ #
455
+ def assert_not_thrown(expected, msg=nil, &blk)
456
+ ThrowAssay.refute!(expected, :message=>msg, :backtrace=>caller, &blk)
457
+ end
458
+
459
+ #
460
+ #
461
+ #
462
+ def assert_nothing_thrown(message=nil, &blk)
463
+ ThrowAssay.refute!(nil, :message=>message, &blk)
464
+ end
465
+
466
+ #
467
+ # Passed if object is +true+.
468
+ #
469
+ def assert_true(exp, msg=nil)
470
+ TrueAssay.assert!(exp, :message=>msg, :backtrace=>caller)
471
+ end
472
+
473
+ #
474
+ # Passed if object is not +true+.
475
+ #
476
+ # assert_not_true(false)
477
+ #
478
+ def assert_not_true(exp, msg=nil)
479
+ TrueAssay.refute!(exp, :message=>msg, :backtrace=>caller)
480
+ end
481
+
482
+ end
483
+
484
+ end
@@ -0,0 +1,9 @@
1
+ require_relative '../assay'
2
+
3
+ require_relative 'testunit/assertions'
4
+
5
+ # Test::Unit-compatible assertion methods (`assert_equal`, ...), to mix
6
+ # into a test scope.
7
+ module Assay::Assertions
8
+ include Assay::TestUnit::Assertions
9
+ end
@@ -0,0 +1,3 @@
1
+ module Assay
2
+ VERSION = '0.5.0'
3
+ end
data/lib/assay.rb CHANGED
@@ -1,30 +1,16 @@
1
+ # Assay (https://github.com/rubyworks/assay)
2
+ # Copyright (c) 2010 Rubyworks. License (spdx) BSD-2-Clause.
3
+
4
+ require_relative 'assay/version'
5
+
1
6
  # Load Assay's assertion classes.
2
7
  require_relative 'assay/assertion'
3
- dir = File.dirname(__FILE__) + '/assay'
4
- Dir.entries(dir).each do |file|
5
- next if File.extname(file) != '.rb'
6
- require_relative 'assay/' + file
8
+ Dir[File.join(__dir__, 'assay', '*_assay.rb')].sort.each do |file|
9
+ require_relative 'assay/' + File.basename(file, '.rb')
7
10
  end
8
11
 
9
12
  module Assay
10
13
 
11
- #
12
- # Returns Hash table of project metadata.
13
- #
14
- def self.metadata
15
- @spec ||= (
16
- require 'yaml'
17
- YAML.load(File.new(File.dirname(__FILE__) + '/assay.yml'))
18
- )
19
- end
20
-
21
- #
22
- # Check metadata for missing constants.
23
- #
24
- def self.const_missing(name)
25
- metadata[name.to_s.downcase] || super(name)
26
- end
27
-
28
14
  #
29
15
  # Returns a list of Assertion subclasses.
30
16
  #