minitest 5.25.1 → 5.26.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 791576b6d19fd427617c1e5c02a7ddf55f3d214e75bdeeda4ec5ccb49bbad5d2
4
- data.tar.gz: 95a6dccbd1cc86bf047b82e88725d50d0dd03dab9f1f6db0a02aad13f1398f10
3
+ metadata.gz: ecf3d390663e8f655908e6feef0796c5666930f979a0010e27d5adf4956b0bfc
4
+ data.tar.gz: be16818cbc164296bdacde79856532e5695bd6e45dec7d28e624e75bbccbf465
5
5
  SHA512:
6
- metadata.gz: acde5c1dc093da1b6749b4e328fe5e0b86ba34c081b3d6e667165f8811ea3565774570e73216d67f8c337b5e3999193b2709a50bd69e0dc62ed211b86d087cb9
7
- data.tar.gz: ee2390a10ef3ce15c17fef8d8387ff38509ac7c5bf9fd0bcbb1b6c160592821b268d713c0dc8c7357ddeaefb8ca08d0a04d96501c064e0c4f4781f7b3612bbb8
6
+ metadata.gz: 4690ff166d9757befd4365ca3ca77443e4252c32132e91933093548b179ae051cade595e1a085e373e9f6a32b4677d38073cfc1b6e386a00bf77edc8cffad487
7
+ data.tar.gz: 923c90aaff33957818b8fcb053bf9fb28c01953ec910d42114cd3ba09204a0166e85824fb7188bc944f12a7855c47c0e6f63a39d2f45fcb37f25b8176416cd18
checksums.yaml.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,58 @@
1
+ === 5.26.0 / 2025-10-07
2
+
3
+ The Seattle.rb Nerd Party, Slightly Tipsy Edition!
4
+
5
+ * 2 minor enhancements:
6
+
7
+ * Added extra documentation to Minitest::TestTask options.
8
+ * Make parallelize_me! a no-op when n_threads=1.
9
+
10
+ * 9 bug fixes:
11
+
12
+ * Bypass parallel_executor entirely when n_threads=1.
13
+ * Don't require rubygems in Rakefile... it is 2025.
14
+ * Ensure that minitest exits non-zero on Interrupt. (tavianator)
15
+ * Fix Minitest.run sequence rdoc to include loop vars and read consistently.
16
+ * Fix call to parallel_executor.shutdown when it isn't defined.
17
+ * Removed some 1.8/1.9-based code from the assertions and expectations.
18
+ * Still fighting with rdoc? Yup. Still fighting with rdoc...
19
+ * Switched assert_equal's diff from Tempfile.open to Tempfile.create.
20
+ * Use Regexp.escape for BASE_RE in case pwd has special chars. (astra_1993)
21
+
22
+ === 5.25.5 / 2025-03-12
23
+
24
+ * 4 bug fixes:
25
+
26
+ * Bumped minimum ruby to 2.7.
27
+ * Fixed expectation docs for must/wont_pattern_match. (jaredcwhite)
28
+ * Reorder Minitest::Test.ancestors to allow reaching Minitest::Assertions#skipped? (Edouard-chin)
29
+ * Update the ruby and rails compatibility tables. (bquorning)
30
+
31
+ === 5.25.4 / 2024-12-03
32
+
33
+ * 1 bug fix:
34
+
35
+ * Fix for must_verify definition if only requiring minitest/mock (but why?).
36
+
37
+ === 5.25.3 / 2024-12-03
38
+
39
+ * 5 bug fixes:
40
+
41
+ * Fixed assert_mock to fail instead of raise on unmet mock expectations.
42
+ * Fixed assert_mock to take an optional message argument.
43
+ * Fixed formatting of unmet mock expectation messages.
44
+ * Fixed missing must_verify expectation to match assert_mock.
45
+ * minitest/pride: Fixed to use true colors with *-direct terminals (bk2204)
46
+
47
+ === 5.25.2 / 2024-11-21
48
+
49
+ * 4 bug fixes:
50
+
51
+ * Include class name in spec name. (thomasmarshall)
52
+ * Fixed 'redefining object_id' warning from ruby 3.4. (mattbrictson)
53
+ * Minitest top-level namespace no longer includes entire contents of README.rdoc. Too much!
54
+ * Refactored spec's describe to more cleanly determine the superclass and name
55
+
1
56
  === 5.25.1 / 2024-08-16
2
57
 
3
58
  * 2 bug fixes:
data/README.rdoc CHANGED
@@ -412,33 +412,40 @@ supporting versions of ruby that are long past EOL. Hopefully I'll be
412
412
  able to support only current versions of ruby sometime in the near
413
413
  future.
414
414
 
415
- (As of 2024-05-10)
415
+ NOTICE: At this point, I will only locally test/dev against the
416
+ currently 3 supported (non-EOL) versions of ruby. I cannot and will
417
+ not maintain that many builds.
418
+
419
+ (As of 2025-02-03)
416
420
 
