minitest 5.18.0 → 5.25.5
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +187 -1
- data/Manifest.txt +3 -0
- data/README.rdoc +28 -17
- data/Rakefile +7 -1
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +77 -80
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +2 -2
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +39 -19
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +16 -23
- data/lib/minitest/spec.rb +13 -12
- data/lib/minitest/test.rb +17 -36
- data/lib/minitest/test_task.rb +21 -19
- data/lib/minitest.rb +298 -141
- data/test/minitest/metametameta.rb +32 -18
- data/test/minitest/test_minitest_assertions.rb +159 -140
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +151 -79
- data/test/minitest/test_minitest_reporter.rb +143 -19
- data/test/minitest/test_minitest_spec.rb +73 -56
- data/test/minitest/test_minitest_test.rb +218 -116
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data.tar.gz.sig +0 -0
- metadata +21 -20
- metadata.gz.sig +0 -0
@@ -2,7 +2,7 @@ require "minitest/autorun"
|
|
2
2
|
require "minitest/metametameta"
|
3
3
|
require "forwardable"
|
4
4
|
|
5
|
-
class
|
5
|
+
class FakeTest < Minitest::Test
|
6
6
|
def woot
|
7
7
|
assert true
|
8
8
|
end
|
@@ -13,10 +13,6 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
13
13
|
attr_accessor :r, :io
|
14
14
|
|
15
15
|
def new_composite_reporter
|
16
|
-
# Ruby bug in older versions of 2.2 & 2.3 on all platforms
|
17
|
-
# Latest Windows builds were 2.2.6 and 2.3.3. Latest Ruby releases were
|
18
|
-
# 2.2.10 and 2.3.8.
|
19
|
-
skip if windows? && RUBY_VERSION < '2.4'
|
20
16
|
reporter = Minitest::CompositeReporter.new
|
21
17
|
reporter << Minitest::SummaryReporter.new(self.io)
|
22
18
|
reporter << Minitest::ProgressReporter.new(self.io)
|
@@ -31,13 +27,13 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
31
27
|
|
32
28
|
def setup
|
33
29
|
super
|
34
|
-
self.io = StringIO.new("")
|
30
|
+
self.io = StringIO.new(+"")
|
35
31
|
self.r = new_composite_reporter
|
36
32
|
end
|
37
33
|
|
38
34
|
def error_test
|
39
35
|
unless defined? @et then
|
40
|
-
@et =
|
36
|
+
@et = FakeTest.new :woot
|
41
37
|
@et.failures << Minitest::UnexpectedError.new(begin
|
42
38
|
raise "no"
|
43
39
|
rescue => e
|
@@ -48,9 +44,28 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
48
44
|
@et
|
49
45
|
end
|
50
46
|
|
47
|
+
def system_stack_error_test
|
48
|
+
unless defined? @sse then
|
49
|
+
|
50
|
+
ex = SystemStackError.new
|
51
|
+
|
52
|
+
pre = ("a".."c").to_a
|
53
|
+
mid = ("aa".."ad").to_a * 67
|
54
|
+
post = ("d".."f").to_a
|
55
|
+
ary = pre + mid + post
|
56
|
+
|
57
|
+
ex.set_backtrace ary
|
58
|
+
|
59
|
+
@sse = FakeTest.new :woot
|
60
|
+
@sse.failures << Minitest::UnexpectedError.new(ex)
|
61
|
+
@sse = Minitest::Result.from @sse
|
62
|
+
end
|
63
|
+
@sse
|
64
|
+
end
|
65
|
+
|
51
66
|
def fail_test
|
52
67
|
unless defined? @ft then
|
53
|
-
@ft =
|
68
|
+
@ft = FakeTest.new :woot
|
54
69
|
@ft.failures << begin
|
55
70
|
raise Minitest::Assertion, "boo"
|
56
71
|
rescue Minitest::Assertion => e
|
@@ -62,12 +77,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
62
77
|
end
|
63
78
|
|
64
79
|
def passing_test
|
65
|
-
@pt ||= Minitest::Result.from
|
80
|
+
@pt ||= Minitest::Result.from FakeTest.new(:woot)
|
81
|
+
end
|
82
|
+
|
83
|
+
def passing_test_with_metadata
|
84
|
+
test = FakeTest.new :woot
|
85
|
+
test.metadata[:meta] = :data
|
86
|
+
@pt ||= Minitest::Result.from test
|
66
87
|
end
|
67
88
|
|
68
89
|
def skip_test
|
69
90
|
unless defined? @st then
|
70
|
-
@st =
|
91
|
+
@st = FakeTest.new :woot
|
71
92
|
@st.failures << begin
|
72
93
|
raise Minitest::Skip
|
73
94
|
rescue Minitest::Assertion => e
|
@@ -166,6 +187,29 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
166
187
|
assert_equal 0, r.assertions
|
167
188
|
end
|
168
189
|
|
190
|
+
def test_record_pass_with_metadata
|
191
|
+
reporter = self.r
|
192
|
+
|
193
|
+
def reporter.metadata
|
194
|
+
@metadata
|
195
|
+
end
|
196
|
+
|
197
|
+
def reporter.record result
|
198
|
+
super
|
199
|
+
@metadata = result.metadata if result.metadata?
|
200
|
+
end
|
201
|
+
|
202
|
+
r.record passing_test_with_metadata
|
203
|
+
|
204
|
+
exp = { :meta => :data }
|
205
|
+
assert_equal exp, reporter.metadata
|
206
|
+
|
207
|
+
assert_equal ".", io.string
|
208
|
+
assert_empty r.results
|
209
|
+
assert_equal 1, r.count
|
210
|
+
assert_equal 0, r.assertions
|
211
|
+
end
|
212
|
+
|
169
213
|
def test_record_fail
|
170
214
|
fail_test = self.fail_test
|
171
215
|
r.record fail_test
|
@@ -200,7 +244,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
200
244
|
r.start
|
201
245
|
r.report
|
202
246
|
|
203
|
-
exp =
|
247
|
+
exp = <<~EOM
|
204
248
|
Run options:
|
205
249
|
|
206
250
|
# Running:
|
@@ -220,7 +264,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
220
264
|
r.record passing_test
|
221
265
|
r.report
|
222
266
|
|
223
|
-
exp =
|
267
|
+
exp = <<~EOM
|
224
268
|
Run options:
|
225
269
|
|
226
270
|
# Running:
|
@@ -240,7 +284,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
240
284
|
r.record fail_test
|
241
285
|
r.report
|
242
286
|
|
243
|
-
exp =
|
287
|
+
exp = <<~EOM
|
244
288
|
Run options:
|
245
289
|
|
246
290
|
# Running:
|
@@ -250,7 +294,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
250
294
|
Finished in 0.00
|
251
295
|
|
252
296
|
1) Failure:
|
253
|
-
|
297
|
+
FakeTest#woot [FILE:LINE]:
|
254
298
|
boo
|
255
299
|
|
256
300
|
1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
|
@@ -264,7 +308,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
264
308
|
r.record error_test
|
265
309
|
r.report
|
266
310
|
|
267
|
-
exp =
|
311
|
+
exp = <<~EOM
|
268
312
|
Run options:
|
269
313
|
|
270
314
|
# Running:
|
@@ -274,10 +318,46 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
274
318
|
Finished in 0.00
|
275
319
|
|
276
320
|
1) Error:
|
277
|
-
|
321
|
+
FakeTest#woot:
|
278
322
|
RuntimeError: no
|
279
|
-
FILE:LINE:in
|
280
|
-
FILE:LINE:in
|
323
|
+
FILE:LINE:in 'error_test'
|
324
|
+
FILE:LINE:in 'test_report_error'
|
325
|
+
|
326
|
+
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
327
|
+
EOM
|
328
|
+
|
329
|
+
assert_equal exp, normalize_output(io.string)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_report_error__sse
|
333
|
+
r.start
|
334
|
+
r.record system_stack_error_test
|
335
|
+
r.report
|
336
|
+
|
337
|
+
exp = <<~EOM
|
338
|
+
Run options:
|
339
|
+
|
340
|
+
# Running:
|
341
|
+
|
342
|
+
E
|
343
|
+
|
344
|
+
Finished in 0.00
|
345
|
+
|
346
|
+
1) Error:
|
347
|
+
FakeTest#woot:
|
348
|
+
SystemStackError: 274 -> 12
|
349
|
+
a
|
350
|
+
b
|
351
|
+
c
|
352
|
+
+->> 67 cycles of 4 lines:
|
353
|
+
| aa
|
354
|
+
| ab
|
355
|
+
| ac
|
356
|
+
| ad
|
357
|
+
+-<<
|
358
|
+
d
|
359
|
+
e
|
360
|
+
f
|
281
361
|
|
282
362
|
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
|
283
363
|
EOM
|
@@ -293,7 +373,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
293
373
|
r.report
|
294
374
|
end
|
295
375
|
|
296
|
-
exp =
|
376
|
+
exp = <<~EOM
|
297
377
|
Run options:
|
298
378
|
|
299
379
|
# Running:
|
@@ -309,4 +389,48 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
309
389
|
|
310
390
|
assert_equal exp, normalize_output(io.string)
|
311
391
|
end
|
392
|
+
|
393
|
+
def test_report_failure_uses_backtrace_filter
|
394
|
+
filter = Minitest::BacktraceFilter.new
|
395
|
+
def filter.filter _bt
|
396
|
+
["foo.rb:123:in 'foo'"]
|
397
|
+
end
|
398
|
+
|
399
|
+
with_backtrace_filter filter do
|
400
|
+
r.start
|
401
|
+
r.record fail_test
|
402
|
+
r.report
|
403
|
+
end
|
404
|
+
|
405
|
+
exp = "FakeTest#woot [foo.rb:123]"
|
406
|
+
|
407
|
+
assert_includes io.string, exp
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_report_failure_uses_backtrace_filter_complex_sorbet
|
411
|
+
backtrace = <<~EOBT
|
412
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/assertions.rb:183:in 'assert'
|
413
|
+
example_test.rb:9:in 'assert_false'
|
414
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'bind_call'
|
415
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/call_validation.rb:256:in 'validate_call'
|
416
|
+
/Users/user/.gem/ruby/3.2.2/gems/sorbet-runtime-0.5.11068/lib/types/private/methods/_methods.rb:275:in 'block in _on_method_added'
|
417
|
+
example_test.rb:25:in 'test_something'
|
418
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:94:in 'block (3 levels) in run'
|
419
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:191:in 'capture_exceptions'
|
420
|
+
/Users/user/.gem/ruby/3.2.2/gems/minitest-5.20.0/lib/minitest/test.rb:89:in 'block (2 levels) in run'
|
421
|
+
... so many lines ...
|
422
|
+
EOBT
|
423
|
+
|
424
|
+
filter = Minitest::BacktraceFilter.new %r%lib/minitest|gems/sorbet%
|
425
|
+
|
426
|
+
with_backtrace_filter filter do
|
427
|
+
begin
|
428
|
+
assert_equal 1, 2
|
429
|
+
rescue Minitest::Assertion => e
|
430
|
+
e.set_backtrace backtrace.lines.map(&:chomp)
|
431
|
+
|
432
|
+
assert_match "example_test.rb:25", e.location
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
312
436
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require "minitest/metametameta"
|
3
2
|
require "stringio"
|
4
3
|
|
@@ -12,15 +11,12 @@ class ExampleA; end
|
|
12
11
|
class ExampleB < ExampleA; end
|
13
12
|
|
14
13
|
describe Minitest::Spec do
|
15
|
-
# helps to deal with 2.4 deprecation of Fixnum for Integer
|
16
|
-
Int = 1.class
|
17
|
-
|
18
14
|
# do not parallelize this suite... it just can"t handle it.
|
19
15
|
|
20
16
|
def assert_triggered expected = "blah", klass = Minitest::Assertion
|
21
17
|
@assertion_count += 1
|
22
18
|
|
23
|
-
e = assert_raises
|
19
|
+
e = assert_raises klass do
|
24
20
|
yield
|
25
21
|
end
|
26
22
|
|
@@ -29,17 +25,17 @@ describe Minitest::Spec do
|
|
29
25
|
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
30
26
|
msg.gsub!(/:0x[Xa-fA-F0-9]{4,}[ @].+?>/, ":0xXXXXXX@PATH>")
|
31
27
|
|
32
|
-
|
28
|
+
return unless expected
|
29
|
+
|
30
|
+
@assertion_count += 1
|
31
|
+
case expected
|
32
|
+
when String then
|
33
|
+
assert_equal expected, msg
|
34
|
+
when Regexp then
|
33
35
|
@assertion_count += 1
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
when Regexp then
|
38
|
-
@assertion_count += 1
|
39
|
-
assert_match expected, msg
|
40
|
-
else
|
41
|
-
flunk "Unknown: #{expected.inspect}"
|
42
|
-
end
|
36
|
+
assert_match expected, msg
|
37
|
+
else
|
38
|
+
flunk "Unknown: #{expected.inspect}"
|
43
39
|
end
|
44
40
|
end
|
45
41
|
|
@@ -196,7 +192,7 @@ describe Minitest::Spec do
|
|
196
192
|
methods = Minitest::Expectations.public_instance_methods.grep(/must|wont/)
|
197
193
|
methods.map!(&:to_s) if Symbol === methods.first
|
198
194
|
|
199
|
-
musts, wonts = methods.sort.partition { |m| m
|
195
|
+
musts, wonts = methods.sort.partition { |m| m.include? "must" }
|
200
196
|
|
201
197
|
expected_musts = %w[must_be
|
202
198
|
must_be_close_to
|
@@ -216,11 +212,12 @@ describe Minitest::Spec do
|
|
216
212
|
must_raise
|
217
213
|
must_respond_to
|
218
214
|
must_throw
|
215
|
+
must_verify
|
219
216
|
path_must_exist]
|
220
217
|
|
221
|
-
bad = %w[not raise throw send output be_silent]
|
218
|
+
bad = %w[not raise throw send output be_silent verify]
|
222
219
|
|
223
|
-
expected_wonts = expected_musts.map { |m| m.sub(
|
220
|
+
expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
|
224
221
|
expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
|
225
222
|
|
226
223
|
_(musts).must_equal expected_musts
|
@@ -284,18 +281,14 @@ describe Minitest::Spec do
|
|
284
281
|
end
|
285
282
|
|
286
283
|
it "needs to warn on equality with nil" do
|
287
|
-
@assertion_count
|
284
|
+
@assertion_count = 3
|
285
|
+
@assertion_count += 2 unless error_on_warn? # 2 extra assertions
|
286
|
+
|
287
|
+
exp = /DEPRECATED: Use assert_nil if expecting nil from .* This will fail in Minitest 6./
|
288
288
|
|
289
|
-
|
289
|
+
assert_deprecation exp do
|
290
290
|
assert_success _(nil).must_equal(nil)
|
291
291
|
end
|
292
|
-
|
293
|
-
exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
|
294
|
-
"This will fail in Minitest 6.\n"
|
295
|
-
exp = "" if $-w.nil?
|
296
|
-
|
297
|
-
assert_empty out
|
298
|
-
assert_equal exp, err
|
299
292
|
end
|
300
293
|
|
301
294
|
it "needs to verify floats outside a delta" do
|
@@ -403,12 +396,12 @@ describe Minitest::Spec do
|
|
403
396
|
it "needs to verify instances of a class" do
|
404
397
|
assert_success _(42).wont_be_instance_of(String)
|
405
398
|
|
406
|
-
assert_triggered "Expected 42 to not be a kind of
|
407
|
-
_(42).wont_be_kind_of
|
399
|
+
assert_triggered "Expected 42 to not be a kind of Integer." do
|
400
|
+
_(42).wont_be_kind_of Integer
|
408
401
|
end
|
409
402
|
|
410
|
-
assert_triggered "msg.\nExpected 42 to not be an instance of
|
411
|
-
_(42).wont_be_instance_of
|
403
|
+
assert_triggered "msg.\nExpected 42 to not be an instance of Integer." do
|
404
|
+
_(42).wont_be_instance_of Integer, "msg"
|
412
405
|
end
|
413
406
|
end
|
414
407
|
|
@@ -418,26 +411,26 @@ describe Minitest::Spec do
|
|
418
411
|
assert_success _(42).wont_be_kind_of(String)
|
419
412
|
assert_success _(proc {}).wont_be_kind_of(String)
|
420
413
|
|
421
|
-
assert_triggered "Expected 42 to not be a kind of
|
422
|
-
_(42).wont_be_kind_of
|
414
|
+
assert_triggered "Expected 42 to not be a kind of Integer." do
|
415
|
+
_(42).wont_be_kind_of Integer
|
423
416
|
end
|
424
417
|
|
425
|
-
assert_triggered "msg.\nExpected 42 to not be a kind of
|
426
|
-
_(42).wont_be_kind_of
|
418
|
+
assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
|
419
|
+
_(42).wont_be_kind_of Integer, "msg"
|
427
420
|
end
|
428
421
|
end
|
429
422
|
|
430
423
|
it "needs to verify kinds of objects" do
|
431
424
|
@assertion_count += 3 # extra test
|
432
425
|
|
433
|
-
assert_success _(6 * 7).must_be_kind_of(
|
426
|
+
assert_success _(6 * 7).must_be_kind_of(Integer)
|
434
427
|
assert_success _(6 * 7).must_be_kind_of(Numeric)
|
435
428
|
|
436
|
-
assert_triggered "Expected 42 to be a kind of String, not
|
429
|
+
assert_triggered "Expected 42 to be a kind of String, not Integer." do
|
437
430
|
_(6 * 7).must_be_kind_of String
|
438
431
|
end
|
439
432
|
|
440
|
-
assert_triggered "msg.\nExpected 42 to be a kind of String, not
|
433
|
+
assert_triggered "msg.\nExpected 42 to be a kind of String, not Integer." do
|
441
434
|
_(6 * 7).must_be_kind_of String, "msg"
|
442
435
|
end
|
443
436
|
|
@@ -576,7 +569,8 @@ describe Minitest::Spec do
|
|
576
569
|
|
577
570
|
it "can NOT use must_equal in a thread. It must use expect in a thread" do
|
578
571
|
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
579
|
-
|
572
|
+
|
573
|
+
assert_raises RuntimeError, Minitest::UnexpectedWarning do
|
580
574
|
capture_io do
|
581
575
|
Thread.new { (1 + 1).must_equal 2 }.join
|
582
576
|
end
|
@@ -586,29 +580,33 @@ describe Minitest::Spec do
|
|
586
580
|
it "fails gracefully when expectation used outside of `it`" do
|
587
581
|
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
588
582
|
|
589
|
-
@assertion_count +=
|
583
|
+
@assertion_count += 2 # assert_match is compound
|
590
584
|
|
591
|
-
e = assert_raises RuntimeError do
|
585
|
+
e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
|
592
586
|
capture_io do
|
593
587
|
Thread.new { # forces ctx to be nil
|
594
|
-
describe
|
588
|
+
describe "woot" do
|
595
589
|
(1 + 1).must_equal 2
|
596
590
|
end
|
597
591
|
}.join
|
598
592
|
end
|
599
593
|
end
|
600
594
|
|
601
|
-
|
595
|
+
exp = "Calling #must_equal outside of test."
|
596
|
+
exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
|
597
|
+
|
598
|
+
assert_match exp, e.message
|
602
599
|
end
|
603
600
|
|
604
601
|
it "deprecates expectation used without _" do
|
605
602
|
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
606
603
|
|
607
|
-
@assertion_count +=
|
604
|
+
@assertion_count += 1
|
605
|
+
@assertion_count += 2 unless error_on_warn?
|
608
606
|
|
609
607
|
exp = /DEPRECATED: global use of must_equal from/
|
610
608
|
|
611
|
-
|
609
|
+
assert_deprecation exp do
|
612
610
|
(1 + 1).must_equal 2
|
613
611
|
end
|
614
612
|
end
|
@@ -618,12 +616,13 @@ describe Minitest::Spec do
|
|
618
616
|
it "deprecates expectation used without _ with empty backtrace_filter" do
|
619
617
|
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
620
618
|
|
621
|
-
@assertion_count +=
|
619
|
+
@assertion_count += 1
|
620
|
+
@assertion_count += 2 unless error_on_warn?
|
622
621
|
|
623
622
|
exp = /DEPRECATED: global use of must_equal from/
|
624
623
|
|
625
624
|
with_empty_backtrace_filter do
|
626
|
-
|
625
|
+
assert_deprecation exp do
|
627
626
|
(1 + 1).must_equal 2
|
628
627
|
end
|
629
628
|
end
|
@@ -654,9 +653,9 @@ describe Minitest::Spec do
|
|
654
653
|
end
|
655
654
|
|
656
655
|
it "needs to verify types of objects" do
|
657
|
-
assert_success _(6 * 7).must_be_instance_of(
|
656
|
+
assert_success _(6 * 7).must_be_instance_of(Integer)
|
658
657
|
|
659
|
-
exp = "Expected 42 to be an instance of String, not
|
658
|
+
exp = "Expected 42 to be an instance of String, not Integer."
|
660
659
|
|
661
660
|
assert_triggered exp do
|
662
661
|
_(6 * 7).must_be_instance_of String
|
@@ -683,7 +682,7 @@ describe Minitest::Spec do
|
|
683
682
|
assert_success _(41).must_be(:<, 42)
|
684
683
|
|
685
684
|
assert_triggered "Expected 42 to be < 41." do
|
686
|
-
_(42).must_be
|
685
|
+
_(42).must_be :<, 41
|
687
686
|
end
|
688
687
|
end
|
689
688
|
|
@@ -700,11 +699,11 @@ describe Minitest::Spec do
|
|
700
699
|
it "needs to verify using respond_to" do
|
701
700
|
assert_success _(42).must_respond_to(:+)
|
702
701
|
|
703
|
-
assert_triggered "Expected 42 (
|
702
|
+
assert_triggered "Expected 42 (Integer) to respond to #clear." do
|
704
703
|
_(42).must_respond_to :clear
|
705
704
|
end
|
706
705
|
|
707
|
-
assert_triggered "msg.\nExpected 42 (
|
706
|
+
assert_triggered "msg.\nExpected 42 (Integer) to respond to #clear." do
|
708
707
|
_(42).must_respond_to :clear, "msg"
|
709
708
|
end
|
710
709
|
end
|
@@ -751,9 +750,9 @@ describe Minitest::Spec, :let do
|
|
751
750
|
it "doesn't raise an error if it is just another let" do
|
752
751
|
v = proc do
|
753
752
|
describe :outer do
|
754
|
-
let
|
753
|
+
let :bar
|
755
754
|
describe :inner do
|
756
|
-
let
|
755
|
+
let :bar
|
757
756
|
end
|
758
757
|
end
|
759
758
|
:good
|
@@ -954,6 +953,23 @@ class TestMeta < MetaMetaMetaTestCase
|
|
954
953
|
assert_equal "ExampleB::random_method", spec_b.name
|
955
954
|
end
|
956
955
|
|
956
|
+
def test_name_inside_class
|
957
|
+
spec_a = nil
|
958
|
+
spec_b = nil
|
959
|
+
inside_class_example = Class.new Minitest::Spec
|
960
|
+
Object.const_set :InsideClassExample, inside_class_example
|
961
|
+
inside_class_example.class_eval do
|
962
|
+
spec_a = describe "a" do
|
963
|
+
spec_b = describe "b" do; end
|
964
|
+
end
|
965
|
+
end
|
966
|
+
|
967
|
+
assert_equal "InsideClassExample::a", spec_a.name
|
968
|
+
assert_equal "InsideClassExample::a::b", spec_b.name
|
969
|
+
ensure
|
970
|
+
Object.send :remove_const, :InsideClassExample
|
971
|
+
end
|
972
|
+
|
957
973
|
def test_structure
|
958
974
|
x, y, z, * = util_structure
|
959
975
|
|
@@ -1016,8 +1032,9 @@ class TestMeta < MetaMetaMetaTestCase
|
|
1016
1032
|
z = describe "second thingy" do end
|
1017
1033
|
end
|
1018
1034
|
|
1019
|
-
test_methods = [
|
1020
|
-
|
1035
|
+
test_methods = [
|
1036
|
+
"test_0001_top level it",
|
1037
|
+
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
|
1021
1038
|
].sort
|
1022
1039
|
|
1023
1040
|
assert_equal test_methods, [x1, x2]
|