minitest 5.17.0 → 5.18.1
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 +19 -0
- data/README.rdoc +10 -9
- data/Rakefile +1 -0
- data/lib/minitest/assertions.rb +50 -0
- data/lib/minitest/expectations.rb +18 -0
- data/lib/minitest/mock.rb +1 -1
- data/lib/minitest/test.rb +0 -8
- data/lib/minitest.rb +27 -13
- data/test/minitest/test_minitest_assertions.rb +110 -0
- data/test/minitest/test_minitest_mock.rb +1 -1
- data/test/minitest/test_minitest_spec.rb +41 -0
- data.tar.gz.sig +0 -0
- metadata +6 -6
- 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: 992b073995b1f8471d46b12e317817e1280f7c25967218dd62520658243f4b97
|
4
|
+
data.tar.gz: 4265a53b9aa6d02307622cb2b57754137e675a032164303feef25445fe3e2ad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd001c5041d4bb8c59fc348a5ab1c9df657cee56938817d2c9e1e9dcabf0e593e0e70dffe56be52b36bff86545919f3982486d632a3393e847bd4c89f392ed80
|
7
|
+
data.tar.gz: 6a6045f24033c98a45951e00fec38cd252687cd6e41069c76e22c3cbe9da8f9f4c8a5ed0b663ba009807dbb1dde6cb5b659e712db5383388955f6efa6d7501c3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== 5.18.1 / 2023-06-16
|
2
|
+
|
3
|
+
* 3 bug fixes:
|
4
|
+
|
5
|
+
* Avoid extra string allocations when filtering tests. (tenderlove)
|
6
|
+
* Only mention deprecated ENV['N'] if it is an integer string.
|
7
|
+
* Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
|
8
|
+
|
9
|
+
=== 5.18.0 / 2023-03-04
|
10
|
+
|
11
|
+
* 2 major enhancements:
|
12
|
+
|
13
|
+
* Added assert_pattern & refute_pattern for pattern matching. (flavorjones)
|
14
|
+
* Added matching must_pattern_match & wont_pattern_match to minitest/spec.
|
15
|
+
|
16
|
+
* 1 bug fix:
|
17
|
+
|
18
|
+
* Support the new message format of NameError in Ruby 3.3 (mame)
|
19
|
+
|
1
20
|
=== 5.17.0 / 2022-12-31
|
2
21
|
|
3
22
|
* 1 minor enhancement:
|
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= minitest/{test,spec,mock,benchmark}
|
2
2
|
|
3
|
-
home :: https://github.com/
|
4
|
-
bugs :: https://github.com/
|
3
|
+
home :: https://github.com/minitest/minitest
|
4
|
+
bugs :: https://github.com/minitest/minitest/issues
|
5
5
|
rdoc :: https://docs.seattlerb.org/minitest
|
6
6
|
vim :: https://github.com/sunaku/vim-ruby-minitest
|
7
7
|
emacs:: https://github.com/arthurnn/minitest-emacs
|
@@ -411,7 +411,7 @@ supporting versions of ruby that are long past EOL. Hopefully I'll be
|
|
411
411
|
able to support only current versions of ruby sometime in the near
|
412
412
|
future.
|
413
413
|
|
414
|
-
(As of
|
414
|
+
(As of 2023-03-05)
|
415
415
|
|
416
416
|
Current versions of rails: (https://endoflife.date/rails)
|
417
417
|
|
@@ -422,20 +422,21 @@ Current versions of rails: (https://endoflife.date/rails)
|
|
422
422
|
| 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security | 2023-06-01 |
|
423
423
|
| 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | EOL | 2022-06-01 |
|
424
424
|
|
425
|
+
If you want to look at the requirements for a specific version, run:
|
426
|
+
|
427
|
+
gem spec -r --ruby rails -v 7.0.0
|
428
|
+
|
425
429
|
Current versions of ruby: (https://endoflife.date/ruby)
|
426
430
|
|
427
431
|
| ruby | Status | EOL Date |
|
428
432
|
|------+---------+------------|
|
429
|
-
| 3.
|
433
|
+
| 3.2 | Current | 2026-03-31 |
|
434
|
+
| 3.1 | Maint | 2025-03-31 |
|
430
435
|
| 3.0 | Maint | 2024-03-31 |
|
431
|
-
| 2.7 |
|
436
|
+
| 2.7 | Security| 2023-03-31 |
|
432
437
|
| 2.6 | EOL | 2022-03-31 |
|
433
438
|
| 2.5 | EOL | 2021-03-31 |
|
434
439
|
|
435
|
-
See also:
|
436
|
-
|
437
|
-
* https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
438
|
-
|
439
440
|
=== How to test SimpleDelegates?
|
440
441
|
|
441
442
|
The following implementation and test:
|
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
|
data/lib/minitest/test.rb
CHANGED
@@ -80,14 +80,6 @@ module Minitest
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
##
|
84
|
-
# Defines the order to run tests (:random by default). Override
|
85
|
-
# this or use a convenience method to change it for your tests.
|
86
|
-
|
87
|
-
def self.test_order
|
88
|
-
:random
|
89
|
-
end
|
90
|
-
|
91
83
|
##
|
92
84
|
# Runs a single test with setup/teardown hooks.
|
93
85
|
|
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.1" # :nodoc:
|
13
13
|
|
14
14
|
@@installed_at_exit ||= false
|
15
15
|
@@after_run = []
|
@@ -32,7 +32,7 @@ module Minitest
|
|
32
32
|
|
33
33
|
cattr_accessor :parallel_executor
|
34
34
|
|
35
|
-
warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"]
|
35
|
+
warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"] && ENV["N"].to_i > 0
|
36
36
|
n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
|
37
37
|
|
38
38
|
self.parallel_executor = Parallel::Executor.new n_threads
|
@@ -331,19 +331,25 @@ module Minitest
|
|
331
331
|
# reporter to record.
|
332
332
|
|
333
333
|
def self.run reporter, options = {}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
334
|
+
filtered_methods = if options[:filter]
|
335
|
+
filter = options[:filter]
|
336
|
+
filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
|
337
|
+
|
338
|
+
self.runnable_methods.find_all { |m|
|
339
|
+
filter === m || filter === "#{self}##{m}"
|
340
|
+
}
|
341
|
+
else
|
342
|
+
self.runnable_methods
|
343
|
+
end
|
340
344
|
|
341
|
-
|
342
|
-
|
345
|
+
if options[:exclude]
|
346
|
+
exclude = options[:exclude]
|
347
|
+
exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
|
343
348
|
|
344
|
-
|
345
|
-
|
346
|
-
|
349
|
+
filtered_methods.delete_if { |m|
|
350
|
+
exclude === m || exclude === "#{self}##{m}"
|
351
|
+
}
|
352
|
+
end
|
347
353
|
|
348
354
|
return if filtered_methods.empty?
|
349
355
|
|
@@ -365,6 +371,14 @@ module Minitest
|
|
365
371
|
reporter.record Minitest.run_one_method(klass, method_name)
|
366
372
|
end
|
367
373
|
|
374
|
+
##
|
375
|
+
# Defines the order to run tests (:random by default). Override
|
376
|
+
# this or use a convenience method to change it for your tests.
|
377
|
+
|
378
|
+
def self.test_order
|
379
|
+
:random
|
380
|
+
end
|
381
|
+
|
368
382
|
def self.with_info_handler reporter, &block # :nodoc:
|
369
383
|
handler = lambda do
|
370
384
|
unless reporter.passed? then
|
@@ -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
|
@@ -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
|
data.tar.gz.sig
CHANGED
Binary file
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
ROfWo9Uyp8ba/j9eVG14KkYRaLydAY1MNQk2yd3R5CGfeOpD1kttxjoypoUJ2dOG
|
30
30
|
nsNBRuQJ1UfiCG97a6DNm+Fr
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2023-
|
32
|
+
date: 2023-06-16 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -157,12 +157,12 @@ files:
|
|
157
157
|
- test/minitest/test_minitest_spec.rb
|
158
158
|
- test/minitest/test_minitest_test.rb
|
159
159
|
- test/minitest/test_minitest_test_task.rb
|
160
|
-
homepage: https://github.com/
|
160
|
+
homepage: https://github.com/minitest/minitest
|
161
161
|
licenses:
|
162
162
|
- MIT
|
163
163
|
metadata:
|
164
|
-
homepage_uri: https://github.com/
|
165
|
-
bug_tracker_uri: https://github.com/
|
164
|
+
homepage_uri: https://github.com/minitest/minitest
|
165
|
+
bug_tracker_uri: https://github.com/minitest/minitest/issues
|
166
166
|
post_install_message:
|
167
167
|
rdoc_options:
|
168
168
|
- "--main"
|
@@ -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.10
|
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
|