minitest 5.25.2 → 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 +10 -0
- data/lib/minitest/mock.rb +18 -4
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +72 -5
- data/test/minitest/test_minitest_spec.rb +2 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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,13 @@
|
|
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
|
+
|
1
11
|
=== 5.25.2 / 2024-11-21
|
2
12
|
|
3
13
|
* 4 bug fixes:
|
data/lib/minitest/mock.rb
CHANGED
@@ -145,8 +145,8 @@ module Minitest # :nodoc:
|
|
145
145
|
def verify
|
146
146
|
@expected_calls.each do |name, expected|
|
147
147
|
actual = @actual_calls.fetch name, nil # defaults to []
|
148
|
-
raise MockExpectationError, "
|
149
|
-
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
|
150
150
|
actual.size < expected.size
|
151
151
|
end
|
152
152
|
true
|
@@ -248,13 +248,27 @@ end
|
|
248
248
|
|
249
249
|
module Minitest::Assertions
|
250
250
|
##
|
251
|
-
# Assert that the mock verifies correctly.
|
251
|
+
# Assert that the mock verifies correctly and fail if not.
|
252
252
|
|
253
|
-
def assert_mock mock
|
253
|
+
def assert_mock mock, msg = nil
|
254
254
|
assert mock.verify
|
255
|
+
rescue MockExpectationError => e
|
256
|
+
msg = message(msg) { e.message }
|
257
|
+
flunk msg
|
255
258
|
end
|
256
259
|
end
|
257
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
|
+
|
258
272
|
##
|
259
273
|
# Object extensions for Minitest::Mock.
|
260
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.rb
CHANGED
@@ -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
|
@@ -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)}/ }
|
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
|
metadata.gz.sig
CHANGED
Binary file
|