minitest 2.9.1 → 2.10.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.
- data.tar.gz.sig +0 -0
- data/.autotest +4 -3
- data/History.txt +12 -0
- data/Manifest.txt +0 -2
- data/lib/minitest/spec.rb +2 -2
- data/lib/minitest/unit.rb +1 -1
- data/test/test_minitest_spec.rb +280 -152
- data/test/test_minitest_unit.rb +20 -0
- metadata +15 -18
- metadata.gz.sig +0 -0
- data/lib/minitest/excludes.rb +0 -76
- data/test/test_minitest_excludes.rb +0 -54
data.tar.gz.sig
CHANGED
Binary file
|
data/.autotest
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'autotest/restart'
|
4
|
+
require 'autotest/rcov'
|
4
5
|
|
5
6
|
Autotest.add_hook :initialize do |at|
|
6
7
|
at.testlib = 'minitest/unit'
|
7
8
|
|
8
|
-
at.extra_class_map["MiniTest::Spec"]
|
9
|
-
at.extra_class_map["
|
10
|
-
at.extra_class_map["TestMiniTestUnit"]
|
9
|
+
at.extra_class_map["MiniTest::Spec"] = "test/test_minitest_spec.rb"
|
10
|
+
at.extra_class_map["TestMiniTestUnitTestCase"] = "test/test_minitest_unit.rb"
|
11
|
+
at.extra_class_map["TestMiniTestUnit"] = "test/test_minitest_unit.rb"
|
11
12
|
at.add_exception 'coverage.info'
|
12
13
|
at.add_exception 'coverage'
|
13
14
|
end
|
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 2.10.0 / 2011-12-20
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
|
5
|
+
* Added specs for must/wont be_empty/respond_to/be_kind_of and others.
|
6
|
+
* Added tests for assert/refute predicate.
|
7
|
+
* Split minitest/excludes.rb out to its own gem.
|
8
|
+
|
9
|
+
* 1 bug fix:
|
10
|
+
|
11
|
+
* Fixed must_be_empty and wont_be_empty argument handling. (mrsimo)
|
12
|
+
|
1
13
|
=== 2.9.1 / 2011-12-13
|
2
14
|
|
3
15
|
* 4 minor enhancements:
|
data/Manifest.txt
CHANGED
@@ -7,14 +7,12 @@ design_rationale.rb
|
|
7
7
|
lib/hoe/minitest.rb
|
8
8
|
lib/minitest/autorun.rb
|
9
9
|
lib/minitest/benchmark.rb
|
10
|
-
lib/minitest/excludes.rb
|
11
10
|
lib/minitest/mock.rb
|
12
11
|
lib/minitest/pride.rb
|
13
12
|
lib/minitest/spec.rb
|
14
13
|
lib/minitest/unit.rb
|
15
14
|
test/metametameta.rb
|
16
15
|
test/test_minitest_benchmark.rb
|
17
|
-
test/test_minitest_excludes.rb
|
18
16
|
test/test_minitest_mock.rb
|
19
17
|
test/test_minitest_spec.rb
|
20
18
|
test/test_minitest_unit.rb
|
data/lib/minitest/spec.rb
CHANGED
@@ -257,7 +257,7 @@ module MiniTest::Expectations
|
|
257
257
|
#
|
258
258
|
# :method: must_be_empty
|
259
259
|
|
260
|
-
infect_an_assertion :assert_empty, :must_be_empty
|
260
|
+
infect_an_assertion :assert_empty, :must_be_empty, :unary
|
261
261
|
|
262
262
|
##
|
263
263
|
# See MiniTest::Assertions#assert_equal
|
@@ -417,7 +417,7 @@ module MiniTest::Expectations
|
|
417
417
|
#
|
418
418
|
# :method: wont_be_empty
|
419
419
|
|
420
|
-
infect_an_assertion :refute_empty, :wont_be_empty
|
420
|
+
infect_an_assertion :refute_empty, :wont_be_empty, :unary
|
421
421
|
|
422
422
|
##
|
423
423
|
# See MiniTest::Assertions#refute_equal
|
data/lib/minitest/unit.rb
CHANGED
data/test/test_minitest_spec.rb
CHANGED
@@ -28,8 +28,78 @@ describe MiniTest::Spec do
|
|
28
28
|
self._assertions.must_equal @assertion_count
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
it "needs to be able to catch a MiniTest::Assertion exception" do
|
32
|
+
@assertion_count = 1
|
33
|
+
|
34
|
+
assert_triggered "Expected 1 to not be equal to 1." do
|
35
|
+
1.wont_equal 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "needs to be sensible about must_include order" do
|
40
|
+
@assertion_count += 3 # must_include is 2 assertions
|
41
|
+
|
42
|
+
[1, 2, 3].must_include(2).must_equal true
|
43
|
+
|
44
|
+
assert_triggered "Expected [1, 2, 3] to include 5." do
|
45
|
+
[1, 2, 3].must_include 5
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_triggered "msg.\nExpected [1, 2, 3] to include 5." do
|
49
|
+
[1, 2, 3].must_include 5, "msg"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "needs to be sensible about wont_include order" do
|
54
|
+
@assertion_count += 3 # wont_include is 2 assertions
|
55
|
+
|
56
|
+
[1, 2, 3].wont_include(5).must_equal false
|
57
|
+
|
58
|
+
assert_triggered "Expected [1, 2, 3] to not include 2." do
|
59
|
+
[1, 2, 3].wont_include 2
|
60
|
+
end
|
61
|
+
|
62
|
+
assert_triggered "msg.\nExpected [1, 2, 3] to not include 2." do
|
63
|
+
[1, 2, 3].wont_include 2, "msg"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "needs to catch an expected exception" do
|
68
|
+
@assertion_count = 2
|
69
|
+
|
70
|
+
proc { raise "blah" }.must_raise RuntimeError
|
71
|
+
proc { raise MiniTest::Assertion }.must_raise MiniTest::Assertion
|
72
|
+
end
|
73
|
+
|
74
|
+
it "needs to catch an unexpected exception" do
|
75
|
+
@assertion_count -= 2 # no positive
|
76
|
+
|
77
|
+
msg = <<-EOM.gsub(/^ {6}/, '').chomp
|
78
|
+
[RuntimeError] exception expected, not
|
79
|
+
Class: <MiniTest::Assertion>
|
80
|
+
Message: <\"MiniTest::Assertion\">
|
81
|
+
---Backtrace---
|
82
|
+
EOM
|
83
|
+
|
84
|
+
assert_triggered msg do
|
85
|
+
proc { raise MiniTest::Assertion }.must_raise RuntimeError
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_triggered "msg.\n#{msg}" do
|
89
|
+
proc { raise MiniTest::Assertion }.must_raise RuntimeError, "msg"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "needs to ensure silence" do
|
94
|
+
@assertion_count -= 1 # no msg
|
95
|
+
@assertion_count += 2 # assert_output is 2 assertions
|
96
|
+
|
97
|
+
proc { }.must_be_silent.must_equal true
|
98
|
+
|
99
|
+
assert_triggered "In stdout.\nExpected: \"\"\n Actual: \"xxx\"" do
|
100
|
+
proc { print "xxx" }.must_be_silent
|
101
|
+
end
|
102
|
+
end
|
33
103
|
|
34
104
|
it "needs to have all methods named well" do
|
35
105
|
@assertion_count = 2
|
@@ -67,6 +137,44 @@ describe MiniTest::Spec do
|
|
67
137
|
wonts.must_equal expected_wonts
|
68
138
|
end
|
69
139
|
|
140
|
+
it "needs to raise if an expected exception is not raised" do
|
141
|
+
@assertion_count -= 2 # no positive test
|
142
|
+
|
143
|
+
assert_triggered "RuntimeError expected but nothing was raised." do
|
144
|
+
proc { 42 }.must_raise RuntimeError
|
145
|
+
end
|
146
|
+
|
147
|
+
assert_triggered "msg.\nRuntimeError expected but nothing was raised." do
|
148
|
+
proc { 42 }.must_raise RuntimeError, "msg"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "needs to verify binary messages" do
|
153
|
+
42.wont_be(:<, 24).must_equal false
|
154
|
+
|
155
|
+
assert_triggered 'Expected 24 to not be < 42.' do
|
156
|
+
24.wont_be :<, 42
|
157
|
+
end
|
158
|
+
|
159
|
+
assert_triggered "msg.\nExpected 24 to not be < 42." do
|
160
|
+
24.wont_be :<, 42, "msg"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "needs to verify emptyness" do
|
165
|
+
@assertion_count += 3 # empty is 2 assertions
|
166
|
+
|
167
|
+
[].must_be_empty.must_equal true
|
168
|
+
|
169
|
+
assert_triggered "Expected [42] to be empty." do
|
170
|
+
[42].must_be_empty
|
171
|
+
end
|
172
|
+
|
173
|
+
assert_triggered "msg.\nExpected [42] to be empty." do
|
174
|
+
[42].must_be_empty "msg"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
70
178
|
it "needs to verify equality" do
|
71
179
|
(6 * 7).must_equal(42).must_equal true
|
72
180
|
|
@@ -79,6 +187,42 @@ describe MiniTest::Spec do
|
|
79
187
|
end
|
80
188
|
end
|
81
189
|
|
190
|
+
it "needs to verify floats outside a delta" do
|
191
|
+
@assertion_count += 1 # extra test
|
192
|
+
|
193
|
+
24.wont_be_close_to(42).must_equal false
|
194
|
+
|
195
|
+
assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.001.' do
|
196
|
+
(6 * 7.0).wont_be_close_to 42
|
197
|
+
end
|
198
|
+
|
199
|
+
assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 1.0e-05.' do
|
200
|
+
(6 * 7.0).wont_be_close_to 42, 0.00001
|
201
|
+
end
|
202
|
+
|
203
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < 1.0e-05." do
|
204
|
+
(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it "needs to verify floats outside an epsilon" do
|
209
|
+
@assertion_count += 1 # extra test
|
210
|
+
|
211
|
+
24.wont_be_within_epsilon(42).must_equal false
|
212
|
+
|
213
|
+
assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.042.' do
|
214
|
+
(6 * 7.0).wont_be_within_epsilon 42
|
215
|
+
end
|
216
|
+
|
217
|
+
assert_triggered 'Expected |42 - 42.0| (0.0) to not be < 0.00042.' do
|
218
|
+
(6 * 7.0).wont_be_within_epsilon 42, 0.00001
|
219
|
+
end
|
220
|
+
|
221
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be < 0.00042." do
|
222
|
+
(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
82
226
|
it "needs to verify floats within a delta" do
|
83
227
|
@assertion_count += 1 # extra test
|
84
228
|
|
@@ -97,17 +241,69 @@ describe MiniTest::Spec do
|
|
97
241
|
end
|
98
242
|
end
|
99
243
|
|
100
|
-
it "needs to verify
|
101
|
-
|
244
|
+
it "needs to verify floats within an epsilon" do
|
245
|
+
@assertion_count += 1 # extra test
|
102
246
|
|
103
|
-
|
247
|
+
(6.0 * 7).must_be_within_epsilon(42.0).must_equal true
|
104
248
|
|
105
|
-
assert_triggered
|
106
|
-
(
|
249
|
+
assert_triggered 'Expected |0.0 - 0.01| (0.01) to be < 0.0.' do
|
250
|
+
(1.0 / 100).must_be_within_epsilon 0.0
|
107
251
|
end
|
108
252
|
|
109
|
-
assert_triggered
|
110
|
-
(
|
253
|
+
assert_triggered 'Expected |0.0 - 0.001| (0.001) to be < 0.0.' do
|
254
|
+
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001
|
255
|
+
end
|
256
|
+
|
257
|
+
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be < 0.0." do
|
258
|
+
(1.0 / 1000).must_be_within_epsilon 0.0, 0.000001, "msg"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
it "needs to verify identity" do
|
263
|
+
1.must_be_same_as(1).must_equal true
|
264
|
+
|
265
|
+
assert_triggered "Expected 1 (oid=N) to be the same as 2 (oid=N)." do
|
266
|
+
1.must_be_same_as 2
|
267
|
+
end
|
268
|
+
|
269
|
+
assert_triggered "msg.\nExpected 1 (oid=N) to be the same as 2 (oid=N)." do
|
270
|
+
1.must_be_same_as 2, "msg"
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
it "needs to verify inequality" do
|
275
|
+
42.wont_equal(6 * 9).must_equal false
|
276
|
+
|
277
|
+
assert_triggered "Expected 1 to not be equal to 1." do
|
278
|
+
1.wont_equal 1
|
279
|
+
end
|
280
|
+
|
281
|
+
assert_triggered "msg.\nExpected 1 to not be equal to 1." do
|
282
|
+
1.wont_equal 1, "msg"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
it "needs to verify instances of a class" do
|
287
|
+
42.wont_be_instance_of(String).must_equal false
|
288
|
+
|
289
|
+
assert_triggered 'Expected 42 to not be an instance of Fixnum.' do
|
290
|
+
42.wont_be_instance_of Fixnum
|
291
|
+
end
|
292
|
+
|
293
|
+
assert_triggered "msg.\nExpected 42 to not be an instance of Fixnum." do
|
294
|
+
42.wont_be_instance_of Fixnum, "msg"
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
it "needs to verify kinds of a class" do
|
299
|
+
42.wont_be_kind_of(String).must_equal false
|
300
|
+
|
301
|
+
assert_triggered 'Expected 42 to not be a kind of Integer.' do
|
302
|
+
42.wont_be_kind_of Integer
|
303
|
+
end
|
304
|
+
|
305
|
+
assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
|
306
|
+
42.wont_be_kind_of Integer, "msg"
|
111
307
|
end
|
112
308
|
end
|
113
309
|
|
@@ -126,17 +322,17 @@ describe MiniTest::Spec do
|
|
126
322
|
end
|
127
323
|
end
|
128
324
|
|
129
|
-
it "needs to verify
|
130
|
-
@assertion_count += 3 #
|
325
|
+
it "needs to verify mismatch" do
|
326
|
+
@assertion_count += 3 # match is 2
|
131
327
|
|
132
|
-
"blah".
|
328
|
+
"blah".wont_match(/\d+/).must_equal false
|
133
329
|
|
134
|
-
assert_triggered "Expected /\\
|
135
|
-
"blah".
|
330
|
+
assert_triggered "Expected /\\w+/ to not match \"blah\"." do
|
331
|
+
"blah".wont_match(/\w+/)
|
136
332
|
end
|
137
333
|
|
138
|
-
assert_triggered "msg.\nExpected /\\
|
139
|
-
"blah".
|
334
|
+
assert_triggered "msg.\nExpected /\\w+/ to not match \"blah\"." do
|
335
|
+
"blah".wont_match(/\w+/, "msg")
|
140
336
|
end
|
141
337
|
end
|
142
338
|
|
@@ -152,93 +348,87 @@ describe MiniTest::Spec do
|
|
152
348
|
end
|
153
349
|
end
|
154
350
|
|
155
|
-
it "needs to verify
|
156
|
-
@assertion_count
|
351
|
+
it "needs to verify non-emptyness" do
|
352
|
+
@assertion_count += 3 # empty is 2 assertions
|
157
353
|
|
158
|
-
|
354
|
+
['some item'].wont_be_empty.must_equal false
|
159
355
|
|
160
|
-
assert_triggered "Expected
|
161
|
-
|
356
|
+
assert_triggered "Expected [] to not be empty." do
|
357
|
+
[].wont_be_empty
|
162
358
|
end
|
163
|
-
end
|
164
|
-
|
165
|
-
it "needs to verify using any predicate" do
|
166
|
-
@assertion_count -= 1 # no msg
|
167
|
-
|
168
|
-
"".must_be(:empty?).must_equal true
|
169
359
|
|
170
|
-
assert_triggered "
|
171
|
-
"
|
360
|
+
assert_triggered "msg.\nExpected [] to not be empty." do
|
361
|
+
[].wont_be_empty "msg"
|
172
362
|
end
|
173
363
|
end
|
174
364
|
|
175
|
-
it "needs to
|
176
|
-
|
365
|
+
it "needs to verify non-identity" do
|
366
|
+
1.wont_be_same_as(2).must_equal false
|
177
367
|
|
178
|
-
|
179
|
-
|
180
|
-
|
368
|
+
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
369
|
+
1.wont_be_same_as 1
|
370
|
+
end
|
181
371
|
|
182
|
-
|
183
|
-
|
372
|
+
assert_triggered "msg.\nExpected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
373
|
+
1.wont_be_same_as 1, "msg"
|
374
|
+
end
|
375
|
+
end
|
184
376
|
|
185
|
-
|
186
|
-
|
187
|
-
Class: <MiniTest::Assertion>
|
188
|
-
Message: <\"MiniTest::Assertion\">
|
189
|
-
---Backtrace---
|
190
|
-
EOM
|
377
|
+
it "needs to verify non-nil" do
|
378
|
+
42.wont_be_nil.must_equal false
|
191
379
|
|
192
|
-
assert_triggered
|
193
|
-
|
380
|
+
assert_triggered "Expected nil to not be nil." do
|
381
|
+
nil.wont_be_nil
|
194
382
|
end
|
195
383
|
|
196
|
-
assert_triggered "msg.\
|
197
|
-
|
384
|
+
assert_triggered "msg.\nExpected nil to not be nil." do
|
385
|
+
nil.wont_be_nil "msg"
|
198
386
|
end
|
199
387
|
end
|
200
388
|
|
201
|
-
it "needs to
|
202
|
-
|
389
|
+
it "needs to verify objects not responding to a message" do
|
390
|
+
"".wont_respond_to(:woot!).must_equal false
|
203
391
|
|
204
|
-
assert_triggered "
|
205
|
-
|
392
|
+
assert_triggered 'Expected "" to not respond to to_s.' do
|
393
|
+
"".wont_respond_to :to_s
|
206
394
|
end
|
207
395
|
|
208
|
-
assert_triggered "msg.\
|
209
|
-
|
396
|
+
assert_triggered "msg.\nExpected \"\" to not respond to to_s." do
|
397
|
+
"".wont_respond_to :to_s, "msg"
|
210
398
|
end
|
211
399
|
end
|
212
400
|
|
213
|
-
it "needs to
|
214
|
-
@assertion_count
|
401
|
+
it "needs to verify output in stderr" do
|
402
|
+
@assertion_count -= 1 # no msg
|
215
403
|
|
216
|
-
|
217
|
-
|
404
|
+
proc { $stderr.print "blah" }.must_output(nil, "blah").must_equal true
|
405
|
+
|
406
|
+
assert_triggered "In stderr.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
407
|
+
proc { $stderr.print "xxx" }.must_output(nil, "blah")
|
218
408
|
end
|
219
409
|
end
|
220
410
|
|
221
|
-
it "needs to verify
|
222
|
-
|
411
|
+
it "needs to verify output in stdout" do
|
412
|
+
@assertion_count -= 1 # no msg
|
223
413
|
|
224
|
-
|
225
|
-
42.must_respond_to :clear
|
226
|
-
end
|
414
|
+
proc { print "blah" }.must_output("blah").must_equal true
|
227
415
|
|
228
|
-
assert_triggered "
|
229
|
-
|
416
|
+
assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
417
|
+
proc { print "xxx" }.must_output("blah")
|
230
418
|
end
|
231
419
|
end
|
232
420
|
|
233
|
-
it "needs to verify
|
234
|
-
|
421
|
+
it "needs to verify regexp matches" do
|
422
|
+
@assertion_count += 3 # must_match is 2 assertions
|
235
423
|
|
236
|
-
|
237
|
-
|
424
|
+
"blah".must_match(/\w+/).must_equal true
|
425
|
+
|
426
|
+
assert_triggered "Expected /\\d+/ to match \"blah\"." do
|
427
|
+
"blah".must_match(/\d+/)
|
238
428
|
end
|
239
429
|
|
240
|
-
assert_triggered "msg.\nExpected
|
241
|
-
|
430
|
+
assert_triggered "msg.\nExpected /\\d+/ to match \"blah\"." do
|
431
|
+
"blah".must_match(/\d+/, "msg")
|
242
432
|
end
|
243
433
|
end
|
244
434
|
|
@@ -264,29 +454,17 @@ describe MiniTest::Spec do
|
|
264
454
|
end
|
265
455
|
end
|
266
456
|
|
267
|
-
it "needs to verify
|
268
|
-
|
269
|
-
|
270
|
-
assert_triggered "Expected 1 to not be equal to 1." do
|
271
|
-
1.wont_equal 1
|
272
|
-
end
|
273
|
-
|
274
|
-
assert_triggered "msg.\nExpected 1 to not be equal to 1." do
|
275
|
-
1.wont_equal 1, "msg"
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
it "needs to verify mismatch" do
|
280
|
-
@assertion_count += 3 # match is 2
|
457
|
+
it "needs to verify types of objects" do
|
458
|
+
(6 * 7).must_be_instance_of(Fixnum).must_equal true
|
281
459
|
|
282
|
-
"
|
460
|
+
exp = "Expected 42 to be an instance of String, not Fixnum."
|
283
461
|
|
284
|
-
assert_triggered
|
285
|
-
|
462
|
+
assert_triggered exp do
|
463
|
+
(6 * 7).must_be_instance_of String
|
286
464
|
end
|
287
465
|
|
288
|
-
assert_triggered "msg.\
|
289
|
-
|
466
|
+
assert_triggered "msg.\n#{exp}" do
|
467
|
+
(6 * 7).must_be_instance_of String, "msg"
|
290
468
|
end
|
291
469
|
end
|
292
470
|
|
@@ -300,88 +478,38 @@ describe MiniTest::Spec do
|
|
300
478
|
end
|
301
479
|
end
|
302
480
|
|
303
|
-
it "needs to verify
|
304
|
-
42.wont_be_nil.must_equal false
|
305
|
-
|
306
|
-
assert_triggered "Expected nil to not be nil." do
|
307
|
-
nil.wont_be_nil
|
308
|
-
end
|
309
|
-
|
310
|
-
assert_triggered "msg.\nExpected nil to not be nil." do
|
311
|
-
nil.wont_be_nil "msg"
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
it "needs to verify non-identity" do
|
316
|
-
1.wont_be_same_as(2).must_equal false
|
317
|
-
|
318
|
-
assert_triggered "Expected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
319
|
-
1.wont_be_same_as 1
|
320
|
-
end
|
321
|
-
|
322
|
-
assert_triggered "msg.\nExpected 1 (oid=N) to not be the same as 1 (oid=N)." do
|
323
|
-
1.wont_be_same_as 1, "msg"
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
it "needs to verify output in stdout" do
|
328
|
-
@assertion_count -= 1 # no msg
|
329
|
-
|
330
|
-
proc { print "blah" }.must_output("blah").must_equal true
|
331
|
-
|
332
|
-
assert_triggered "In stdout.\nExpected: \"blah\"\n Actual: \"xxx\"" do
|
333
|
-
proc { print "xxx" }.must_output("blah")
|
334
|
-
end
|
335
|
-
end
|
336
|
-
|
337
|
-
it "needs to verify output in stderr" do
|
481
|
+
it "needs to verify using any binary operator" do
|
338
482
|
@assertion_count -= 1 # no msg
|
339
483
|
|
340
|
-
|
484
|
+
41.must_be(:<, 42).must_equal true
|
341
485
|
|
342
|
-
assert_triggered "
|
343
|
-
|
486
|
+
assert_triggered "Expected 42 to be < 41." do
|
487
|
+
42.must_be(:<, 41)
|
344
488
|
end
|
345
489
|
end
|
346
490
|
|
347
|
-
it "needs to
|
491
|
+
it "needs to verify using any predicate" do
|
348
492
|
@assertion_count -= 1 # no msg
|
349
|
-
@assertion_count += 2 # assert_output is 2 assertions
|
350
493
|
|
351
|
-
|
494
|
+
"".must_be(:empty?).must_equal true
|
352
495
|
|
353
|
-
assert_triggered "
|
354
|
-
|
496
|
+
assert_triggered "Expected \"blah\" to be empty?." do
|
497
|
+
"blah".must_be :empty?
|
355
498
|
end
|
356
499
|
end
|
357
500
|
|
358
|
-
it "needs to
|
359
|
-
|
360
|
-
|
361
|
-
[1, 2, 3].must_include(2).must_equal true
|
501
|
+
it "needs to verify using respond_to" do
|
502
|
+
42.must_respond_to(:+).must_equal true
|
362
503
|
|
363
|
-
assert_triggered "Expected
|
364
|
-
|
504
|
+
assert_triggered "Expected 42 (Fixnum) to respond to #clear." do
|
505
|
+
42.must_respond_to :clear
|
365
506
|
end
|
366
507
|
|
367
|
-
assert_triggered "msg.\nExpected
|
368
|
-
|
508
|
+
assert_triggered "msg.\nExpected 42 (Fixnum) to respond to #clear." do
|
509
|
+
42.must_respond_to :clear, "msg"
|
369
510
|
end
|
370
511
|
end
|
371
512
|
|
372
|
-
it "needs to be sensible about wont_include order" do
|
373
|
-
@assertion_count += 3 # wont_include is 2 assertions
|
374
|
-
|
375
|
-
[1, 2, 3].wont_include(5).must_equal false
|
376
|
-
|
377
|
-
assert_triggered "Expected [1, 2, 3] to not include 2." do
|
378
|
-
[1, 2, 3].wont_include 2
|
379
|
-
end
|
380
|
-
|
381
|
-
assert_triggered "msg.\nExpected [1, 2, 3] to not include 2." do
|
382
|
-
[1, 2, 3].wont_include 2, "msg"
|
383
|
-
end
|
384
|
-
end
|
385
513
|
end
|
386
514
|
|
387
515
|
describe MiniTest::Spec, :let do
|
data/test/test_minitest_unit.rb
CHANGED
@@ -945,6 +945,16 @@ class TestMiniTestUnitTestCase < MiniTest::Unit::TestCase
|
|
945
945
|
end
|
946
946
|
end
|
947
947
|
|
948
|
+
def test_assert_predicate
|
949
|
+
@tc.assert_predicate "", :empty?
|
950
|
+
end
|
951
|
+
|
952
|
+
def test_assert_predicate_triggered
|
953
|
+
util_assert_triggered 'Expected "blah" to be empty?.' do
|
954
|
+
@tc.assert_predicate "blah", :empty?
|
955
|
+
end
|
956
|
+
end
|
957
|
+
|
948
958
|
def test_assert_raises
|
949
959
|
@tc.assert_raises RuntimeError do
|
950
960
|
raise "blah"
|
@@ -1382,6 +1392,16 @@ FILE:LINE:in `test_assert_raises_triggered_subclass'
|
|
1382
1392
|
end
|
1383
1393
|
end
|
1384
1394
|
|
1395
|
+
def test_refute_predicate
|
1396
|
+
@tc.refute_predicate "42", :empty?
|
1397
|
+
end
|
1398
|
+
|
1399
|
+
def test_refute_predicate_triggered
|
1400
|
+
util_assert_triggered 'Expected "" to not be empty?.' do
|
1401
|
+
@tc.refute_predicate "", :empty?
|
1402
|
+
end
|
1403
|
+
end
|
1404
|
+
|
1385
1405
|
def test_refute_operator
|
1386
1406
|
@tc.refute_operator 2, :<, 1
|
1387
1407
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 10
|
9
|
+
- 0
|
10
|
+
version: 2.10.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,36 +36,36 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-12-
|
39
|
+
date: 2011-12-21 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rdoc
|
43
43
|
prerelease: false
|
44
44
|
requirement: &id001 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
49
|
+
hash: 19
|
50
50
|
segments:
|
51
|
-
-
|
52
|
-
-
|
53
|
-
version: "
|
51
|
+
- 3
|
52
|
+
- 10
|
53
|
+
version: "3.10"
|
54
54
|
type: :development
|
55
55
|
version_requirements: *id001
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: hoe
|
58
58
|
prerelease: false
|
59
59
|
requirement: &id002 !ruby/object:Gem::Requirement
|
60
60
|
none: false
|
61
61
|
requirements:
|
62
62
|
- - ~>
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
hash:
|
64
|
+
hash: 27
|
65
65
|
segments:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
version: "
|
66
|
+
- 2
|
67
|
+
- 12
|
68
|
+
version: "2.12"
|
69
69
|
type: :development
|
70
70
|
version_requirements: *id002
|
71
71
|
description: "minitest provides a complete suite of testing facilities supporting\n\
|
@@ -108,14 +108,12 @@ files:
|
|
108
108
|
- lib/hoe/minitest.rb
|
109
109
|
- lib/minitest/autorun.rb
|
110
110
|
- lib/minitest/benchmark.rb
|
111
|
-
- lib/minitest/excludes.rb
|
112
111
|
- lib/minitest/mock.rb
|
113
112
|
- lib/minitest/pride.rb
|
114
113
|
- lib/minitest/spec.rb
|
115
114
|
- lib/minitest/unit.rb
|
116
115
|
- test/metametameta.rb
|
117
116
|
- test/test_minitest_benchmark.rb
|
118
|
-
- test/test_minitest_excludes.rb
|
119
117
|
- test/test_minitest_mock.rb
|
120
118
|
- test/test_minitest_spec.rb
|
121
119
|
- test/test_minitest_unit.rb
|
@@ -156,7 +154,6 @@ specification_version: 3
|
|
156
154
|
summary: minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
|
157
155
|
test_files:
|
158
156
|
- test/test_minitest_benchmark.rb
|
159
|
-
- test/test_minitest_excludes.rb
|
160
157
|
- test/test_minitest_mock.rb
|
161
158
|
- test/test_minitest_spec.rb
|
162
159
|
- test/test_minitest_unit.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/minitest/excludes.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'minitest/unit'
|
2
|
-
|
3
|
-
##
|
4
|
-
# minitest/excludes.rb extends MiniTest::Unit::TestCase to provide a
|
5
|
-
# clean API for excluding certain tests you don't want to run under
|
6
|
-
# certain conditions.
|
7
|
-
#
|
8
|
-
# For example, in test/test_xyz.rb you have:
|
9
|
-
#
|
10
|
-
# class TestXYZ < MiniTest::Unit::TestCase
|
11
|
-
# def test_good
|
12
|
-
# # test that passes
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# def test_bad
|
16
|
-
# # test that fails only on jruby
|
17
|
-
# end
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# For jruby runs, you can add test/excludes/TestXYZ.rb with:
|
21
|
-
#
|
22
|
-
# exclude :test_bad, "Uses ObjectSpace" if jruby?
|
23
|
-
#
|
24
|
-
# The file is instance_eval'd on TestXYZ so you can call the exclude
|
25
|
-
# class method directly. Since it is ruby you can provide any sort
|
26
|
-
# of conditions you want to figure out if your tests should be
|
27
|
-
# excluded.
|
28
|
-
#
|
29
|
-
# TestCase.exclude causes test methods to call skip with the reason
|
30
|
-
# you provide. If you run your tests in verbose mode, you'll see a
|
31
|
-
# full report of the tests you've excluded.
|
32
|
-
#
|
33
|
-
# If you want to change where the exclude files are located, you can
|
34
|
-
# set the EXCLUDE_DIR environment variable.
|
35
|
-
|
36
|
-
class MiniTest::Unit::TestCase
|
37
|
-
ENV['EXCLUDE_DIR'] ||= "test/excludes"
|
38
|
-
|
39
|
-
##
|
40
|
-
# Exclude a test from a testcase. This is intended to be used by
|
41
|
-
# exclusion files.
|
42
|
-
|
43
|
-
def self.exclude name, reason
|
44
|
-
return warn "Method #{self}##{name} is not defined" unless
|
45
|
-
method_defined? name
|
46
|
-
|
47
|
-
alias_method :"old_#{name}", name
|
48
|
-
|
49
|
-
define_method name do
|
50
|
-
skip reason
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
##
|
55
|
-
# Loads the exclusion file for the class, if any.
|
56
|
-
|
57
|
-
def self.load_excludes
|
58
|
-
@__load_excludes__ ||=
|
59
|
-
begin
|
60
|
-
if name and not name.empty? then
|
61
|
-
file = File.join ENV['EXCLUDE_DIR'], "#{name}.rb"
|
62
|
-
instance_eval File.read file if File.exist? file
|
63
|
-
end
|
64
|
-
true
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class << self
|
69
|
-
alias :old_test_methods :test_methods # :nodoc:
|
70
|
-
|
71
|
-
def test_methods # :nodoc:
|
72
|
-
load_excludes
|
73
|
-
old_test_methods
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'test/metametameta'
|
2
|
-
require 'minitest/excludes'
|
3
|
-
|
4
|
-
class TestMiniTestExcludes < MetaMetaMetaTestCase
|
5
|
-
def test_cls_excludes
|
6
|
-
srand 42
|
7
|
-
old_exclude_base = ENV['EXCLUDE_DIR']
|
8
|
-
|
9
|
-
@assertion_count = 0
|
10
|
-
|
11
|
-
Dir.mktmpdir do |path|
|
12
|
-
ENV['EXCLUDE_DIR'] = path
|
13
|
-
File.open File.join(path, "ATestCase.rb"), "w" do |f|
|
14
|
-
f.puts <<-EOM
|
15
|
-
exclude :test_test2, "because it is borked"
|
16
|
-
EOM
|
17
|
-
end
|
18
|
-
|
19
|
-
tc = Class.new(MiniTest::Unit::TestCase) do
|
20
|
-
def test_test1; assert true end
|
21
|
-
def test_test2; assert false end # oh noes!
|
22
|
-
def test_test3; assert true end
|
23
|
-
end
|
24
|
-
|
25
|
-
Object.const_set(:ATestCase, tc)
|
26
|
-
|
27
|
-
assert_equal %w(test_test1 test_test2 test_test3), ATestCase.test_methods
|
28
|
-
|
29
|
-
@tu.run %w[--seed 42 --verbose]
|
30
|
-
|
31
|
-
expected = <<-EOM.gsub(/^ {8}/, '')
|
32
|
-
Run options: --seed 42 --verbose
|
33
|
-
|
34
|
-
# Running tests:
|
35
|
-
|
36
|
-
ATestCase#test_test2 = 0.00 s = S
|
37
|
-
ATestCase#test_test1 = 0.00 s = .
|
38
|
-
ATestCase#test_test3 = 0.00 s = .
|
39
|
-
|
40
|
-
|
41
|
-
Finished tests in 0.00
|
42
|
-
|
43
|
-
1) Skipped:
|
44
|
-
test_test2(ATestCase) [FILE:LINE]:
|
45
|
-
because it is borked
|
46
|
-
|
47
|
-
3 tests, 2 assertions, 0 failures, 0 errors, 1 skips
|
48
|
-
EOM
|
49
|
-
assert_report expected
|
50
|
-
end
|
51
|
-
ensure
|
52
|
-
ENV['EXCLUDE_DIR'] = old_exclude_base
|
53
|
-
end
|
54
|
-
end
|