417
421
  Current versions of rails: (https://endoflife.date/rails)
418
422
 
419
423
  | rails | min ruby | minitest | status | EOL Date |
420
424
  |-------+----------+----------+----------+------------|
421
- | 7.1 | >= 2.7 | >= 5.1 | Current | 2026-06-01?|
422
- | 7.0 | >= 2.7 | >= 5.1 | Maint | 2025-06-01?|
423
- | 6.1 | >= 2.5 | >= 5.1 | Security | 2024-06-01?|
425
+ | 8.0 | >= 3.2 | >= 5.1 | Current | 2026-11-07 |
426
+ | 7.2 | >= 3.1 | >= 5.1 | Current | 2026-08-09 |
427
+ | 7.1 | >= 2.7 | >= 5.1 | Security | 2025-10-01 |
428
+ | 7.0 | >= 2.7 | >= 5.1 | Security | 2025-04-01 |
429
+ | 6.1 | >= 2.5 | >= 5.1 | EOL | 2024-10-01 |
424
430
  | 6.0 | >= 2.5 | >= 5.1 | EOL | 2023-06-01 |
425
431
  | 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
426
432
 
427
433
  If you want to look at the requirements for a specific version, run:
428
434
 
429
- gem spec -r --ruby rails -v 7.0.0
435
+ gem spec -r --ruby rails -v 8.0.0
430
436
 
431
437
  Current versions of ruby: (https://endoflife.date/ruby)
432
438
 
433
439
  | ruby | Status | EOL Date |
434
440
  |------+---------+------------|
435
- | 3.3 | Current | 2027-03-31 |
436
- | 3.2 | Maint | 2026-03-31 |
437
- | 3.1 | Security| 2025-03-31 |
441
+ | 3.4 | Current | 2028-03-31 |
442
+ | 3.3 | Maint | 2027-03-31 |
443
+ | 3.2 | Security| 2026-03-31 |
444
+ | 3.1 | EOL | 2025-03-31 |
438
445
  | 3.0 | EOL | 2024-03-31 |
439
446
  | 2.7 | EOL | 2023-03-31 |
440
447
  | 2.6 | EOL | 2022-03-31 |
441
- | 2.5 | EOL | 2021-03-31 | DO YOU SEE WHAT I'M STUCK WITH???
448
+ | 2.5 | EOL | 2021-03-31 |
442
449
 
443
450
  === How to test SimpleDelegates?
444
451
 
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require "rubygems"
4
3
  require "hoe"
5
4
  $:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
6
5
 
@@ -12,7 +11,7 @@ Hoe.spec "minitest" do
12
11
 
13
12
  license "MIT"
14
13
 
15
- require_ruby_version [">= 2.6", "< 4.0"]
14
+ require_ruby_version [">= 2.7", "< 4.0"]
16
15
  end
17
16
 
18
17
  desc "Find missing expectations"
@@ -62,11 +62,11 @@ module Minitest
62
62
  return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
63
63
  expect
64
64
 
65
- Tempfile.open "expect" do |a|
65
+ Tempfile.create "expect" do |a|
66
66
  a.puts expect
67
67
  a.flush
68
68
 
69
- Tempfile.open "butwas" do |b|
69
+ Tempfile.create "butwas" do |b|
70
70
  b.puts butwas
71
71
  b.flush
72
72
 
@@ -500,14 +500,9 @@ module Minitest
500
500
  value = catch sym do
501
501
  begin
502
502
  yield
503
- rescue ThreadError => e # wtf?!? 1.8 + threads == suck
504
- default += ", not :#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
505
- rescue ArgumentError => e # 1.9 exception
503
+ rescue ArgumentError => e # 1.9+ exception
506
504
  raise e unless e.message.include? "uncaught throw"
507
505
  default += ", not #{e.message.split(/ /).last}"
508
- rescue NameError => e # 1.8 exception
509
- raise e unless e.name == sym
510
- default += ", not #{e.name.inspect}"
511
506
  end
512
507
  caught = false
513
508
  end
@@ -125,7 +125,7 @@ module Minitest::Expectations
125
125
  infect_an_assertion :assert_output, :must_output, :block
126
126
 
127
127
  ##
128
- # See Minitest::Assertions#assert_pattern_match
128
+ # See Minitest::Assertions#assert_pattern
129
129
  #
130
130
  # _ { ... }.must_pattern_match [...]
131
131
  #
@@ -293,7 +293,7 @@ module Minitest::Expectations
293
293
  infect_an_assertion :refute_operator, :wont_be, :reverse
294
294
 
295
295
  ##
296
- # See Minitest::Assertions#refute_pattern_match
296
+ # See Minitest::Assertions#refute_pattern
297
297
  #
298
298
  # _ { ... }.wont_pattern_match [...]
299
299
  #
data/lib/minitest/mock.rb CHANGED
@@ -30,6 +30,7 @@ module Minitest # :nodoc:
30
30
  end
31
31
 
32
32
  overridden_methods.map(&:to_sym).each do |method_id|
33
+ old_w, $-w = $-w, nil
33
34
  define_method method_id do |*args, **kwargs, &b|
34
35
  if @expected_calls.key? method_id then
35
36
  if kwargs.empty? then # FIX: drop this after 2.7 dead
@@ -45,6 +46,8 @@ module Minitest # :nodoc:
45
46
  end
46
47
  end
47
48
  end
49
+ ensure
50
+ $-w = old_w
48
51
  end
49
52
 
50
53
  def initialize delegator = nil # :nodoc:
@@ -142,8 +145,8 @@ module Minitest # :nodoc:
142
145
  def verify
143
146
  @expected_calls.each do |name, expected|
144
147
  actual = @actual_calls.fetch name, nil # defaults to []
145
- raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
146
- raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
148
+ raise MockExpectationError, "Expected #{__call name, expected[0]}" unless actual
149
+ raise MockExpectationError, "Expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
147
150
  actual.size < expected.size
148
151
  end
149
152
  true
@@ -245,13 +248,28 @@ end
245
248
 
246
249
  module Minitest::Assertions
247
250
  ##
248
- # Assert that the mock verifies correctly.
251
+ # Assert that the mock verifies correctly and fail if not.
249
252
 
250
- def assert_mock mock
253
+ def assert_mock mock, msg = nil
251
254
  assert mock.verify
255
+ rescue MockExpectationError => e
256
+ msg = message(msg) { e.message }
257
+ flunk msg
252
258
  end
253
259
  end
254
260
 
261
+ module Minitest::Expectations
262
+ ##
263
+ # See Minitest::Assertions#assert_mock.
264
+ #
265
+ # _(collection).must_verify
266
+ #
267
+ # :method: must_verify
268
+
269
+ infect_an_assertion :assert_mock, :must_verify, :unary if
270
+ defined?(infect_an_assertion)
271
+ end
272
+
255
273
  ##
256
274
  # Object extensions for Minitest::Mock.
257
275
 
@@ -10,7 +10,7 @@ module Minitest
10
10
  def self.plugin_pride_init options # :nodoc:
11
11
  return unless PrideIO.pride?
12
12
 
13
- klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
13
+ klass = ENV["TERM"] =~ /^xterm|-(?:256color|direct)$/ ? PrideLOL : PrideIO
14
14
  io = klass.new options[:io]
15
15
 
16
16
  self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
data/lib/minitest/spec.rb CHANGED
@@ -38,7 +38,11 @@ class Module # :nodoc:
38
38
  end
39
39
  end
40
40
 
41
- Minitest::Expectation = Struct.new :target, :ctx # :nodoc:
41
+ # :stopdoc:
42
+ module Minitest # fucking hell rdoc...
43
+ Expectation = Struct.new :target, :ctx
44
+ end
45
+ # :startdoc:
42
46
 
43
47
  ##
44
48
  # Kernel extensions for minitest
@@ -81,14 +85,15 @@ module Kernel
81
85
 
82
86
  def describe desc, *additional_desc, &block # :doc:
83
87
  stack = Minitest::Spec.describe_stack
84
- name = [stack.last, desc, *additional_desc].compact.join("::")
85
- sclas = stack.last || if Class === self && kind_of?(Minitest::Spec::DSL) then
86
- self
87
- else
88
- Minitest::Spec.spec_type desc, *additional_desc
89
- end
88
+ is_spec_class = Class === self && kind_of?(Minitest::Spec::DSL)
89
+ name = [stack.last, desc, *additional_desc]
90
+ name.prepend self if stack.empty? && is_spec_class
91
+ sclas =
92
+ stack.last \
93
+ || (is_spec_class && self) \
94
+ || Minitest::Spec.spec_type(desc, *additional_desc)
90
95
 
91
- cls = sclas.create name, desc
96
+ cls = sclas.create name.compact.join("::"), desc
92
97
 
93
98
  stack.push cls
94
99
  cls.class_eval(&block)
@@ -284,9 +289,7 @@ class Minitest::Spec < Minitest::Test
284
289
  defined?(@name) ? @name : super
285
290
  end
286
291
 
287
- def to_s # :nodoc:
288
- name # Can't alias due to 1.8.7, not sure why
289
- end
292
+ alias to_s name
290
293
 
291
294
  attr_reader :desc # :nodoc:
292
295
  alias specify it
data/lib/minitest/test.rb CHANGED
@@ -9,8 +9,8 @@ module Minitest
9
9
 
10
10
  class Test < Runnable
11
11
  require "minitest/assertions"
12
- include Minitest::Assertions
13
12
  include Minitest::Reportable
13
+ include Minitest::Assertions
14
14
 
15
15
  def class_name # :nodoc:
16
16
  self.class.name # for Minitest::Reportable
@@ -58,6 +58,7 @@ module Minitest
58
58
  # tests are awesome.
59
59
 
60
60
  def self.parallelize_me!
61
+ return unless Minitest.parallel_executor
61
62
  include Minitest::Parallel::Test
62
63
  extend Minitest::Parallel::Test::ClassMethods
63
64
  end
@@ -44,8 +44,16 @@ module Minitest # :nodoc:
44
44
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
45
45
 
46
46
  ##
47
- # Create several test-oriented tasks under +name+. Takes an
48
- # optional block to customize variables.
47
+ # Create several test-oriented tasks under +name+ (default:
48
+ # "test"). Takes an optional block to customize variables.
49
+ # Examples:
50
+ #
51
+ # Minitest::TestTask.create # named "test", all defaults
52
+ #
53
+ # Minitest::TestTask.create do |t|
54
+ # t.warning = false # my tests are noisy
55
+ # t.framework = %(require_relative "./test/helper.rb")
56
+ # end
49
57
 
50
58
  def self.create name = :test, &block
51
59
  task = new name
@@ -69,9 +77,18 @@ module Minitest # :nodoc:
69
77
 
70
78
  ##
71
79
  # The code to load the framework. Defaults to requiring
72
- # minitest/autorun...
80
+ # minitest/autorun.
81
+ #
82
+ # If you have a test helper file that requires minitest/autorun
83
+ # and anything else your project standardizes on, then you'll
84
+ # probably want to change this to:
73
85
  #
74
- # Why do I have this as an option?
86
+ # Minitest::TestTask.create do |t|
87
+ # t.framework = %(require_relative "./test/helper.rb")
88
+ # end
89
+ #
90
+ # or something similar. NOTE: if you do this, then helper must
91
+ # require "minitest/autorun" at the top to start the tests.
75
92
 
76
93
  attr_accessor :framework
77
94
 
@@ -100,6 +117,11 @@ module Minitest # :nodoc:
100
117
 
101
118
  ##
102
119
  # Optional: Additional ruby to run before the test framework is loaded.
120
+ # Example:
121
+ #
122
+ # Minitest::TestTask.create "test:cov" do |t|
123
+ # t.test_prelude = %(require "simplecov")
124
+ # end
103
125
 
104
126
  attr_accessor :test_prelude
105
127
 
data/lib/minitest.rb CHANGED
@@ -6,10 +6,11 @@ require_relative "minitest/parallel"
6
6
  require_relative "minitest/compress"
7
7
 
8
8
  ##
9
- # :include: README.rdoc
9
+ # The top-level namespace for Minitest. Also the location of the main
10
+ # runtime. See +Minitest.run+ for more information.
10
11
 
11
12
  module Minitest
12
- VERSION = "5.25.1" # :nodoc:
13
+ VERSION = "5.26.0" # :nodoc:
13
14
 
14
15
  @@installed_at_exit ||= false
15
16
  @@after_run = []
@@ -35,7 +36,7 @@ module Minitest
35
36
  warn "DEPRECATED: use MT_CPU instead of N for parallel test runs" if ENV["N"] && ENV["N"].to_i > 0
36
37
  n_threads = (ENV["MT_CPU"] || ENV["N"] || Etc.nprocessors).to_i
37
38
 
38
- self.parallel_executor = Parallel::Executor.new n_threads
39
+ self.parallel_executor = Parallel::Executor.new n_threads if n_threads > 1
39
40
 
40
41
  ##
41
42
  # Filter object for backtraces.
@@ -258,12 +259,13 @@ module Minitest
258
259
  # Minitest.process_args
259
260
  # Minitest.init_plugins
260
261
  # Minitest.__run(reporter, options)
261
- # Runnable.runnables.each
262
+ # Runnable.runnables.each |runnable_klass|
262
263
  # runnable_klass.run(reporter, options)
263
- # self.runnable_methods.each
264
- # self.run_one_method(self, runnable_method, reporter)
265
- # Minitest.run_one_method(klass, runnable_method)
266
- # klass.new(runnable_method).run
264
+ # filtered_methods = runnable_methods.select {...}.reject {...}
265
+ # filtered_methods.each |runnable_method|
266
+ # runnable_klass.run_one_method(self, runnable_method, reporter)
267
+ # Minitest.run_one_method(runnable_klass, runnable_method)
268
+ # runnable_klass.new(runnable_method).run
267
269
 
268
270
  def self.run args = []
269
271
  self.load_plugins unless args.delete("--no-plugins") || ENV["MT_NO_PLUGINS"]
@@ -285,18 +287,19 @@ module Minitest
285
287
  reporter.start
286
288
  begin
287
289
  __run reporter, options
290
+ finished = true
288
291
  rescue Interrupt
289
292
  warn "Interrupted. Exiting..."
290
293
  end
291
- self.parallel_executor.shutdown
294
+ self.parallel_executor.shutdown if parallel_executor.respond_to? :shutdown
292
295
 
293
296
  # might have been removed/replaced during init_plugins:
294
297
  summary = reporter.reporters.grep(SummaryReporter).first
295
298
 
296
299
  reporter.report
297
300
 
298
- return empty_run! options if summary && summary.count == 0
299
- reporter.passed?
301
+ return empty_run! options if finished && summary && summary.count == 0
302
+ finished and reporter.passed?
300
303
  end
301
304
 
302
305
  def self.empty_run! options # :nodoc:
@@ -1078,7 +1081,7 @@ module Minitest
1078
1081
  self.error.backtrace
1079
1082
  end
1080
1083
 
1081
- BASE_RE = %r%#{Dir.pwd}/% # :nodoc:
1084
+ BASE_RE = %r%#{Regexp.escape Dir.pwd}/% # :nodoc:
1082
1085
 
1083
1086
  def message # :nodoc:
1084
1087
  bt = Minitest.filter_backtrace(self.backtrace).join("\n ")
@@ -318,13 +318,13 @@ class TestMinitestAssertions < Minitest::Test
318
318
  end
319
319
 
320
320
  def test_assert_equal_string_both_escaped_unescaped_newlines
321
- msg = <<~EOM
321
+ msg = <<~'EOM' # NOTE: single quotes on heredoc
322
322
  --- expected
323
323
  +++ actual
324
324
  @@ -1,2 +1 @@
325
- -"A\\n
325
+ -"A\n
326
326
  -B"
327
- +"A\\n\\\\nB"
327
+ +"A\n\\nB"
328
328
  EOM
329
329
 
330
330
  assert_triggered msg do
@@ -26,7 +26,7 @@ class TestMinitestMock < Minitest::Test
26
26
  def test_blow_up_if_not_called
27
27
  @mock.foo
28
28
 
29
- util_verify_bad "expected meaning_of_life() => 42"
29
+ util_verify_bad "Expected meaning_of_life() => 42"
30
30
  end
31
31
 
32
32
  def test_not_blow_up_if_everything_called
@@ -46,7 +46,7 @@ class TestMinitestMock < Minitest::Test
46
46
  @mock.meaning_of_life
47
47
  @mock.expect :bar, true
48
48
 
49
- util_verify_bad "expected bar() => true"
49
+ util_verify_bad "Expected bar() => true"
50
50
  end
51
51
 
52
52
  def test_blow_up_on_wrong_number_of_arguments
@@ -184,6 +184,73 @@ class TestMinitestMock < Minitest::Test
184
184
  assert @mock == 1, "didn't mock :=="
185
185
  end
186
186
 
187
+ def test_assert_mock__pass
188
+ mock = Minitest::Mock.new
189
+ mock.expect :loose_expectation, true, [Integer]
190
+ mock.loose_expectation 1
191
+
192
+ result = assert_mock mock
193
+
194
+ assert_equal true, result
195
+ end
196
+
197
+ def assert_bad_mock klass, msg
198
+ mock = Minitest::Mock.new
199
+ mock.expect :foo, nil, [:bar]
200
+ mock.expect :foo, nil, [:baz]
201
+
202
+ mock.foo :bar
203
+
204
+ e = assert_raises klass do
205
+ yield mock
206
+ end
207
+
208
+ assert_equal msg, e.message
209
+ end
210
+
211
+ def test_verify__error
212
+ exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]"
213
+ assert_bad_mock MockExpectationError, exp do |mock|
214
+ mock.verify
215
+ end
216
+ end
217
+
218
+ def test_assert_mock__fail
219
+ exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]."
220
+ assert_bad_mock Minitest::Assertion, exp do |mock|
221
+ assert_mock mock
222
+ end
223
+ end
224
+
225
+ def test_assert_mock__fail_msg
226
+ exp = "BLAH.\nExpected foo(:baz) => nil, got [foo(:bar) => nil]."
227
+ assert_bad_mock Minitest::Assertion, exp do |mock|
228
+ assert_mock mock, "BLAH"
229
+ end
230
+ end
231
+
232
+ def test_assert_mock__fail_exp
233
+ exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]."
234
+ assert_bad_mock Minitest::Assertion, exp do |mock|
235
+ describe "X" do
236
+ it "y" do
237
+ _(mock).must_verify
238
+ end
239
+ end.new(:blah).send(:test_0001_y)
240
+ end
241
+ end
242
+
243
+ def test_assert_mock__fail_exp_msg
244
+ exp = "BLAH.\nExpected foo(:baz) => nil, got [foo(:bar) => nil]."
245
+ assert_bad_mock Minitest::Assertion, exp do |mock|
246
+ describe "X" do
247
+ it "y" do
248
+ _(mock).must_verify "BLAH"
249
+ end
250
+ end.new(:blah).send(:test_0001_y)
251
+ end
252
+ end
253
+
187
254
  def test_verify_allows_called_args_to_be_loosely_specified
