minitest 5.25.1 → 5.25.3
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/lib/minitest/mock.rb +21 -4
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/spec.rb +9 -8
- data/lib/minitest.rb +3 -2
- data/test/minitest/test_minitest_mock.rb +72 -5
- data/test/minitest/test_minitest_reporter.rb +11 -11
- data/test/minitest/test_minitest_spec.rb +19 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: a27292f346c716aae8b4a43bcb3297cb71155663c66b60e4f2db2713fb38ba21
|
4
|
+
data.tar.gz: 61e9d14ed5c142a0e16a185137f7ed2e7fd0703975232ebbaa3b0b98283045cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c6a79d2bb013e251f4a216e28c7170170691669f4a31eb65d6c078bfeafba31992631c1f6071511a81ac510a8abc93cdb6dfeefa8a9a988f33abcb0d9c6ed9
|
7
|
+
data.tar.gz: ceb3c98cfa67aa52743f2a197dacf19175d7eb68b32401a54d55212714f2700132349a01189b050865002c95840845f95d3f73c423ebf383c8e4f0250ddb764e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== 5.25.3 / 2024-12-03
|
2
|
+
|
3
|
+
* 5 bug fixes:
|
4
|
+
|
5
|
+
* Fixed assert_mock to fail instead of raise on unmet mock expectations.
|
6
|
+
* Fixed assert_mock to take an optional message argument.
|
7
|
+
* Fixed formatting of unmet mock expectation messages.
|
8
|
+
* Fixed missing must_verify expectation to match assert_mock.
|
9
|
+
* minitest/pride: Fixed to use true colors with *-direct terminals (bk2204)
|
10
|
+
|
11
|
+
=== 5.25.2 / 2024-11-21
|
12
|
+
|
13
|
+
* 4 bug fixes:
|
14
|
+
|
15
|
+
* Include class name in spec name. (thomasmarshall)
|
16
|
+
* Fixed 'redefining object_id' warning from ruby 3.4. (mattbrictson)
|
17
|
+
* Minitest top-level namespace no longer includes entire contents of README.rdoc. Too much!
|
18
|
+
* Refactored spec's describe to more cleanly determine the superclass and name
|
19
|
+
|
1
20
|
=== 5.25.1 / 2024-08-16
|
2
21
|
|
3
22
|
* 2 bug fixes:
|
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, "
|
146
|
-
raise MockExpectationError, "
|
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,27 @@ 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
|
270
|
+
end
|
271
|
+
|
255
272
|
##
|
256
273
|
# Object extensions for Minitest::Mock.
|
257
274
|
|
@@ -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
@@ -81,14 +81,15 @@ module Kernel
|
|
81
81
|
|
82
82
|
def describe desc, *additional_desc, &block # :doc:
|
83
83
|
stack = Minitest::Spec.describe_stack
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
is_spec_class = Class === self && kind_of?(Minitest::Spec::DSL)
|
85
|
+
name = [stack.last, desc, *additional_desc]
|
86
|
+
name.prepend self if stack.empty? && is_spec_class
|
87
|
+
sclas =
|
88
|
+
stack.last \
|
89
|
+
|| (is_spec_class && self) \
|
90
|
+
|| Minitest::Spec.spec_type(desc, *additional_desc)
|
91
|
+
|
92
|
+
cls = sclas.create name.compact.join("::"), desc
|
92
93
|
|
93
94
|
stack.push cls
|
94
95
|
cls.class_eval(&block)
|
data/lib/minitest.rb
CHANGED
@@ -6,10 +6,11 @@ require_relative "minitest/parallel"
|
|
6
6
|
require_relative "minitest/compress"
|
7
7
|
|
8
8
|
##
|
9
|
-
#
|
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.
|
13
|
+
VERSION = "5.25.3" # :nodoc:
|
13
14
|
|
14
15
|
@@installed_at_exit ||= false
|
15
16
|
@@after_run = []
|
@@ -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 "
|
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 "
|
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 = "
|
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 = "
|
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 = "
|
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
|
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 =
|
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 =
|
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 =
|
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
|
80
|
+
@pt ||= Minitest::Result.from FakeTest.new(:woot)
|
81
81
|
end
|
82
82
|
|
83
83
|
def passing_test_with_metadata
|
84
|
-
test =
|
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 =
|
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
|
-
|
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
|
-
|
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
|
-
|
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 = "
|
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)}/ }
|
@@ -952,6 +953,23 @@ class TestMeta < MetaMetaMetaTestCase
|
|
952
953
|
assert_equal "ExampleB::random_method", spec_b.name
|
953
954
|
end
|
954
955
|
|
956
|
+
def test_name_inside_class
|
957
|
+
spec_a = nil
|
958
|
+
spec_b = nil
|
959
|
+
inside_class_example = Class.new Minitest::Spec
|
960
|
+
Object.const_set :InsideClassExample, inside_class_example
|
961
|
+
inside_class_example.class_eval do
|
962
|
+
spec_a = describe "a" do
|
963
|
+
spec_b = describe "b" do; end
|
964
|
+
end
|
965
|
+
end
|
966
|
+
|
967
|
+
assert_equal "InsideClassExample::a", spec_a.name
|
968
|
+
assert_equal "InsideClassExample::a::b", spec_b.name
|
969
|
+
ensure
|
970
|
+
Object.send :remove_const, :InsideClassExample
|
971
|
+
end
|
972
|
+
|
955
973
|
def test_structure
|
956
974
|
x, y, z, * = util_structure
|
957
975
|
|
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.25.
|
4
|
+
version: 5.25.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
S7043fq9EbQdBr2AXdj92+CDwuTfHI6/Hj5FVBDULufrJaan4xUgL70Hvc6pTTeW
|
30
30
|
deKfBjgVAq7EYHu1AczzlUly
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2024-
|
32
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -187,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
|
-
rubygems_version: 3.5.
|
190
|
+
rubygems_version: 3.5.23
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: minitest provides a complete suite of testing facilities supporting TDD,
|
metadata.gz.sig
CHANGED
Binary file
|