minitest 5.16.3 → 5.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +23 -0
- data/README.rdoc +14 -17
- data/Rakefile +1 -0
- data/lib/minitest/assertions.rb +50 -0
- data/lib/minitest/expectations.rb +18 -0
- data/lib/minitest/mock.rb +6 -2
- data/lib/minitest/spec.rb +6 -0
- data/lib/minitest/test.rb +9 -5
- data/lib/minitest/test_task.rb +3 -3
- data/lib/minitest.rb +2 -10
- data/test/minitest/test_minitest_assertions.rb +110 -0
- data/test/minitest/test_minitest_mock.rb +10 -3
- data/test/minitest/test_minitest_spec.rb +76 -0
- data.tar.gz.sig +1 -2
- metadata +13 -13
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27d1d24e16ba576cc5a425d6e09e3de81465d10104a647c21ad9a5df36be1551
|
4
|
+
data.tar.gz: c3ca5dd490b7d08ee3254c7c8a680af0675f72e5356ad97b55dd1ec67e27251d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f545c292aabb802ae8e03cea73bf2334a8ac6dea7da411b8e6ad48e036b00eabac550e5405c11aea175b30a9d65aced4e3601258081e845299ff6e1dbffd353d
|
7
|
+
data.tar.gz: ae62ac5c0f4218b66fe0206eb0205828c872531d6b68a4b0537fbe4b0a8753ccf604b4d11a11322dc329b275a1428683125c061e6e255f90ff5a076e4afb02ad
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
=== 5.18.0 / 2023-03-04
|
2
|
+
|
3
|
+
* 2 major enhancements:
|
4
|
+
|
5
|
+
* Added assert_pattern & refute_pattern for pattern matching. (flavorjones)
|
6
|
+
* Added matching must_pattern_match & wont_pattern_match to minitest/spec.
|
7
|
+
|
8
|
+
* 1 bug fix:
|
9
|
+
|
10
|
+
* Support the new message format of NameError in Ruby 3.3 (mame)
|
11
|
+
|
12
|
+
=== 5.17.0 / 2022-12-31
|
13
|
+
|
14
|
+
* 1 minor enhancement:
|
15
|
+
|
16
|
+
* Refactor setup hooks into a SETUP_METHODS constant. (MSP-Greg)
|
17
|
+
|
18
|
+
* 3 bug fixes:
|
19
|
+
|
20
|
+
* Fix kwargs for Mock calls to delegator. (blowmage)
|
21
|
+
* Fix kwargs for expectations. (bobmazanec, blowmage)
|
22
|
+
* Remove check for .b method. (tenderlove)
|
23
|
+
|
1
24
|
=== 5.16.3 / 2022-08-17
|
2
25
|
|
3
26
|
* 2 bug fixes:
|
data/README.rdoc
CHANGED
@@ -407,37 +407,34 @@ Using our example above, here is how we might implement MyCI:
|
|
407
407
|
|
408
408
|
Minitest is a dependency of rails, which until fairly recently had an
|
409
409
|
overzealous backwards compatibility policy. As such, I'm stuck
|
410
|
-
supporting versions of ruby that are long past EOL.
|
411
|
-
|
412
|
-
|
410
|
+
supporting versions of ruby that are long past EOL. Hopefully I'll be
|
411
|
+
able to support only current versions of ruby sometime in the near
|
412
|
+
future.
|
413
413
|
|
414
|
-
(As of
|
414
|
+
(As of 2022-11-29)
|
415
415
|
|
416
416
|
Current versions of rails: (https://endoflife.date/rails)
|
417
417
|
|
418
|
-
| rails | min ruby | rec ruby | minitest | status |
|
419
|
-
|
420
|
-
| 7.0 | >= 2.7 | 3.
|
421
|
-
| 6.1 | >= 2.5 | 3.0 | >= 5.1 |
|
422
|
-
| 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security |
|
423
|
-
| 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 |
|
418
|
+
| rails | min ruby | rec ruby | minitest | status | EOL Date |
|
419
|
+
|-------+----------+----------+----------+----------+------------|
|
420
|
+
| 7.0 | >= 2.7 | 3.1 | >= 5.1 | Current | 2025-06-01?|
|
421
|
+
| 6.1 | >= 2.5 | 3.0 | >= 5.1 | Maint | 2024-06-01?|
|
422
|
+
| 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
|
423
|
+
| 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | EOL | 2022-06-01 |
|
424
424
|
|
425
425
|
Current versions of ruby: (https://endoflife.date/ruby)
|
426
426
|
|
427
427
|
| ruby | Status | EOL Date |
|
428
428
|
|------+---------+------------|
|
429
|
-
| 3.
|
430
|
-
|
|
431
|
-
| 2.
|
429
|
+
| 3.1 | Current | 2025-12-25 |
|
430
|
+
| 3.0 | Maint | 2024-03-31 |
|
431
|
+
| 2.7 | Maint* | 2023-03-31 |
|
432
|
+
| 2.6 | EOL | 2022-03-31 |
|
432
433
|
| 2.5 | EOL | 2021-03-31 |
|
433
|
-
| 2.4 | EOL | 2020-03-31 |
|
434
|
-
| 2.3 | EOL | 2019-03-31 |
|
435
|
-
| 2.2 | EOL | 2018-03-31 |
|
436
434
|
|
437
435
|
See also:
|
438
436
|
|
439
437
|
* https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
440
|
-
* https://jamesjeffersconsulting.com/ruby-rails-version-matrix/
|
441
438
|
|
442
439
|
=== How to test SimpleDelegates?
|
443
440
|
|
data/Rakefile
CHANGED
data/lib/minitest/assertions.rb
CHANGED
@@ -357,6 +357,32 @@ module Minitest
|
|
357
357
|
assert File.exist?(path), msg
|
358
358
|
end
|
359
359
|
|
360
|
+
##
|
361
|
+
# For testing with pattern matching (only supported with Ruby 3.0 and later)
|
362
|
+
#
|
363
|
+
# # pass
|
364
|
+
# assert_pattern { [1,2,3] => [Integer, Integer, Integer] }
|
365
|
+
#
|
366
|
+
# # fail "length mismatch (given 3, expected 1)"
|
367
|
+
# assert_pattern { [1,2,3] => [Integer] }
|
368
|
+
#
|
369
|
+
# The bare <tt>=></tt> pattern will raise a NoMatchingPatternError on failure, which would
|
370
|
+
# normally be counted as a test error. This assertion rescues NoMatchingPatternError and
|
371
|
+
# generates a test failure. Any other exception will be raised as normal and generate a test
|
372
|
+
# error.
|
373
|
+
|
374
|
+
def assert_pattern
|
375
|
+
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
376
|
+
flunk "assert_pattern requires a block to capture errors." unless block_given?
|
377
|
+
|
378
|
+
begin # TODO: remove after ruby 2.6 dropped
|
379
|
+
yield
|
380
|
+
pass
|
381
|
+
rescue NoMatchingPatternError => e
|
382
|
+
flunk e.message
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
360
386
|
##
|
361
387
|
# For testing with predicates. Eg:
|
362
388
|
#
|
@@ -721,6 +747,30 @@ module Minitest
|
|
721
747
|
refute obj.nil?, msg
|
722
748
|
end
|
723
749
|
|
750
|
+
##
|
751
|
+
# For testing with pattern matching (only supported with Ruby 3.0 and later)
|
752
|
+
#
|
753
|
+
# # pass
|
754
|
+
# refute_pattern { [1,2,3] => [String] }
|
755
|
+
#
|
756
|
+
# # fail "NoMatchingPatternError expected, but nothing was raised."
|
757
|
+
# refute_pattern { [1,2,3] => [Integer, Integer, Integer] }
|
758
|
+
#
|
759
|
+
# This assertion expects a NoMatchingPatternError exception, and will fail if none is raised. Any
|
760
|
+
# other exceptions will be raised as normal and generate a test error.
|
761
|
+
|
762
|
+
def refute_pattern
|
763
|
+
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
764
|
+
flunk "refute_pattern requires a block to capture errors." unless block_given?
|
765
|
+
|
766
|
+
begin
|
767
|
+
yield
|
768
|
+
flunk("NoMatchingPatternError expected, but nothing was raised.")
|
769
|
+
rescue NoMatchingPatternError
|
770
|
+
pass
|
771
|
+
end
|
772
|
+
end
|
773
|
+
|
724
774
|
##
|
725
775
|
# Fails if +o1+ is not +op+ +o2+. Eg:
|
726
776
|
#
|
@@ -124,6 +124,15 @@ module Minitest::Expectations
|
|
124
124
|
|
125
125
|
infect_an_assertion :assert_output, :must_output, :block
|
126
126
|
|
127
|
+
##
|
128
|
+
# See Minitest::Assertions#assert_pattern_match
|
129
|
+
#
|
130
|
+
# _ { ... }.must_pattern_match [...]
|
131
|
+
#
|
132
|
+
# :method: must_pattern_match
|
133
|
+
|
134
|
+
infect_an_assertion :assert_pattern, :must_pattern_match, :block
|
135
|
+
|
127
136
|
##
|
128
137
|
# See Minitest::Assertions#assert_raises
|
129
138
|
#
|
@@ -283,6 +292,15 @@ module Minitest::Expectations
|
|
283
292
|
|
284
293
|
infect_an_assertion :refute_operator, :wont_be, :reverse
|
285
294
|
|
295
|
+
##
|
296
|
+
# See Minitest::Assertions#refute_pattern_match
|
297
|
+
#
|
298
|
+
# _ { ... }.wont_pattern_match [...]
|
299
|
+
#
|
300
|
+
# :method: wont_pattern_match
|
301
|
+
|
302
|
+
infect_an_assertion :refute_pattern, :wont_pattern_match, :block
|
303
|
+
|
286
304
|
##
|
287
305
|
# See Minitest::Assertions#refute_respond_to
|
288
306
|
#
|
data/lib/minitest/mock.rb
CHANGED
@@ -55,7 +55,7 @@ module Minitest # :nodoc:
|
|
55
55
|
|
56
56
|
##
|
57
57
|
# Expect that method +name+ is called, optionally with +args+ (and
|
58
|
-
# +kwargs+ or a +blk
|
58
|
+
# +kwargs+ or a +blk+), and returns +retval+.
|
59
59
|
#
|
60
60
|
# @mock.expect(:meaning_of_life, 42)
|
61
61
|
# @mock.meaning_of_life # => 42
|
@@ -150,7 +150,11 @@ module Minitest # :nodoc:
|
|
150
150
|
def method_missing sym, *args, **kwargs, &block # :nodoc:
|
151
151
|
unless @expected_calls.key?(sym) then
|
152
152
|
if @delegator && @delegator.respond_to?(sym)
|
153
|
-
|
153
|
+
if kwargs.empty? then # FIX: drop this after 2.7 dead
|
154
|
+
return @delegator.public_send(sym, *args, &block)
|
155
|
+
else
|
156
|
+
return @delegator.public_send(sym, *args, **kwargs, &block)
|
157
|
+
end
|
154
158
|
else
|
155
159
|
raise NoMethodError, "unmocked method %p, expected one of %p" %
|
156
160
|
[sym, @expected_calls.keys.sort_by(&:to_s)]
|
data/lib/minitest/spec.rb
CHANGED
@@ -6,6 +6,10 @@ class Module # :nodoc:
|
|
6
6
|
dont_flip = false if block
|
7
7
|
target_obj = block ? '_{obj.method}' : '_(obj)'
|
8
8
|
|
9
|
+
# https://eregon.me/blog/2021/02/13/correct-delegation-in-ruby-2-27-3.html
|
10
|
+
# Drop this when we can drop ruby 2.6 (aka after rails 6.1 EOL, ~2024-06)
|
11
|
+
kw_extra = "ruby2_keywords %p" % [new_name] if respond_to?(:ruby2_keywords, true)
|
12
|
+
|
9
13
|
# warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
|
10
14
|
self.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
11
15
|
def #{new_name} *args
|
@@ -14,6 +18,7 @@ class Module # :nodoc:
|
|
14
18
|
Kernel.warn "DEPRECATED: global use of #{new_name} from #\{where}. Use #{target_obj}.#{new_name} instead. This will fail in Minitest 6."
|
15
19
|
Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
|
16
20
|
end
|
21
|
+
#{kw_extra}
|
17
22
|
EOM
|
18
23
|
|
19
24
|
Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
@@ -28,6 +33,7 @@ class Module # :nodoc:
|
|
28
33
|
ctx.#{meth}(args.first, target, *args[1..-1])
|
29
34
|
end
|
30
35
|
end
|
36
|
+
#{kw_extra}
|
31
37
|
EOM
|
32
38
|
end
|
33
39
|
end
|
data/lib/minitest/test.rb
CHANGED
@@ -18,6 +18,10 @@ module Minitest
|
|
18
18
|
|
19
19
|
PASSTHROUGH_EXCEPTIONS = [NoMemoryError, SignalException, SystemExit] # :nodoc:
|
20
20
|
|
21
|
+
SETUP_METHODS = %w[ before_setup setup after_setup ] # :nodoc:
|
22
|
+
|
23
|
+
TEARDOWN_METHODS = %w[ before_teardown teardown after_teardown ] # :nodoc:
|
24
|
+
|
21
25
|
# :stopdoc:
|
22
26
|
class << self; attr_accessor :io_lock; end
|
23
27
|
self.io_lock = Mutex.new
|
@@ -84,8 +88,6 @@ module Minitest
|
|
84
88
|
:random
|
85
89
|
end
|
86
90
|
|
87
|
-
TEARDOWN_METHODS = %w[ before_teardown teardown after_teardown ] # :nodoc:
|
88
|
-
|
89
91
|
##
|
90
92
|
# Runs a single test with setup/teardown hooks.
|
91
93
|
|
@@ -93,7 +95,9 @@ module Minitest
|
|
93
95
|
with_info_handler do
|
94
96
|
time_it do
|
95
97
|
capture_exceptions do
|
96
|
-
|
98
|
+
SETUP_METHODS.each do |hook|
|
99
|
+
self.send hook
|
100
|
+
end
|
97
101
|
|
98
102
|
self.send self.name
|
99
103
|
end
|
@@ -208,7 +212,7 @@ module Minitest
|
|
208
212
|
neuter_exception e
|
209
213
|
end
|
210
214
|
|
211
|
-
def neuter_exception e
|
215
|
+
def neuter_exception e # :nodoc:
|
212
216
|
bt = e.backtrace
|
213
217
|
msg = e.message.dup
|
214
218
|
|
@@ -219,7 +223,7 @@ module Minitest
|
|
219
223
|
new_exception RuntimeError, msg, bt, true # but if this raises, we die
|
220
224
|
end
|
221
225
|
|
222
|
-
def new_exception klass, msg, bt, kill = false
|
226
|
+
def new_exception klass, msg, bt, kill = false # :nodoc:
|
223
227
|
ne = klass.new msg
|
224
228
|
ne.set_backtrace bt
|
225
229
|
|
data/lib/minitest/test_task.rb
CHANGED
@@ -277,8 +277,8 @@ module Minitest # :nodoc:
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
-
class Work < Queue
|
281
|
-
def initialize jobs = []
|
280
|
+
class Work < Queue # :nodoc:
|
281
|
+
def initialize jobs = [] # :nodoc:
|
282
282
|
super()
|
283
283
|
|
284
284
|
jobs.each do |job|
|
@@ -289,7 +289,7 @@ class Work < Queue
|
|
289
289
|
end
|
290
290
|
end
|
291
291
|
|
292
|
-
class Integer
|
292
|
+
class Integer # :nodoc:
|
293
293
|
def threads_do(jobs) # :nodoc:
|
294
294
|
require "thread"
|
295
295
|
q = Work.new jobs
|
data/lib/minitest.rb
CHANGED
@@ -9,7 +9,7 @@ require "etc"
|
|
9
9
|
# :include: README.rdoc
|
10
10
|
|
11
11
|
module Minitest
|
12
|
-
VERSION = "5.
|
12
|
+
VERSION = "5.18.0" # :nodoc:
|
13
13
|
|
14
14
|
@@installed_at_exit ||= false
|
15
15
|
@@after_run = []
|
@@ -823,7 +823,7 @@ module Minitest
|
|
823
823
|
end
|
824
824
|
|
825
825
|
def to_s # :nodoc:
|
826
|
-
aggregated_results(StringIO.new(
|
826
|
+
aggregated_results(StringIO.new(''.b)).string
|
827
827
|
end
|
828
828
|
|
829
829
|
def summary # :nodoc:
|
@@ -836,14 +836,6 @@ module Minitest
|
|
836
836
|
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
|
837
837
|
[count, assertions, failures, errors, skips, extra]
|
838
838
|
end
|
839
|
-
|
840
|
-
private
|
841
|
-
|
842
|
-
if '<3'.respond_to? :b
|
843
|
-
def binary_string; ''.b; end
|
844
|
-
else
|
845
|
-
def binary_string; ''.force_encoding(Encoding::ASCII_8BIT); end
|
846
|
-
end
|
847
839
|
end
|
848
840
|
|
849
841
|
##
|
@@ -1062,6 +1062,66 @@ class TestMinitestAssertions < Minitest::Test
|
|
1062
1062
|
end
|
1063
1063
|
end
|
1064
1064
|
|
1065
|
+
def test_assert_pattern
|
1066
|
+
if RUBY_VERSION > "3" then
|
1067
|
+
@tc.assert_pattern do
|
1068
|
+
exp = if RUBY_VERSION.start_with? "3.0"
|
1069
|
+
"(eval):1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!\n"
|
1070
|
+
else
|
1071
|
+
""
|
1072
|
+
end
|
1073
|
+
assert_output nil, exp do
|
1074
|
+
eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
|
1075
|
+
end
|
1076
|
+
end
|
1077
|
+
else
|
1078
|
+
@assertion_count = 0
|
1079
|
+
|
1080
|
+
assert_raises NotImplementedError do
|
1081
|
+
@tc.assert_pattern do
|
1082
|
+
# do nothing
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
end
|
1086
|
+
end
|
1087
|
+
|
1088
|
+
def test_assert_pattern_traps_nomatchingpatternerror
|
1089
|
+
skip unless RUBY_VERSION > "3"
|
1090
|
+
exp = if RUBY_VERSION.start_with? "3.0" then
|
1091
|
+
"[1, 2, 3]" # terrible error message!
|
1092
|
+
else
|
1093
|
+
/length mismatch/
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
assert_triggered exp do
|
1097
|
+
@tc.assert_pattern do
|
1098
|
+
capture_io do # 3.0 is noisy
|
1099
|
+
eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
|
1100
|
+
end
|
1101
|
+
end
|
1102
|
+
end
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
def test_assert_pattern_raises_other_exceptions
|
1106
|
+
skip unless RUBY_VERSION >= "3.0"
|
1107
|
+
|
1108
|
+
@assertion_count = 0
|
1109
|
+
|
1110
|
+
assert_raises RuntimeError do
|
1111
|
+
@tc.assert_pattern do
|
1112
|
+
raise "boom"
|
1113
|
+
end
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
def test_assert_pattern_with_no_block
|
1118
|
+
skip unless RUBY_VERSION >= "3.0"
|
1119
|
+
|
1120
|
+
assert_triggered "assert_pattern requires a block to capture errors." do
|
1121
|
+
@tc.assert_pattern
|
1122
|
+
end
|
1123
|
+
end
|
1124
|
+
|
1065
1125
|
def test_capture_io
|
1066
1126
|
@assertion_count = 0
|
1067
1127
|
|
@@ -1314,6 +1374,56 @@ class TestMinitestAssertions < Minitest::Test
|
|
1314
1374
|
end
|
1315
1375
|
end
|
1316
1376
|
|
1377
|
+
def test_refute_pattern
|
1378
|
+
if RUBY_VERSION >= "3.0"
|
1379
|
+
@tc.refute_pattern do
|
1380
|
+
capture_io do # 3.0 is noisy
|
1381
|
+
eval "[1,2,3] => [Integer, Integer, String]"
|
1382
|
+
end
|
1383
|
+
end
|
1384
|
+
else
|
1385
|
+
@assertion_count = 0
|
1386
|
+
|
1387
|
+
assert_raises NotImplementedError do
|
1388
|
+
@tc.refute_pattern do
|
1389
|
+
eval "[1,2,3] => [Integer, Integer, String]"
|
1390
|
+
end
|
1391
|
+
end
|
1392
|
+
end
|
1393
|
+
end
|
1394
|
+
|
1395
|
+
def test_refute_pattern_expects_nomatchingpatternerror
|
1396
|
+
skip unless RUBY_VERSION > "3"
|
1397
|
+
|
1398
|
+
assert_triggered(/NoMatchingPatternError expected, but nothing was raised./) do
|
1399
|
+
@tc.refute_pattern do
|
1400
|
+
capture_io do # 3.0 is noisy
|
1401
|
+
eval "[1,2,3] => [Integer, Integer, Integer]"
|
1402
|
+
end
|
1403
|
+
end
|
1404
|
+
end
|
1405
|
+
end
|
1406
|
+
|
1407
|
+
def test_refute_pattern_raises_other_exceptions
|
1408
|
+
skip unless RUBY_VERSION >= "3.0"
|
1409
|
+
|
1410
|
+
@assertion_count = 0
|
1411
|
+
|
1412
|
+
assert_raises RuntimeError do
|
1413
|
+
@tc.refute_pattern do
|
1414
|
+
raise "boom"
|
1415
|
+
end
|
1416
|
+
end
|
1417
|
+
end
|
1418
|
+
|
1419
|
+
def test_refute_pattern_with_no_block
|
1420
|
+
skip unless RUBY_VERSION >= "3.0"
|
1421
|
+
|
1422
|
+
assert_triggered "refute_pattern requires a block to capture errors." do
|
1423
|
+
@tc.refute_pattern
|
1424
|
+
end
|
1425
|
+
end
|
1426
|
+
|
1317
1427
|
def test_refute_predicate
|
1318
1428
|
@tc.refute_predicate "42", :empty?
|
1319
1429
|
end
|
@@ -9,8 +9,6 @@ ensure
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class TestMinitestMock < Minitest::Test
|
12
|
-
parallelize_me!
|
13
|
-
|
14
12
|
def setup
|
15
13
|
@mock = Minitest::Mock.new.expect(:foo, nil)
|
16
14
|
@mock.expect(:meaning_of_life, 42)
|
@@ -260,6 +258,15 @@ class TestMinitestMock < Minitest::Test
|
|
260
258
|
assert_equal exp, e.message
|
261
259
|
end
|
262
260
|
|
261
|
+
def test_delegator_calls_are_propagated
|
262
|
+
delegator = Object.new
|
263
|
+
mock = Minitest::Mock.new delegator
|
264
|
+
|
265
|
+
refute delegator.nil?
|
266
|
+
refute mock.nil?
|
267
|
+
assert_mock mock
|
268
|
+
end
|
269
|
+
|
263
270
|
def test_handles_kwargs_in_error_message
|
264
271
|
mock = Minitest::Mock.new
|
265
272
|
|
@@ -1076,7 +1083,7 @@ class TestMinitestStub < Minitest::Test
|
|
1076
1083
|
end
|
1077
1084
|
end
|
1078
1085
|
end
|
1079
|
-
exp =
|
1086
|
+
exp = /undefined method `write' for nil/
|
1080
1087
|
assert_match exp, e.message
|
1081
1088
|
end
|
1082
1089
|
|
@@ -137,6 +137,46 @@ describe Minitest::Spec do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
def good_pattern
|
141
|
+
capture_io do # 3.0 is noisy
|
142
|
+
eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def bad_pattern
|
147
|
+
capture_io do # 3.0 is noisy
|
148
|
+
eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "needs to pattern match" do
|
153
|
+
@assertion_count = 1
|
154
|
+
|
155
|
+
if RUBY_VERSION > "3" then
|
156
|
+
expect { good_pattern }.must_pattern_match
|
157
|
+
else
|
158
|
+
assert_raises NotImplementedError do
|
159
|
+
expect {}.must_pattern_match
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "needs to error on bad pattern match" do
|
165
|
+
skip unless RUBY_VERSION > "3"
|
166
|
+
|
167
|
+
@assertion_count = 1
|
168
|
+
|
169
|
+
exp = if RUBY_VERSION.start_with? "3.0"
|
170
|
+
"[1, 2, 3]" # terrible error message!
|
171
|
+
else
|
172
|
+
/length mismatch/
|
173
|
+
end
|
174
|
+
|
175
|
+
assert_triggered exp do
|
176
|
+
expect { bad_pattern }.must_pattern_match
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
140
180
|
it "needs to ensure silence" do
|
141
181
|
@assertion_count -= 1 # no msg
|
142
182
|
@assertion_count += 2 # assert_output is 2 assertions
|
@@ -172,6 +212,7 @@ describe Minitest::Spec do
|
|
172
212
|
must_include
|
173
213
|
must_match
|
174
214
|
must_output
|
215
|
+
must_pattern_match
|
175
216
|
must_raise
|
176
217
|
must_respond_to
|
177
218
|
must_throw
|
@@ -1068,3 +1109,38 @@ class ValueMonadTest < Minitest::Test
|
|
1068
1109
|
assert_equal "c", struct.expect
|
1069
1110
|
end
|
1070
1111
|
end
|
1112
|
+
|
1113
|
+
describe Minitest::Spec, :infect_an_assertion do
|
1114
|
+
class << self
|
1115
|
+
attr_accessor :infect_mock
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
def assert_infects exp, act, msg = nil, foo: nil, bar: nil
|
1119
|
+
self.class.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
infect_an_assertion :assert_infects, :must_infect
|
1123
|
+
infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
|
1124
|
+
|
1125
|
+
it "infects assertions with kwargs" do
|
1126
|
+
mock = Minitest::Mock.new
|
1127
|
+
mock.expect :assert_infects, true, [:exp, :act, nil], foo: :foo, bar: :bar
|
1128
|
+
|
1129
|
+
self.class.infect_mock = mock
|
1130
|
+
|
1131
|
+
_(:act).must_infect :exp, foo: :foo, bar: :bar
|
1132
|
+
|
1133
|
+
assert_mock mock
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
it "infects assertions with kwargs (dont_flip)" do
|
1137
|
+
mock = Minitest::Mock.new
|
1138
|
+
mock.expect :assert_infects, true, [:act, :exp, nil], foo: :foo, bar: :bar
|
1139
|
+
|
1140
|
+
self.class.infect_mock = mock
|
1141
|
+
|
1142
|
+
_(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
|
1143
|
+
|
1144
|
+
assert_mock mock
|
1145
|
+
end
|
1146
|
+
end
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�3WP�fG&�����TU�5���tj�Ͷ�AoRvn�ܿ����h��������V�ڌ�Xh3�Gp��g���|\%d�L�Y#��D�e�=p�={����t�,I���L�����i���2-��$�~�z����]6F�M{t/֦yϭ
|
1
|
+
��w`^�F�t���X�5�*��c.%RHt~��~F�A�ƴ#7?�"ļ���Ju��Wj$�: ��J8)bx�eYʎEɆT2C�-xQ0 �.�.��ڿ�){�̯rFAt��W�&)��0{�X�s����Ps��Q�3˚�Fw,3H�0GW$���1�L���I��d2g�N�_�n�I�w��lm�k&&�DV��|��t��o�$�� ̵"���kq�q��x�Ҋ�G���N���
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTIzMDEwMTA3NTExN1oXDTI0MDEwMTA3NTExN1owRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -22,14 +22,14 @@ cert_chain:
|
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
24
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
AQAkg3y+PBnBAPWdxxITm5sPHqdWQgSyCpRA20o4LTuWr8BWhSXBkfQNa7cY6fOn
|
26
|
+
xyM34VPzBFbExv6XOGDfOMFBVaYTHuN9peC/5/umL7kLl+nflXzL2QA7K6LYj5Bg
|
27
|
+
sM574Onr0dZDM6Vn69bzQ7rBIFDfK/OhlPzqKZad4nsdcsVH8ODCiT+ATMIZyz5K
|
28
|
+
WCnNtqlyiWXI8tdTpahDgcUwfcN/oN7v4K8iU5IbLJX6HQ5DKgmKjfb6XyMth16k
|
29
|
+
ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
|
30
|
+
nsNBRuQJ1UfiCG97a6DNm+Fr
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2023-03-04 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -57,14 +57,14 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '4.0'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '4.0'
|
68
68
|
description: |-
|
69
69
|
minitest provides a complete suite of testing facilities supporting
|
70
70
|
TDD, BDD, mocking, and benchmarking.
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
186
|
+
rubygems_version: 3.4.6
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: minitest provides a complete suite of testing facilities supporting TDD,
|
metadata.gz.sig
CHANGED
Binary file
|