188
255
  mock = Minitest::Mock.new
189
256
  mock.expect :loose_expectation, true, [Integer]
@@ -238,7 +305,7 @@ class TestMinitestMock < Minitest::Test
238
305
 
239
306
  e = assert_raises(MockExpectationError) { mock.verify }
240
307
 
241
- exp = "expected foo(:baz) => nil, got [foo(:bar) => nil]"
308
+ exp = "Expected foo(:baz) => nil, got [foo(:bar) => nil]"
242
309
 
243
310
  assert_equal exp, e.message
244
311
  end
@@ -252,7 +319,7 @@ class TestMinitestMock < Minitest::Test
252
319
 
253
320
  e = assert_raises(MockExpectationError) { mock.verify }
254
321
 
255
- exp = "expected foo(:bar) => nil, got [foo(:bar) => nil]"
322
+ exp = "Expected foo(:bar) => nil, got [foo(:bar) => nil]"
256
323
 
257
324
  assert_equal exp, e.message
258
325
  end
@@ -276,7 +343,7 @@ class TestMinitestMock < Minitest::Test
276
343
 
277
344
  e = assert_raises(MockExpectationError) { mock.verify }
278
345
 
279
- exp = "expected foo(%p) => nil, got [foo(%p) => nil]" \
346
+ exp = "Expected foo(%p) => nil, got [foo(%p) => nil]" \
280
347
  % [{ :kw => false }, { :kw => true }]
