minitest 5.16.2 → 6.0.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 +373 -1
- data/Manifest.txt +16 -4
- data/README.rdoc +48 -118
- data/Rakefile +17 -2
- data/bin/minitest +5 -0
- data/design_rationale.rb +21 -19
- data/lib/hoe/minitest.rb +4 -2
- data/lib/minitest/assertions.rb +142 -124
- data/lib/minitest/autorun.rb +3 -11
- data/lib/minitest/benchmark.rb +9 -12
- data/lib/minitest/bisect.rb +304 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/expectations.rb +18 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +4 -0
- data/lib/minitest/parallel.rb +10 -8
- data/lib/minitest/path_expander.rb +432 -0
- data/lib/minitest/pride.rb +2 -2
- data/lib/minitest/pride_plugin.rb +17 -24
- data/lib/minitest/server.rb +49 -0
- data/lib/minitest/server_plugin.rb +88 -0
- data/lib/minitest/spec.rb +27 -46
- data/lib/minitest/sprint.rb +105 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +32 -52
- data/lib/minitest/test_task.rb +68 -42
- data/lib/minitest.rb +361 -215
- data/test/minitest/metametameta.rb +33 -19
- data/test/minitest/test_bisect.rb +249 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +311 -173
- data/test/minitest/test_minitest_benchmark.rb +15 -1
- data/test/minitest/test_minitest_reporter.rb +148 -23
- data/test/minitest/test_minitest_spec.rb +157 -132
- data/test/minitest/test_minitest_test.rb +270 -204
- data/test/minitest/test_minitest_test_task.rb +18 -7
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +146 -0
- data.tar.gz.sig +2 -2
- metadata +97 -37
- metadata.gz.sig +0 -0
- data/.autotest +0 -34
- data/lib/minitest/mock.rb +0 -323
- data/lib/minitest/unit.rb +0 -42
- data/test/minitest/test_minitest_mock.rb +0 -1139
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
require "minitest/metametameta"
|
|
1
|
+
require_relative "metametameta"
|
|
3
2
|
require "stringio"
|
|
4
3
|
|
|
5
4
|
class MiniSpecA < Minitest::Spec; end
|
|
@@ -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
|
|
|
@@ -112,7 +108,7 @@ describe Minitest::Spec do
|
|
|
112
108
|
end
|
|
113
109
|
|
|
114
110
|
it "needs to catch an expected exception" do
|
|
115
|
-
@assertion_count
|
|
111
|
+
@assertion_count -= 2
|
|
116
112
|
|
|
117
113
|
expect { raise "blah" }.must_raise RuntimeError
|
|
118
114
|
expect { raise Minitest::Assertion }.must_raise Minitest::Assertion
|
|
@@ -137,6 +133,34 @@ describe Minitest::Spec do
|
|
|
137
133
|
end
|
|
138
134
|
end
|
|
139
135
|
|
|
136
|
+
def good_pattern
|
|
137
|
+
capture_io do # 3.0 is noisy
|
|
138
|
+
eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def bad_pattern
|
|
143
|
+
capture_io do # 3.0 is noisy
|
|
144
|
+
eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "needs to pattern match" do
|
|
149
|
+
@assertion_count = 1
|
|
150
|
+
|
|
151
|
+
expect { good_pattern }.must_pattern_match
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "needs to error on bad pattern match" do
|
|
155
|
+
@assertion_count = 1
|
|
156
|
+
|
|
157
|
+
exp = /length mismatch/
|
|
158
|
+
|
|
159
|
+
assert_triggered exp do
|
|
160
|
+
expect { bad_pattern }.must_pattern_match
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
140
164
|
it "needs to ensure silence" do
|
|
141
165
|
@assertion_count -= 1 # no msg
|
|
142
166
|
@assertion_count += 2 # assert_output is 2 assertions
|
|
@@ -156,7 +180,7 @@ describe Minitest::Spec do
|
|
|
156
180
|
methods = Minitest::Expectations.public_instance_methods.grep(/must|wont/)
|
|
157
181
|
methods.map!(&:to_s) if Symbol === methods.first
|
|
158
182
|
|
|
159
|
-
musts, wonts = methods.sort.partition { |m| m
|
|
183
|
+
musts, wonts = methods.sort.partition { |m| m.include? "must" }
|
|
160
184
|
|
|
161
185
|
expected_musts = %w[must_be
|
|
162
186
|
must_be_close_to
|
|
@@ -172,14 +196,21 @@ describe Minitest::Spec do
|
|
|
172
196
|
must_include
|
|
173
197
|
must_match
|
|
174
198
|
must_output
|
|
199
|
+
must_pattern_match
|
|
175
200
|
must_raise
|
|
176
201
|
must_respond_to
|
|
177
202
|
must_throw
|
|
178
203
|
path_must_exist]
|
|
179
204
|
|
|
180
|
-
bad = %w[not raise throw send output be_silent]
|
|
205
|
+
bad = %w[not raise throw send output be_silent verify]
|
|
181
206
|
|
|
182
|
-
|
|
207
|
+
if methods.include? "must_infect" then # from test_minitest_mock.rb
|
|
208
|
+
expected_musts += %w[must_infect must_infect_without_flipping]
|
|
209
|
+
expected_musts.sort!
|
|
210
|
+
bad << "infect"
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
|
|
183
214
|
expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
|
|
184
215
|
|
|
185
216
|
_(musts).must_equal expected_musts
|
|
@@ -199,6 +230,8 @@ describe Minitest::Spec do
|
|
|
199
230
|
end
|
|
200
231
|
|
|
201
232
|
it "needs to verify binary messages" do
|
|
233
|
+
@assertion_count += 3
|
|
234
|
+
|
|
202
235
|
assert_success _(42).wont_be(:<, 24)
|
|
203
236
|
|
|
204
237
|
assert_triggered "Expected 24 to not be < 42." do
|
|
@@ -242,19 +275,9 @@ describe Minitest::Spec do
|
|
|
242
275
|
end
|
|
243
276
|
end
|
|
244
277
|
|
|
245
|
-
it "needs to
|
|
246
|
-
@assertion_count
|
|
247
|
-
|
|
248
|
-
out, err = capture_io do
|
|
249
|
-
assert_success _(nil).must_equal(nil)
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
|
|
253
|
-
"This will fail in Minitest 6.\n"
|
|
254
|
-
exp = "" if $-w.nil?
|
|
255
|
-
|
|
256
|
-
assert_empty out
|
|
257
|
-
assert_equal exp, err
|
|
278
|
+
it "needs to fail on equality with nil" do
|
|
279
|
+
@assertion_count -= 2
|
|
280
|
+
expect { _(nil).must_equal(nil) }.must_raise Minitest::Assertion
|
|
258
281
|
end
|
|
259
282
|
|
|
260
283
|
it "needs to verify floats outside a delta" do
|
|
@@ -266,12 +289,11 @@ describe Minitest::Spec do
|
|
|
266
289
|
_(6 * 7.0).wont_be_close_to 42
|
|
267
290
|
end
|
|
268
291
|
|
|
269
|
-
|
|
270
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
292
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
|
|
271
293
|
_(6 * 7.0).wont_be_close_to 42, 0.00001
|
|
272
294
|
end
|
|
273
295
|
|
|
274
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <=
|
|
296
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
|
|
275
297
|
_(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
|
|
276
298
|
end
|
|
277
299
|
end
|
|
@@ -281,17 +303,15 @@ describe Minitest::Spec do
|
|
|
281
303
|
|
|
282
304
|
assert_success _(24).wont_be_within_epsilon(42)
|
|
283
305
|
|
|
284
|
-
|
|
285
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
306
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.042." do
|
|
286
307
|
_(6 * 7.0).wont_be_within_epsilon 42
|
|
287
308
|
end
|
|
288
309
|
|
|
289
|
-
|
|
290
|
-
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
|
|
310
|
+
assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.00042." do
|
|
291
311
|
_(6 * 7.0).wont_be_within_epsilon 42, 0.00001
|
|
292
312
|
end
|
|
293
313
|
|
|
294
|
-
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <=
|
|
314
|
+
assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 0.00042." do
|
|
295
315
|
_(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
|
|
296
316
|
end
|
|
297
317
|
end
|
|
@@ -305,12 +325,11 @@ describe Minitest::Spec do
|
|
|
305
325
|
_(1.0 / 100).must_be_close_to 0.0
|
|
306
326
|
end
|
|
307
327
|
|
|
308
|
-
|
|
309
|
-
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
|
328
|
+
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
|
|
310
329
|
_(1.0 / 1000).must_be_close_to 0.0, 0.000001
|
|
311
330
|
end
|
|
312
331
|
|
|
313
|
-
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <=
|
|
332
|
+
assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
|
|
314
333
|
_(1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
|
|
315
334
|
end
|
|
316
335
|
end
|
|
@@ -362,12 +381,12 @@ describe Minitest::Spec do
|
|
|
362
381
|
it "needs to verify instances of a class" do
|
|
363
382
|
assert_success _(42).wont_be_instance_of(String)
|
|
364
383
|
|
|
365
|
-
assert_triggered "Expected 42 to not be a kind of
|
|
366
|
-
_(42).wont_be_kind_of
|
|
384
|
+
assert_triggered "Expected 42 to not be a kind of Integer." do
|
|
385
|
+
_(42).wont_be_kind_of Integer
|
|
367
386
|
end
|
|
368
387
|
|
|
369
|
-
assert_triggered "msg.\nExpected 42 to not be an instance of
|
|
370
|
-
_(42).wont_be_instance_of
|
|
388
|
+
assert_triggered "msg.\nExpected 42 to not be an instance of Integer." do
|
|
389
|
+
_(42).wont_be_instance_of Integer, "msg"
|
|
371
390
|
end
|
|
372
391
|
end
|
|
373
392
|
|
|
@@ -377,26 +396,26 @@ describe Minitest::Spec do
|
|
|
377
396
|
assert_success _(42).wont_be_kind_of(String)
|
|
378
397
|
assert_success _(proc {}).wont_be_kind_of(String)
|
|
379
398
|
|
|
380
|
-
assert_triggered "Expected 42 to not be a kind of
|
|
381
|
-
_(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
|
|
382
401
|
end
|
|
383
402
|
|
|
384
|
-
assert_triggered "msg.\nExpected 42 to not be a kind of
|
|
385
|
-
_(42).wont_be_kind_of
|
|
403
|
+
assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
|
|
404
|
+
_(42).wont_be_kind_of Integer, "msg"
|
|
386
405
|
end
|
|
387
406
|
end
|
|
388
407
|
|
|
389
408
|
it "needs to verify kinds of objects" do
|
|
390
409
|
@assertion_count += 3 # extra test
|
|
391
410
|
|
|
392
|
-
assert_success _(6 * 7).must_be_kind_of(
|
|
411
|
+
assert_success _(6 * 7).must_be_kind_of(Integer)
|
|
393
412
|
assert_success _(6 * 7).must_be_kind_of(Numeric)
|
|
394
413
|
|
|
395
|
-
assert_triggered "Expected 42 to be a kind of String, not
|
|
414
|
+
assert_triggered "Expected 42 to be a kind of String, not Integer." do
|
|
396
415
|
_(6 * 7).must_be_kind_of String
|
|
397
416
|
end
|
|
398
417
|
|
|
399
|
-
assert_triggered "msg.\nExpected 42 to be a kind of String, not
|
|
418
|
+
assert_triggered "msg.\nExpected 42 to be a kind of String, not Integer." do
|
|
400
419
|
_(6 * 7).must_be_kind_of String, "msg"
|
|
401
420
|
end
|
|
402
421
|
|
|
@@ -532,61 +551,6 @@ describe Minitest::Spec do
|
|
|
532
551
|
it "can use expect in a thread" do
|
|
533
552
|
Thread.new { _(1 + 1).must_equal 2 }.join
|
|
534
553
|
end
|
|
535
|
-
|
|
536
|
-
it "can NOT use must_equal in a thread. It must use expect in a thread" do
|
|
537
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
538
|
-
assert_raises RuntimeError do
|
|
539
|
-
capture_io do
|
|
540
|
-
Thread.new { (1 + 1).must_equal 2 }.join
|
|
541
|
-
end
|
|
542
|
-
end
|
|
543
|
-
end
|
|
544
|
-
|
|
545
|
-
it "fails gracefully when expectation used outside of `it`" do
|
|
546
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
547
|
-
|
|
548
|
-
@assertion_count += 1
|
|
549
|
-
|
|
550
|
-
e = assert_raises RuntimeError do
|
|
551
|
-
capture_io do
|
|
552
|
-
Thread.new { # forces ctx to be nil
|
|
553
|
-
describe("woot") do
|
|
554
|
-
(1 + 1).must_equal 2
|
|
555
|
-
end
|
|
556
|
-
}.join
|
|
557
|
-
end
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
assert_equal "Calling #must_equal outside of test.", e.message
|
|
561
|
-
end
|
|
562
|
-
|
|
563
|
-
it "deprecates expectation used without _" do
|
|
564
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
565
|
-
|
|
566
|
-
@assertion_count += 3
|
|
567
|
-
|
|
568
|
-
exp = /DEPRECATED: global use of must_equal from/
|
|
569
|
-
|
|
570
|
-
assert_output "", exp do
|
|
571
|
-
(1 + 1).must_equal 2
|
|
572
|
-
end
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
# https://github.com/seattlerb/minitest/issues/837
|
|
576
|
-
# https://github.com/rails/rails/pull/39304
|
|
577
|
-
it "deprecates expectation used without _ with empty backtrace_filter" do
|
|
578
|
-
skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
|
|
579
|
-
|
|
580
|
-
@assertion_count += 3
|
|
581
|
-
|
|
582
|
-
exp = /DEPRECATED: global use of must_equal from/
|
|
583
|
-
|
|
584
|
-
with_empty_backtrace_filter do
|
|
585
|
-
assert_output "", exp do
|
|
586
|
-
(1 + 1).must_equal 2
|
|
587
|
-
end
|
|
588
|
-
end
|
|
589
|
-
end
|
|
590
554
|
end
|
|
591
555
|
|
|
592
556
|
it "needs to verify throw" do
|
|
@@ -613,9 +577,9 @@ describe Minitest::Spec do
|
|
|
613
577
|
end
|
|
614
578
|
|
|
615
579
|
it "needs to verify types of objects" do
|
|
616
|
-
assert_success _(6 * 7).must_be_instance_of(
|
|
580
|
+
assert_success _(6 * 7).must_be_instance_of(Integer)
|
|
617
581
|
|
|
618
|
-
exp = "Expected 42 to be an instance of String, not
|
|
582
|
+
exp = "Expected 42 to be an instance of String, not Integer."
|
|
619
583
|
|
|
620
584
|
assert_triggered exp do
|
|
621
585
|
_(6 * 7).must_be_instance_of String
|
|
@@ -627,7 +591,7 @@ describe Minitest::Spec do
|
|
|
627
591
|
end
|
|
628
592
|
|
|
629
593
|
it "needs to verify using any (negative) predicate" do
|
|
630
|
-
@assertion_count
|
|
594
|
+
@assertion_count += 1
|
|
631
595
|
|
|
632
596
|
assert_success _("blah").wont_be(:empty?)
|
|
633
597
|
|
|
@@ -637,17 +601,17 @@ describe Minitest::Spec do
|
|
|
637
601
|
end
|
|
638
602
|
|
|
639
603
|
it "needs to verify using any binary operator" do
|
|
640
|
-
@assertion_count
|
|
604
|
+
@assertion_count += 1
|
|
641
605
|
|
|
642
606
|
assert_success _(41).must_be(:<, 42)
|
|
643
607
|
|
|
644
608
|
assert_triggered "Expected 42 to be < 41." do
|
|
645
|
-
_(42).must_be
|
|
609
|
+
_(42).must_be :<, 41
|
|
646
610
|
end
|
|
647
611
|
end
|
|
648
612
|
|
|
649
613
|
it "needs to verify using any predicate" do
|
|
650
|
-
@assertion_count
|
|
614
|
+
@assertion_count += 1
|
|
651
615
|
|
|
652
616
|
assert_success _("").must_be(:empty?)
|
|
653
617
|
|
|
@@ -659,19 +623,17 @@ describe Minitest::Spec do
|
|
|
659
623
|
it "needs to verify using respond_to" do
|
|
660
624
|
assert_success _(42).must_respond_to(:+)
|
|
661
625
|
|
|
662
|
-
assert_triggered "Expected 42 (
|
|
626
|
+
assert_triggered "Expected 42 (Integer) to respond to #clear." do
|
|
663
627
|
_(42).must_respond_to :clear
|
|
664
628
|
end
|
|
665
629
|
|
|
666
|
-
assert_triggered "msg.\nExpected 42 (
|
|
630
|
+
assert_triggered "msg.\nExpected 42 (Integer) to respond to #clear." do
|
|
667
631
|
_(42).must_respond_to :clear, "msg"
|
|
668
632
|
end
|
|
669
633
|
end
|
|
670
634
|
end
|
|
671
635
|
|
|
672
636
|
describe Minitest::Spec, :let do
|
|
673
|
-
i_suck_and_my_tests_are_order_dependent!
|
|
674
|
-
|
|
675
637
|
def _count
|
|
676
638
|
$let_count ||= 0
|
|
677
639
|
end
|
|
@@ -682,21 +644,21 @@ describe Minitest::Spec, :let do
|
|
|
682
644
|
end
|
|
683
645
|
|
|
684
646
|
it "is evaluated once per example" do
|
|
685
|
-
|
|
647
|
+
exp = _count + 1
|
|
686
648
|
|
|
687
|
-
_(count).must_equal
|
|
688
|
-
_(count).must_equal
|
|
649
|
+
_(count).must_equal exp
|
|
650
|
+
_(count).must_equal exp
|
|
689
651
|
|
|
690
|
-
_(_count).must_equal
|
|
652
|
+
_(_count).must_equal exp
|
|
691
653
|
end
|
|
692
654
|
|
|
693
655
|
it "is REALLY evaluated once per example" do
|
|
694
|
-
|
|
656
|
+
exp = _count + 1
|
|
695
657
|
|
|
696
|
-
_(count).must_equal
|
|
697
|
-
_(count).must_equal
|
|
658
|
+
_(count).must_equal exp
|
|
659
|
+
_(count).must_equal exp
|
|
698
660
|
|
|
699
|
-
_(_count).must_equal
|
|
661
|
+
_(_count).must_equal exp
|
|
700
662
|
end
|
|
701
663
|
|
|
702
664
|
it 'raises an error if the name begins with "test"' do
|
|
@@ -710,9 +672,9 @@ describe Minitest::Spec, :let do
|
|
|
710
672
|
it "doesn't raise an error if it is just another let" do
|
|
711
673
|
v = proc do
|
|
712
674
|
describe :outer do
|
|
713
|
-
let
|
|
675
|
+
let :bar
|
|
714
676
|
describe :inner do
|
|
715
|
-
let
|
|
677
|
+
let :bar
|
|
716
678
|
end
|
|
717
679
|
end
|
|
718
680
|
:good
|
|
@@ -901,6 +863,16 @@ class TestMeta < MetaMetaMetaTestCase
|
|
|
901
863
|
assert_equal "ExampleB::random_method::addl_context", spec_c.name
|
|
902
864
|
end
|
|
903
865
|
|
|
866
|
+
def test_inspect
|
|
867
|
+
spec_a = describe ExampleA do; end
|
|
868
|
+
spec_b = describe ExampleB, :random_method do; end
|
|
869
|
+
spec_c = describe ExampleB, :random_method, :addl_context do; end
|
|
870
|
+
|
|
871
|
+
assert_equal "ExampleA", spec_a.inspect
|
|
872
|
+
assert_equal "ExampleB::random_method", spec_b.inspect
|
|
873
|
+
assert_equal "ExampleB::random_method::addl_context", spec_c.inspect
|
|
874
|
+
end
|
|
875
|
+
|
|
904
876
|
def test_name2
|
|
905
877
|
assert_equal "NamedExampleA", NamedExampleA.name
|
|
906
878
|
assert_equal "NamedExampleB", NamedExampleB.name
|
|
@@ -913,6 +885,23 @@ class TestMeta < MetaMetaMetaTestCase
|
|
|
913
885
|
assert_equal "ExampleB::random_method", spec_b.name
|
|
914
886
|
end
|
|
915
887
|
|
|
888
|
+
def test_name_inside_class
|
|
889
|
+
spec_a = nil
|
|
890
|
+
spec_b = nil
|
|
891
|
+
inside_class_example = Class.new Minitest::Spec
|
|
892
|
+
Object.const_set :InsideClassExample, inside_class_example
|
|
893
|
+
inside_class_example.class_eval do
|
|
894
|
+
spec_a = describe "a" do
|
|
895
|
+
spec_b = describe "b" do; end
|
|
896
|
+
end
|
|
897
|
+
end
|
|
898
|
+
|
|
899
|
+
assert_equal "InsideClassExample::a", spec_a.name
|
|
900
|
+
assert_equal "InsideClassExample::a::b", spec_b.name
|
|
901
|
+
ensure
|
|
902
|
+
Object.send :remove_const, :InsideClassExample
|
|
903
|
+
end
|
|
904
|
+
|
|
916
905
|
def test_structure
|
|
917
906
|
x, y, z, * = util_structure
|
|
918
907
|
|
|
@@ -975,8 +964,9 @@ class TestMeta < MetaMetaMetaTestCase
|
|
|
975
964
|
z = describe "second thingy" do end
|
|
976
965
|
end
|
|
977
966
|
|
|
978
|
-
test_methods = [
|
|
979
|
-
|
|
967
|
+
test_methods = [
|
|
968
|
+
"test_0001_top level it",
|
|
969
|
+
"test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
|
|
980
970
|
].sort
|
|
981
971
|
|
|
982
972
|
assert_equal test_methods, [x1, x2]
|
|
@@ -1068,3 +1058,38 @@ class ValueMonadTest < Minitest::Test
|
|
|
1068
1058
|
assert_equal "c", struct.expect
|
|
1069
1059
|
end
|
|
1070
1060
|
end
|
|
1061
|
+
|
|
1062
|
+
describe Minitest::Spec, :infect_an_assertion do
|
|
1063
|
+
attr_accessor :infect_mock
|
|
1064
|
+
|
|
1065
|
+
before do
|
|
1066
|
+
mock = Object.new
|
|
1067
|
+
mock.singleton_class.attr_accessor :a, :k
|
|
1068
|
+
def mock.assert_infects *args, **kwargs
|
|
1069
|
+
self.a, self.k = args, kwargs
|
|
1070
|
+
end
|
|
1071
|
+
|
|
1072
|
+
self.infect_mock = mock
|
|
1073
|
+
end
|
|
1074
|
+
|
|
1075
|
+
def assert_infects exp, act, msg = nil, foo: nil, bar: nil
|
|
1076
|
+
self.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect
|
|
1080
|
+
Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
|
|
1081
|
+
|
|
1082
|
+
it "infects assertions with kwargs" do
|
|
1083
|
+
_(:act).must_infect :exp, foo: :foo, bar: :bar
|
|
1084
|
+
|
|
1085
|
+
assert_equal [:exp, :act, nil], infect_mock.a
|
|
1086
|
+
assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
|
|
1087
|
+
end
|
|
1088
|
+
|
|
1089
|
+
it "infects assertions with kwargs (dont_flip)" do
|
|
1090
|
+
_(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
|
|
1091
|
+
|
|
1092
|
+
assert_equal [:act, :exp, nil], infect_mock.a
|
|
1093
|
+
assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
|
|
1094
|
+
end
|
|
1095
|
+
end
|