minitest 5.16.3 → 5.20.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +48 -0
- data/README.rdoc +21 -23
- 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 +11 -15
- data/lib/minitest/test_task.rb +7 -10
- data/lib/minitest.rb +58 -23
- data/test/minitest/test_minitest_assertions.rb +110 -0
- data/test/minitest/test_minitest_mock.rb +10 -3
- data/test/minitest/test_minitest_reporter.rb +29 -0
- data/test/minitest/test_minitest_spec.rb +76 -0
- data/test/minitest/test_minitest_test.rb +12 -2
- data.tar.gz.sig +4 -2
- metadata +16 -16
- 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: 667a803a272949e7b05440f91a56155ea3977a5b9d364542801889c5a2fe0ff0
|
4
|
+
data.tar.gz: 862bf0ff3d24eea4bbe6c7f435ceef19aaa97748f6a87ec3fa51dc218ca79298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2284c84ae5f98a3454e9a95417e609ca1a8ef9af8ee8b1fad8f2aca2632fde6a309e266ef1d399d9a7d47337cdcba696500a1b36f1fa7d952615eb390a89e329
|
7
|
+
data.tar.gz: a76204f74c2caf693a4302065815b871863ae655372d25fc4d41e416b0d4935704c1e1068457b5cda934312e3915ae8a27595ca962c98e544dd45b54cac2aef7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,51 @@
|
|
1
|
+
=== 5.20.0 / 2023-09-06
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Optionally allow autorun exit hook to remain active in forked child. (casperisfine)
|
6
|
+
|
7
|
+
=== 5.19.0 / 2023-07-26
|
8
|
+
|
9
|
+
* 2 minor enhancements:
|
10
|
+
|
11
|
+
* Add metadata lazy accessor to Runnable / Result. (matteeyah)
|
12
|
+
* Only load minitest/unit (aka ancient MiniTest compatibility layer) if ENV["MT_COMPAT"]
|
13
|
+
|
14
|
+
* 1 bug fix:
|
15
|
+
|
16
|
+
* Minitest::TestTask enthusiastically added itself to default. (ParadoxV5)
|
17
|
+
|
18
|
+
=== 5.18.1 / 2023-06-16
|
19
|
+
|
20
|
+
* 3 bug fixes:
|
21
|
+
|
22
|
+
* Avoid extra string allocations when filtering tests. (tenderlove)
|
23
|
+
* Only mention deprecated ENV['N'] if it is an integer string.
|
24
|
+
* Push up test_order to Minitest::Runnable to fix minitest/hell. (koic)
|
25
|
+
|
26
|
+
=== 5.18.0 / 2023-03-04
|
27
|
+
|
28
|
+
* 2 major enhancements:
|
29
|
+
|
30
|
+
* Added assert_pattern & refute_pattern for pattern matching. (flavorjones)
|
31
|
+
* Added matching must_pattern_match & wont_pattern_match to minitest/spec.
|
32
|
+
|
33
|
+
* 1 bug fix:
|
34
|
+
|
35
|
+
* Support the new message format of NameError in Ruby 3.3 (mame)
|
36
|
+
|
37
|
+
=== 5.17.0 / 2022-12-31
|
38
|
+
|
39
|
+
* 1 minor enhancement:
|
40
|
+
|
41
|
+
* Refactor setup hooks into a SETUP_METHODS constant. (MSP-Greg)
|
42
|
+
|
43
|
+
* 3 bug fixes:
|
44
|
+
|
45
|
+
* Fix kwargs for Mock calls to delegator. (blowmage)
|
46
|
+
* Fix kwargs for expectations. (bobmazanec, blowmage)
|
47
|
+
* Remove check for .b method. (tenderlove)
|
48
|
+
|
1
49
|
=== 5.16.3 / 2022-08-17
|
2
50
|
|
3
51
|
* 2 bug fixes:
|
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
|
@@ -407,37 +407,35 @@ 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 2023-03-05)
|
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
|
+
|
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
|
424
428
|
|
425
429
|
Current versions of ruby: (https://endoflife.date/ruby)
|
426
430
|
|
427
431
|
| ruby | Status | EOL Date |
|
428
432
|
|------+---------+------------|
|
429
|
-
| 3.
|
430
|
-
|
|
431
|
-
|
|
433
|
+
| 3.2 | Current | 2026-03-31 |
|
434
|
+
| 3.1 | Maint | 2025-03-31 |
|
435
|
+
| 3.0 | Maint | 2024-03-31 |
|
436
|
+
| 2.7 | Security| 2023-03-31 |
|
437
|
+
| 2.6 | EOL | 2022-03-31 |
|
432
438
|
| 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
|
-
|
437
|
-
See also:
|
438
|
-
|
439
|
-
* https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
|
440
|
-
* https://jamesjeffersconsulting.com/ruby-rails-version-matrix/
|
441
439
|
|
442
440
|
=== How to test SimpleDelegates?
|
443
441
|
|
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
|
@@ -76,16 +80,6 @@ module Minitest
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
|
-
##
|
80
|
-
# Defines the order to run tests (:random by default). Override
|
81
|
-
# this or use a convenience method to change it for your tests.
|
82
|
-
|
83
|
-
def self.test_order
|
84
|
-
:random
|
85
|
-
end
|
86
|
-
|
87
|
-
TEARDOWN_METHODS = %w[ before_teardown teardown after_teardown ] # :nodoc:
|
88
|
-
|
89
83
|
##
|
90
84
|
# Runs a single test with setup/teardown hooks.
|
91
85
|
|
@@ -93,7 +87,9 @@ module Minitest
|
|
93
87
|
with_info_handler do
|
94
88
|
time_it do
|
95
89
|
capture_exceptions do
|
96
|
-
|
90
|
+
SETUP_METHODS.each do |hook|
|
91
|
+
self.send hook
|
92
|
+
end
|
97
93
|
|
98
94
|
self.send self.name
|
99
95
|
end
|
@@ -145,7 +141,7 @@ module Minitest
|
|
145
141
|
# end
|
146
142
|
# end
|
147
143
|
#
|
148
|
-
# class
|
144
|
+
# class Minitest::Test
|
149
145
|
# include MyMinitestPlugin
|
150
146
|
# end
|
151
147
|
|
@@ -208,7 +204,7 @@ module Minitest
|
|
208
204
|
neuter_exception e
|
209
205
|
end
|
210
206
|
|
211
|
-
def neuter_exception e
|
207
|
+
def neuter_exception e # :nodoc:
|
212
208
|
bt = e.backtrace
|
213
209
|
msg = e.message.dup
|
214
210
|
|
@@ -219,7 +215,7 @@ module Minitest
|
|
219
215
|
new_exception RuntimeError, msg, bt, true # but if this raises, we die
|
220
216
|
end
|
221
217
|
|
222
|
-
def new_exception klass, msg, bt, kill = false
|
218
|
+
def new_exception klass, msg, bt, kill = false # :nodoc:
|
223
219
|
ne = klass.new msg
|
224
220
|
ne.set_backtrace bt
|
225
221
|
|
@@ -249,4 +245,4 @@ module Minitest
|
|
249
245
|
end # Test
|
250
246
|
end
|
251
247
|
|
252
|
-
require "minitest/unit"
|
248
|
+
require "minitest/unit" if ENV["MT_COMPAT"] # compatibility layer only
|
data/lib/minitest/test_task.rb
CHANGED
@@ -29,6 +29,10 @@ module Minitest # :nodoc:
|
|
29
29
|
# end
|
30
30
|
#
|
31
31
|
# Customize the name and only run unit tests.
|
32
|
+
#
|
33
|
+
# NOTE: To hook this task up to the default, make it a dependency:
|
34
|
+
#
|
35
|
+
# task default: :unit
|
32
36
|
|
33
37
|
class TestTask < Rake::TaskLib
|
34
38
|
WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
|
@@ -157,8 +161,6 @@ module Minitest # :nodoc:
|
|
157
161
|
end
|
158
162
|
|
159
163
|
def define # :nodoc:
|
160
|
-
default_tasks = []
|
161
|
-
|
162
164
|
desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args."
|
163
165
|
task name do
|
164
166
|
ruby make_test_cmd, verbose:verbose
|
@@ -243,11 +245,6 @@ module Minitest # :nodoc:
|
|
243
245
|
"sort -n -k2 -t=",
|
244
246
|
"tail -25"].join " | "
|
245
247
|
end
|
246
|
-
|
247
|
-
default_tasks << name
|
248
|
-
|
249
|
-
desc "Run the default task(s)."
|
250
|
-
task :default => default_tasks
|
251
248
|
end
|
252
249
|
|
253
250
|
##
|
@@ -277,8 +274,8 @@ module Minitest # :nodoc:
|
|
277
274
|
end
|
278
275
|
end
|
279
276
|
|
280
|
-
class Work < Queue
|
281
|
-
def initialize jobs = []
|
277
|
+
class Work < Queue # :nodoc:
|
278
|
+
def initialize jobs = [] # :nodoc:
|
282
279
|
super()
|
283
280
|
|
284
281
|
jobs.each do |job|
|
@@ -289,7 +286,7 @@ class Work < Queue
|
|
289
286
|
end
|
290
287
|
end
|
291
288
|
|
292
|
-
class Integer
|
289
|
+
class Integer # :nodoc:
|
293
290
|
def threads_do(jobs) # :nodoc:
|
294
291
|
require "thread"
|
295
292
|
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.20.0" # :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
|
@@ -60,6 +60,9 @@ module Minitest
|
|
60
60
|
cattr_accessor :info_signal
|
61
61
|
self.info_signal = "INFO"
|
62
62
|
|
63
|
+
cattr_accessor :allow_fork
|
64
|
+
self.allow_fork = false
|
65
|
+
|
63
66
|
##
|
64
67
|
# Registers Minitest to run at process exit
|
65
68
|
|
@@ -75,7 +78,7 @@ module Minitest
|
|
75
78
|
|
76
79
|
pid = Process.pid
|
77
80
|
at_exit {
|
78
|
-
next if Process.pid != pid
|
81
|
+
next if !Minitest.allow_fork && Process.pid != pid
|
79
82
|
@@after_run.reverse_each(&:call)
|
80
83
|
exit exit_code || false
|
81
84
|
}
|
@@ -331,19 +334,25 @@ module Minitest
|
|
331
334
|
# reporter to record.
|
332
335
|
|
333
336
|
def self.run reporter, options = {}
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
337
|
+
filtered_methods = if options[:filter]
|
338
|
+
filter = options[:filter]
|
339
|
+
filter = Regexp.new $1 if filter.is_a?(String) && filter =~ %r%/(.*)/%
|
340
|
+
|
341
|
+
self.runnable_methods.find_all { |m|
|
342
|
+
filter === m || filter === "#{self}##{m}"
|
343
|
+
}
|
344
|
+
else
|
345
|
+
self.runnable_methods
|
346
|
+
end
|
340
347
|
|
341
|
-
|
342
|
-
|
348
|
+
if options[:exclude]
|
349
|
+
exclude = options[:exclude]
|
350
|
+
exclude = Regexp.new $1 if exclude =~ %r%/(.*)/%
|
343
351
|
|
344
|
-
|
345
|
-
|
346
|
-
|
352
|
+
filtered_methods.delete_if { |m|
|
353
|
+
exclude === m || exclude === "#{self}##{m}"
|
354
|
+
}
|
355
|
+
end
|
347
356
|
|
348
357
|
return if filtered_methods.empty?
|
349
358
|
|
@@ -365,6 +374,14 @@ module Minitest
|
|
365
374
|
reporter.record Minitest.run_one_method(klass, method_name)
|
366
375
|
end
|
367
376
|
|
377
|
+
##
|
378
|
+
# Defines the order to run tests (:random by default). Override
|
379
|
+
# this or use a convenience method to change it for your tests.
|
380
|
+
|
381
|
+
def self.test_order
|
382
|
+
:random
|
383
|
+
end
|
384
|
+
|
368
385
|
def self.with_info_handler reporter, &block # :nodoc:
|
369
386
|
handler = lambda do
|
370
387
|
unless reporter.passed? then
|
@@ -432,6 +449,31 @@ module Minitest
|
|
432
449
|
self.name = name
|
433
450
|
self.failures = []
|
434
451
|
self.assertions = 0
|
452
|
+
# lazy initializer for metadata
|
453
|
+
end
|
454
|
+
|
455
|
+
##
|
456
|
+
# Metadata you attach to the test results that get sent to the reporter.
|
457
|
+
#
|
458
|
+
# Lazily initializes to a hash, to keep memory down.
|
459
|
+
#
|
460
|
+
# NOTE: this data *must* be plain (read: marshal-able) data!
|
461
|
+
# Hashes! Arrays! Strings!
|
462
|
+
|
463
|
+
def metadata
|
464
|
+
@metadata ||= {}
|
465
|
+
end
|
466
|
+
|
467
|
+
##
|
468
|
+
# Sets metadata, mainly used for +Result.from+.
|
469
|
+
|
470
|
+
attr_writer :metadata
|
471
|
+
|
472
|
+
##
|
473
|
+
# Returns true if metadata exists.
|
474
|
+
|
475
|
+
def metadata?
|
476
|
+
defined? @metadata
|
435
477
|
end
|
436
478
|
|
437
479
|
##
|
@@ -552,6 +594,7 @@ module Minitest
|
|
552
594
|
r.assertions = o.assertions
|
553
595
|
r.failures = o.failures.dup
|
554
596
|
r.time = o.time
|
597
|
+
r.metadata = o.metadata if o.metadata?
|
555
598
|
|
556
599
|
r.source_location = o.method(o.name).source_location rescue ["unknown", -1]
|
557
600
|
|
@@ -823,7 +866,7 @@ module Minitest
|
|
823
866
|
end
|
824
867
|
|
825
868
|
def to_s # :nodoc:
|
826
|
-
aggregated_results(StringIO.new(
|
869
|
+
aggregated_results(StringIO.new(''.b)).string
|
827
870
|
end
|
828
871
|
|
829
872
|
def summary # :nodoc:
|
@@ -836,14 +879,6 @@ module Minitest
|
|
836
879
|
"%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
|
837
880
|
[count, assertions, failures, errors, skips, extra]
|
838
881
|
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
882
|
end
|
848
883
|
|
849
884
|
##
|
@@ -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
|
|
@@ -65,6 +65,12 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
65
65
|
@pt ||= Minitest::Result.from Minitest::Test.new(:woot)
|
66
66
|
end
|
67
67
|
|
68
|
+
def passing_test_with_metadata
|
69
|
+
test = Minitest::Test.new(:woot)
|
70
|
+
test.metadata[:meta] = :data
|
71
|
+
@pt ||= Minitest::Result.from test
|
72
|
+
end
|
73
|
+
|
68
74
|
def skip_test
|
69
75
|
unless defined? @st then
|
70
76
|
@st = Minitest::Test.new(:woot)
|
@@ -166,6 +172,29 @@ class TestMinitestReporter < MetaMetaMetaTestCase
|
|
166
172
|
assert_equal 0, r.assertions
|
167
173
|
end
|
168
174
|
|
175
|
+
def test_record_pass_with_metadata
|
176
|
+
reporter = self.r
|
177
|
+
|
178
|
+
def reporter.metadata
|
179
|
+
@metadata
|
180
|
+
end
|
181
|
+
|
182
|
+
def reporter.record result
|
183
|
+
super
|
184
|
+
@metadata = result.metadata if result.metadata?
|
185
|
+
end
|
186
|
+
|
187
|
+
r.record passing_test_with_metadata
|
188
|
+
|
189
|
+
exp = { :meta => :data }
|
190
|
+
assert_equal exp, reporter.metadata
|
191
|
+
|
192
|
+
assert_equal ".", io.string
|
193
|
+
assert_empty r.results
|
194
|
+
assert_equal 1, r.count
|
195
|
+
assert_equal 0, r.assertions
|
196
|
+
end
|
197
|
+
|
169
198
|
def test_record_fail
|
170
199
|
fail_test = self.fail_test
|
171
200
|
r.record fail_test
|
@@ -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
|
@@ -1089,17 +1089,27 @@ class TestMinitestUnitTestCase < Minitest::Test
|
|
1089
1089
|
|
1090
1090
|
def test_autorun_does_not_affect_fork_success_status
|
1091
1091
|
@assertion_count = 0
|
1092
|
-
skip "windows doesn't have
|
1092
|
+
skip "windows doesn't have fork" unless Process.respond_to?(:fork)
|
1093
1093
|
Process.waitpid(fork {})
|
1094
1094
|
assert_equal true, $?.success?
|
1095
1095
|
end
|
1096
1096
|
|
1097
1097
|
def test_autorun_does_not_affect_fork_exit_status
|
1098
1098
|
@assertion_count = 0
|
1099
|
-
skip "windows doesn't have
|
1099
|
+
skip "windows doesn't have fork" unless Process.respond_to?(:fork)
|
1100
1100
|
Process.waitpid(fork { exit 42 })
|
1101
1101
|
assert_equal 42, $?.exitstatus
|
1102
1102
|
end
|
1103
|
+
|
1104
|
+
def test_autorun_optionally_can_affect_fork_exit_status
|
1105
|
+
@assertion_count = 0
|
1106
|
+
skip "windows doesn't have fork" unless Process.respond_to?(:fork)
|
1107
|
+
Minitest.allow_fork = true
|
1108
|
+
Process.waitpid(fork { exit 42 })
|
1109
|
+
refute_equal 42, $?.exitstatus
|
1110
|
+
ensure
|
1111
|
+
Minitest.allow_fork = false
|
1112
|
+
end
|
1103
1113
|
end
|
1104
1114
|
|
1105
1115
|
class TestMinitestGuard < Minitest::Test
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
�
|
1
|
+
^�bG�@�����Ąw��nr��:@�
|
2
|
+
���Q���%�`d�[M�S7#�N�Ǟ,sVn=5��ݕ��0+E$��0���K�Kn80br�
|
3
|
+
�ʜ�}�� ���m�O��i
|
4
|
+
��=
|
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.20.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-09-06 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.
|
@@ -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
|