281
348
 
282
349
  assert_equal exp.delete("{}"), e.message
@@ -2,7 +2,7 @@ require "minitest/autorun"
2
2
  require "minitest/metametameta"
3
3
  require "forwardable"
4
4
 
5
- class Runnable
5
+ class FakeTest < Minitest::Test
6
6
  def woot
7
7
  assert true
8
8
  end
@@ -33,7 +33,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
33
33
 
34
34
  def error_test
35
35
  unless defined? @et then
36
- @et = Minitest::Test.new :woot
36
+ @et = FakeTest.new :woot
37
37
  @et.failures << Minitest::UnexpectedError.new(begin
38
38
  raise "no"
39
39
  rescue => e
@@ -56,7 +56,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
56
56
 
57
57
  ex.set_backtrace ary
58
58
 
59
- @sse = Minitest::Test.new :woot
59
+ @sse = FakeTest.new :woot
60
60
  @sse.failures << Minitest::UnexpectedError.new(ex)
61
61
  @sse = Minitest::Result.from @sse
62
62
  end
@@ -65,7 +65,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
65
65
 
66
66
  def fail_test
67
67
  unless defined? @ft then
68
- @ft = Minitest::Test.new :woot
68
+ @ft = FakeTest.new :woot
69
69
  @ft.failures << begin
70
70
  raise Minitest::Assertion, "boo"
71
71
  rescue Minitest::Assertion => e
@@ -77,18 +77,18 @@ class TestMinitestReporter < MetaMetaMetaTestCase
77
77
  end
78
78
 
79
79
  def passing_test
80
- @pt ||= Minitest::Result.from Minitest::Test.new(:woot)
80
+ @pt ||= Minitest::Result.from FakeTest.new(:woot)
81
81
  end
82
82
 
83
83
  def passing_test_with_metadata
84
- test = Minitest::Test.new :woot
84
+ test = FakeTest.new :woot
85
85
  test.metadata[:meta] = :data
86
86
  @pt ||= Minitest::Result.from test
87
87
  end
88
88
 
89
89
  def skip_test
90
90
  unless defined? @st then
91
- @st = Minitest::Test.new :woot
91
+ @st = FakeTest.new :woot
92
92
  @st.failures << begin
93
93
  raise Minitest::Skip
94
94
  rescue Minitest::Assertion => e
@@ -294,7 +294,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
294
294
  Finished in 0.00
295
295
 
296
296
  1) Failure:
297
- Minitest::Test#woot [FILE:LINE]:
297
+ FakeTest#woot [FILE:LINE]:
298
298
  boo
299
299
 
300
300
  1 runs, 0 assertions, 1 failures, 0 errors, 0 skips
@@ -318,7 +318,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
318
318
  Finished in 0.00
319
319
 
320
320
  1) Error:
321
- Minitest::Test#woot:
321
+ FakeTest#woot:
322
322
  RuntimeError: no
323
323
  FILE:LINE:in 'error_test'
324
324
  FILE:LINE:in 'test_report_error'
@@ -344,7 +344,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
344
344
  Finished in 0.00
345
345
 
346
346
  1) Error:
347
- Minitest::Test#woot:
347
+ FakeTest#woot:
348
348
  SystemStackError: 274 -> 12
349
349
  a
350
350
  b
@@ -402,7 +402,7 @@ class TestMinitestReporter < MetaMetaMetaTestCase
402
402
  r.report
403
403
  end
404
404
 
405
- exp = "Minitest::Test#woot [foo.rb:123]"
405
+ exp = "FakeTest#woot [foo.rb:123]"
406
406
 
407
407
  assert_includes io.string, exp
408
408
  end
@@ -212,9 +212,10 @@ describe Minitest::Spec do
212
212
  must_raise
213
213
  must_respond_to
214
214
  must_throw
215
+ must_verify
215
216
  path_must_exist]
216
217
 
217
- bad = %w[not raise throw send output be_silent]
218
+ bad = %w[not raise throw send output be_silent verify]
218
219
 
219
220
  expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
220
221
  expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
@@ -709,8 +710,6 @@ describe Minitest::Spec do
709
710
  end
710
711
 
711
712
  describe Minitest::Spec, :let do
712
- i_suck_and_my_tests_are_order_dependent!
713
-
714
713
  def _count
715
714
  $let_count ||= 0
716
715
  end
@@ -721,21 +720,21 @@ describe Minitest::Spec, :let do
721
720
  end
722
721
 
723
722
  it "is evaluated once per example" do
724
- _(_count).must_equal 0
723
+ exp = _count + 1
725
724
 
726
- _(count).must_equal 1
727
- _(count).must_equal 1
725
+ _(count).must_equal exp
726
+ _(count).must_equal exp
728
727
 
729
- _(_count).must_equal 1
728
+ _(_count).must_equal exp
730
729
  end
731
730
 
732
731
  it "is REALLY evaluated once per example" do
733
- _(_count).must_equal 1
732
+ exp = _count + 1
734
733
 
735
- _(count).must_equal 2
736
- _(count).must_equal 2
734
+ _(count).must_equal exp
735
+ _(count).must_equal exp
737
736
 
738
- _(_count).must_equal 2
737
+ _(_count).must_equal exp
739
738
  end
740
739
 
741
740
  it 'raises an error if the name begins with "test"' do
@@ -952,6 +951,23 @@ class TestMeta < MetaMetaMetaTestCase
952
951
  assert_equal "ExampleB::random_method", spec_b.name
953
952
  end
954
953
 
954
+ def test_name_inside_class
955
+ spec_a = nil
956
+ spec_b = nil
957
+ inside_class_example = Class.new Minitest::Spec
958
+ Object.const_set :InsideClassExample, inside_class_example
959
+ inside_class_example.class_eval do
960
+ spec_a = describe "a" do
961
+ spec_b = describe "b" do; end
962
+ end
963
+ end
964
+
965
+ assert_equal "InsideClassExample::a", spec_a.name
966
+ assert_equal "InsideClassExample::a::b", spec_b.name
967
+ ensure
968
+ Object.send :remove_const, :InsideClassExample
969
+ end
970
+
955
971
  def test_structure
956
972
  x, y, z, * = util_structure
957
973
 
@@ -157,6 +157,24 @@ class TestMinitestUnit < MetaMetaMetaTestCase
157
157
  refute_predicate test, :skipped?
158
158
  end
159
159
 
160
+ def test_skipped_is_reachable
161
+ test_class = Class.new FakeNamedTest do
162
+ def test_omg
163
+ skip
164
+ ensure
165
+ flunk unless skipped?
166
+ end
167
+ end
168
+
169
+ test = test_class.new :test_omg
170
+ test.run
171
+
172
+ refute_predicate test, :error?
173
+ refute_predicate test, :passed?
174
+
175
+ assert_predicate test, :skipped?
176
+ end
177
+
160
178
  def util_expand_bt bt
161
179
  bt.map { |f| f.start_with?(".") ? File.expand_path(f) : f }
162
180
  end
@@ -644,7 +662,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
644
662
  2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
645
663
  EOM
646
664
 
647
- skip if Minitest.parallel_executor.size < 2 # locks up test runner if 1 CPU
665
+ skip unless Minitest.parallel_executor # locks up test runner if 1 CPU
648
666
 
649
667
  assert_report expected do |reporter|
650
668
  reporter.extend Module.new {
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.25.1
4
+ version: 5.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain:
11
10
  - |
12
11
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBCDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
12
+ MIIDPjCCAiagAwIBAgIBCTANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
13
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTI0MDEwMjIxMjEyM1oXDTI1MDEwMTIxMjEyM1owRTETMBEGA1UE
14
+ GRYDY29tMB4XDTI1MDEwNjIzMjcwMVoXDTI2MDEwNjIzMjcwMVowRTETMBEGA1UE
16
15
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
16
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
17
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +21,14 @@ cert_chain:
22
21
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
22
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
23
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
25
- AQCygvpmncmkiSs9r/Kceo4bBPDszhTv6iBi4LwMReqnFrpNLMOWJw7xi8x+3eL2
26
- XS09ZPNOt2zm70KmFouBMgOysnDY4k2dE8uF6B8JbZOO8QfalW+CoNBliefOTcn2
27
- bg5IOP7UoGM5lC174/cbDJrJnRG9bzig5FAP0mvsgA8zgTRXQzIUAZEo92D5K7p4
28
- B4/O998ho6BSOgYBI9Yk1ttdCtti6Y+8N9+fZESsjtWMykA+WXWeGUScHqiU+gH8
29
- S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
30
- deKfBjgVAq7EYHu1AczzlUly
24
+ AQAC0WQJcPOWPFwkojhzweilRVjTJ19UiLhiBTw3C1wJO3LVdBkWDmnnhAmKuX4D
25
+ r7vjQvESlABGIPdutI1Yl7mrHQzTkfLfXvNN6MT0nLChPyIYauT6SZZxubwJrUfA
26
+ 7R0c2CJTIboZ0XaGpLsXqHEF1c29H7TV1QvVuqKAN2mCjh4N82QVn+ZKtys28AwT
27
+ 6GfQX2fqLoi4KSc7xIzHKaNzqxeOICmJofk9w5VZ2rRN6yes8jvFYwz9HR41wdj8
28
+ bwfinv7Yp5fA6AysuZLhCykyfDuZVRrUp0Vb68YCKsLjJly/Theak+euNTxvHsB+
29
+ al9oSgPPHICMEX65qvLywitx
31
30
  -----END CERTIFICATE-----
32
- date: 2024-08-16 00:00:00.000000000 Z
31
+ date: 1980-01-02 00:00:00.000000000 Z
33
32
  dependencies:
34
33
  - !ruby/object:Gem::Dependency
35
34
  name: rdoc
@@ -57,14 +56,14 @@ dependencies:
57
56
  requirements:
58
57
  - - "~>"
59
58
  - !ruby/object:Gem::Version
60
- version: '4.2'
59
+ version: '4.3'
61
60
  type: :development
62
61
  prerelease: false
63
62
  version_requirements: !ruby/object:Gem::Requirement
64
63
  requirements:
65
64
  - - "~>"
66
65
  - !ruby/object:Gem::Version
67
- version: '4.2'
66
+ version: '4.3'
68
67
  description: |-
69
68
  minitest provides a complete suite of testing facilities supporting
70
69
  TDD, BDD, mocking, and benchmarking.
@@ -167,7 +166,6 @@ metadata:
167
166
  homepage_uri: https://github.com/minitest/minitest
168
167
  bug_tracker_uri: https://github.com/minitest/minitest/issues
169
168
  changelog_uri: https://github.com/minitest/minitest/blob/master/History.rdoc
170
- post_install_message:
171
169
  rdoc_options:
172
170
  - "--main"
173
171
  - README.rdoc
@@ -177,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
175
  requirements:
178
176
  - - ">="
179
177
  - !ruby/object:Gem::Version
180
- version: '2.6'
178
+ version: '2.7'
181
179
  - - "<"
182
180
  - !ruby/object:Gem::Version
183
181
  version: '4.0'
@@ -187,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
185
  - !ruby/object:Gem::Version
188
186
  version: '0'
189
187
  requirements: []
190
- rubygems_version: 3.5.15
191
- signing_key:
188
+ rubygems_version: 3.7.2
192
189
  specification_version: 4
193
190
  summary: minitest provides a complete suite of testing facilities supporting TDD,
194
191
  BDD, mocking, and benchmarking
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- 5�1�4)B�I�e�2�����vK����]"xQ�#y�^���e��|6��AϹnk�'�LK���0�HK�XK�hvv���׭�;��>Af&=pi�ChTzg�u7E(\���L��t5Uy+�`yŗt����K��Q1[n��u���nT���po�&@)</Tˊ㲧Cǁ�n�j�jj�ֳ��mBYKW�Z�\�p1�sz�|ǎztQ~J��
1
+ UA�Xf�v ���d�-$#���� ,�w��L�Vn�FxE�$XP� �@���_�*8�e7m�N��Tt��Q�}"6����=y� �n�.�:Rb�I3�S -���Z�)��Җ���tRH,Z��g��QkŪ
2
+ yd[!"�;U�#�rȔq�_�FD]B��NH���l��4S�� ��Rɰ��9~K�ڵd/ N٦�Ϫp�����:mI�݀�".�KO�3w E� ��K�ڑ��g����9�L�!�}@�d٠Y