minitest 5.26.2 → 6.0.0.a1
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 +80 -0
- data/Manifest.txt +13 -4
- data/README.rdoc +8 -90
- data/Rakefile +7 -1
- data/bin/minitest +5 -0
- data/lib/minitest/assertions.rb +32 -64
- data/lib/minitest/autorun.rb +3 -4
- data/lib/minitest/benchmark.rb +2 -2
- data/lib/minitest/bisect.rb +306 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +4 -16
- data/lib/minitest/parallel.rb +3 -3
- data/lib/minitest/path_expander.rb +418 -0
- data/lib/minitest/pride.rb +2 -2
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/server.rb +45 -0
- data/lib/minitest/server_plugin.rb +84 -0
- data/lib/minitest/spec.rb +4 -33
- data/lib/minitest/sprint.rb +104 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +8 -13
- data/lib/minitest/test_task.rb +6 -13
- data/lib/minitest.rb +62 -91
- data/test/minitest/metametameta.rb +1 -1
- data/test/minitest/test_bisect.rb +235 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +41 -101
- data/test/minitest/test_minitest_reporter.rb +6 -5
- data/test/minitest/test_minitest_spec.rb +41 -117
- data/test/minitest/test_minitest_test.rb +21 -100
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +149 -0
- data.tar.gz.sig +0 -0
- metadata +50 -14
- metadata.gz.sig +0 -0
- data/.autotest +0 -34
- data/lib/minitest/mock.rb +0 -327
- data/lib/minitest/unit.rb +0 -42
- data/test/minitest/test_minitest_mock.rb +0 -1213
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a01b47e47e72a229e83d2809ca755928bdd25f359c933e22c72b5ac8a171755f
|
|
4
|
+
data.tar.gz: 66fa45d45a03fb1432654237fa2dc74d955667223e22b11c81b589aafce07289
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7469ea92dcfe5adfe2ffe53178ad0acd4f5fc699359e52c7cfcb7519ce322294a0cd29c171bef2226618cb5d64f4f73069a2ef54fde664e78a31404e53d9b6bc
|
|
7
|
+
data.tar.gz: b12bf7908a6fcf0e22fbac91e2d68b7a30ba86a8cdb87dbe9b55adf617df6275afc6cbb97f0c4e197f762bd836aafe1c7f6e2fe22262eec5aa3eb1bae5e5699d
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
+
=== 6.0.0.a.1 / 2025-12-15
|
|
2
|
+
|
|
3
|
+
This is an alpha level release in order to get feedback. I'm pretty
|
|
4
|
+
settled on integrating minitest-sprint's minitest cmdline but less
|
|
5
|
+
sold on having bisect+server integrated.
|
|
6
|
+
|
|
7
|
+
Please give me feedback here: https://github.com/minitest/minitest/issues/1040
|
|
8
|
+
|
|
9
|
+
Oh god... here we go... (again)
|
|
10
|
+
|
|
11
|
+
* 8 deaths in the family(!!):
|
|
12
|
+
|
|
13
|
+
* Deleted MiniTest and MiniTest::Unit::TestCase compatibility namespaces.
|
|
14
|
+
* Deleted all use of Marshal for serialization.
|
|
15
|
+
* Deleted maglev? and rubinius? guard methods. LOL.
|
|
16
|
+
* Deleted all minitest/spec expectations from Object. Use _/value/expect.
|
|
17
|
+
* Dropped minitest/mock.rb. This has been extracted to the minitest-mock gem.
|
|
18
|
+
* assert_equal(nil, value) no longer allowed. Use assert_nil to be explicit.
|
|
19
|
+
* Removed assert_send. Use assert_predicate or assert_operator.
|
|
20
|
+
* Removed Minitest::Test#class_name.
|
|
21
|
+
|
|
22
|
+
* 7 major (oft incompatible) changes:
|
|
23
|
+
|
|
24
|
+
* Big: Major refactored MT6's run path!
|
|
25
|
+
* Minitest.__run -> Minitest.run_all_suites
|
|
26
|
+
* Runnable.run -> Runnable.run_suite & Runnable.filter_runnable_methods
|
|
27
|
+
* Runnable.run_one_method -> Runnable.run
|
|
28
|
+
* Removed Minitest.run_one_method (might bring it back to raise?)
|
|
29
|
+
* Removed deprecated ENV["N"] to specify number of parallel tests. Use MT_CPU.
|
|
30
|
+
* Renamed options[:filter] to options[:include], added --include cmdline option.
|
|
31
|
+
* --name is still handled, but that will be removed in the future.
|
|
32
|
+
* Renamed Minitest::Runnable#test_order to #run_order.
|
|
33
|
+
* If message is passed a proc then that proc overrides all other output.
|
|
34
|
+
* They are no longer chained!
|
|
35
|
+
* And it does less for formatting of your output.
|
|
36
|
+
* Removed reporter arg from with_info_handler as it has never(?) been used. (HACK?)
|
|
37
|
+
* Plugin loading is now opt-in!
|
|
38
|
+
* Require the plugin in your test_helper.
|
|
39
|
+
* Or use Minitest.load :x
|
|
40
|
+
* Or call Minitest.load_plugins for the old autoloading behavior.
|
|
41
|
+
|
|
42
|
+
* 5 additions:
|
|
43
|
+
|
|
44
|
+
* Added minitest-sprint's minitest cmdline, now with line support.
|
|
45
|
+
* Added minitest-bisect. Run with minitest --bisect or -b.
|
|
46
|
+
* Added minitest-server.
|
|
47
|
+
* Added minitest/complete to help with shell's tab-completion of tests.
|
|
48
|
+
* Vendored latest version of path_expander.
|
|
49
|
+
|
|
50
|
+
* 5 other:
|
|
51
|
+
|
|
52
|
+
* Bumped to ruby 3.2+.
|
|
53
|
+
* Removed obsolete conditional for CompositeReporter#prerecord.
|
|
54
|
+
* Removed obsolete version guards around Minitest::Result in reporters.
|
|
55
|
+
* assert_operator and assert_predicate both call assert_respond_to first.
|
|
56
|
+
* Assertions reuse themselves a lot more. Bumps assertion count in some places.
|
|
57
|
+
|
|
58
|
+
* 1 voodoo:
|
|
59
|
+
|
|
60
|
+
* HACK: does anyone require minitest/test w/o minitest? that's crazy right?
|
|
61
|
+
|
|
62
|
+
=== 5.27.0 / 2025-12-11
|
|
63
|
+
|
|
64
|
+
* 1 major enhancement:
|
|
65
|
+
|
|
66
|
+
* Adding post install message announcing the EOL for minitest 5!
|
|
67
|
+
|
|
68
|
+
* 2 minor enhancements:
|
|
69
|
+
|
|
70
|
+
* Removed TestTask::Work#initialize since Queue can now initialize with an Enumerable! AMAZING!
|
|
71
|
+
* Use Kernel#warn uplevel argument for nicer warnings. (byroot)
|
|
72
|
+
|
|
73
|
+
* 5 bug fixes:
|
|
74
|
+
|
|
75
|
+
* Cleaned up option aliasing a tad.
|
|
76
|
+
* Removed obsolete conditional for prerecord
|
|
77
|
+
* Removed obsolete guards around Warning.
|
|
78
|
+
* Removed obsolete version guards for pattern matching assertions.
|
|
79
|
+
* Switched all internal requires to require_relative.
|
|
80
|
+
|
|
1
81
|
=== 5.26.2 / 2025-11-17
|
|
2
82
|
|
|
3
83
|
* 5 bug fixes:
|
data/Manifest.txt
CHANGED
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
.autotest
|
|
2
1
|
History.rdoc
|
|
3
2
|
Manifest.txt
|
|
4
3
|
README.rdoc
|
|
5
4
|
Rakefile
|
|
5
|
+
bin/minitest
|
|
6
6
|
design_rationale.rb
|
|
7
7
|
lib/hoe/minitest.rb
|
|
8
8
|
lib/minitest.rb
|
|
9
9
|
lib/minitest/assertions.rb
|
|
10
10
|
lib/minitest/autorun.rb
|
|
11
11
|
lib/minitest/benchmark.rb
|
|
12
|
+
lib/minitest/bisect.rb
|
|
13
|
+
lib/minitest/complete.rb
|
|
12
14
|
lib/minitest/compress.rb
|
|
13
15
|
lib/minitest/error_on_warning.rb
|
|
14
16
|
lib/minitest/expectations.rb
|
|
17
|
+
lib/minitest/find_minimal_combination.rb
|
|
15
18
|
lib/minitest/hell.rb
|
|
16
19
|
lib/minitest/manual_plugins.rb
|
|
17
|
-
lib/minitest/mock.rb
|
|
18
20
|
lib/minitest/parallel.rb
|
|
21
|
+
lib/minitest/path_expander.rb
|
|
19
22
|
lib/minitest/pride.rb
|
|
20
23
|
lib/minitest/pride_plugin.rb
|
|
24
|
+
lib/minitest/server.rb
|
|
25
|
+
lib/minitest/server_plugin.rb
|
|
21
26
|
lib/minitest/spec.rb
|
|
27
|
+
lib/minitest/sprint.rb
|
|
28
|
+
lib/minitest/sprint_plugin.rb
|
|
22
29
|
lib/minitest/test.rb
|
|
23
30
|
lib/minitest/test_task.rb
|
|
24
|
-
lib/minitest/unit.rb
|
|
25
31
|
test/minitest/metametameta.rb
|
|
32
|
+
test/minitest/test_bisect.rb
|
|
33
|
+
test/minitest/test_find_minimal_combination.rb
|
|
26
34
|
test/minitest/test_minitest_assertions.rb
|
|
27
35
|
test/minitest/test_minitest_benchmark.rb
|
|
28
|
-
test/minitest/test_minitest_mock.rb
|
|
29
36
|
test/minitest/test_minitest_reporter.rb
|
|
30
37
|
test/minitest/test_minitest_spec.rb
|
|
31
38
|
test/minitest/test_minitest_test.rb
|
|
32
39
|
test/minitest/test_minitest_test_task.rb
|
|
40
|
+
test/minitest/test_server.rb
|
|
41
|
+
test/minitest/test_path_expander.rb
|
data/README.rdoc
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
= minitest/{test,spec,
|
|
1
|
+
= minitest/{test,spec,benchmark}
|
|
2
2
|
|
|
3
|
-
home :: https://
|
|
3
|
+
home :: https://minite.st/
|
|
4
|
+
code :: https://github.com/minitest/minitest
|
|
4
5
|
bugs :: https://github.com/minitest/minitest/issues
|
|
5
6
|
rdoc :: https://docs.seattlerb.org/minitest
|
|
6
7
|
clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
|
|
7
|
-
vim :: https://github.com/sunaku/vim-ruby-minitest
|
|
8
8
|
emacs:: https://github.com/arthurnn/minitest-emacs
|
|
9
|
+
vim :: https://github.com/vim-test/vim-test
|
|
9
10
|
|
|
10
11
|
== DESCRIPTION:
|
|
11
12
|
|
|
12
13
|
minitest provides a complete suite of testing facilities supporting
|
|
13
|
-
TDD, BDD,
|
|
14
|
+
TDD, BDD, and benchmarking.
|
|
14
15
|
|
|
15
16
|
"I had a class with Jim Weirich on testing last week and we were
|
|
16
17
|
allowed to choose our testing frameworks. Kirk Haines and I were
|
|
@@ -36,9 +37,6 @@ algorithms in a repeatable manner. Now you can assert that your newb
|
|
|
36
37
|
co-worker doesn't replace your linear algorithm with an exponential
|
|
37
38
|
one!
|
|
38
39
|
|
|
39
|
-
minitest/mock by Steven Baker, is a beautifully tiny mock (and stub)
|
|
40
|
-
object framework.
|
|
41
|
-
|
|
42
40
|
minitest/pride shows pride in testing and adds coloring to your test
|
|
43
41
|
output. I guess it is an example of how to write IO pipes too. :P
|
|
44
42
|
|
|
@@ -68,7 +66,6 @@ extract-method refactorings still apply.
|
|
|
68
66
|
* minitest/autorun - the easy and explicit way to run all your tests.
|
|
69
67
|
* minitest/test - a very fast, simple, and clean test system.
|
|
70
68
|
* minitest/spec - a very fast, simple, and clean spec system.
|
|
71
|
-
* minitest/mock - a simple and clean mock/stub system.
|
|
72
69
|
* minitest/benchmark - an awesome way to assert your algorithm's performance.
|
|
73
70
|
* minitest/pride - show your pride in testing!
|
|
74
71
|
* minitest/test_task - a full-featured and clean rake task generator.
|
|
@@ -190,85 +187,6 @@ outputs something like:
|
|
|
190
187
|
|
|
191
188
|
Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
192
189
|
|
|
193
|
-
=== Mocks
|
|
194
|
-
|
|
195
|
-
Mocks and stubs defined using terminology by Fowler & Meszaros at
|
|
196
|
-
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
197
|
-
|
|
198
|
-
"Mocks are pre-programmed with expectations which form a specification
|
|
199
|
-
of the calls they are expected to receive. They can throw an exception
|
|
200
|
-
if they receive a call they don't expect and are checked during
|
|
201
|
-
verification to ensure they got all the calls they were expecting."
|
|
202
|
-
|
|
203
|
-
class MemeAsker
|
|
204
|
-
def initialize(meme)
|
|
205
|
-
@meme = meme
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def ask(question)
|
|
209
|
-
method = question.tr(" ", "_") + "?"
|
|
210
|
-
@meme.__send__(method)
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
require "minitest/autorun"
|
|
215
|
-
|
|
216
|
-
describe MemeAsker, :ask do
|
|
217
|
-
describe "when passed an unpunctuated question" do
|
|
218
|
-
it "should invoke the appropriate predicate method on the meme" do
|
|
219
|
-
@meme = Minitest::Mock.new
|
|
220
|
-
@meme_asker = MemeAsker.new @meme
|
|
221
|
-
@meme.expect :will_it_blend?, :return_value
|
|
222
|
-
|
|
223
|
-
@meme_asker.ask "will it blend"
|
|
224
|
-
|
|
225
|
-
@meme.verify
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
==== Multi-threading and Mocks
|
|
231
|
-
|
|
232
|
-
Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
|
|
233
|
-
you can use regular ruby patterns and facilities like local variables. Here's
|
|
234
|
-
an example of asserting that code inside a thread is run:
|
|
235
|
-
|
|
236
|
-
def test_called_inside_thread
|
|
237
|
-
called = false
|
|
238
|
-
pr = Proc.new { called = true }
|
|
239
|
-
thread = Thread.new(&pr)
|
|
240
|
-
thread.join
|
|
241
|
-
assert called, "proc not called"
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
=== Stubs
|
|
245
|
-
|
|
246
|
-
Mocks and stubs are defined using terminology by Fowler & Meszaros at
|
|
247
|
-
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
248
|
-
|
|
249
|
-
"Stubs provide canned answers to calls made during the test".
|
|
250
|
-
|
|
251
|
-
Minitest's stub method overrides a single method for the duration of
|
|
252
|
-
the block.
|
|
253
|
-
|
|
254
|
-
def test_stale_eh
|
|
255
|
-
obj_under_test = Something.new
|
|
256
|
-
|
|
257
|
-
refute obj_under_test.stale?
|
|
258
|
-
|
|
259
|
-
Time.stub :now, Time.at(0) do # stub goes away once the block is done
|
|
260
|
-
assert obj_under_test.stale?
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
A note on stubbing: In order to stub a method, the method must
|
|
265
|
-
actually exist prior to stubbing. Use a singleton method to create a
|
|
266
|
-
new non-existing method:
|
|
267
|
-
|
|
268
|
-
def obj_under_test.fake_method
|
|
269
|
-
...
|
|
270
|
-
end
|
|
271
|
-
|
|
272
190
|
=== Running Your Tests
|
|
273
191
|
|
|
274
192
|
Ideally, you'll use a rake task to run your tests (see below), either
|
|
@@ -764,8 +682,8 @@ rematch :: Declutter your test files from large hardcoded da
|
|
|
764
682
|
and update them automatically when your code changes.
|
|
765
683
|
rspec2minitest :: Easily translate any RSpec matchers to Minitest
|
|
766
684
|
assertions and expectations.
|
|
767
|
-
stubberry :: Multiple stubbing 'berries', sweet and useful
|
|
768
|
-
stub helpers and assertions. ( stub_must,
|
|
685
|
+
stubberry :: Multiple stubbing 'berries', sweet and useful
|
|
686
|
+
stub helpers and assertions. ( stub_must,
|
|
769
687
|
assert_method_called, stubbing ORM objects by id )
|
|
770
688
|
|
|
771
689
|
== Unknown Extensions:
|
|
@@ -796,7 +714,7 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
|
796
714
|
|
|
797
715
|
== REQUIREMENTS:
|
|
798
716
|
|
|
799
|
-
* Ruby 2
|
|
717
|
+
* Ruby 3.2+. No magic is involved. I hope.
|
|
800
718
|
|
|
801
719
|
== INSTALL:
|
|
802
720
|
|
data/Rakefile
CHANGED
|
@@ -4,14 +4,20 @@ require "hoe"
|
|
|
4
4
|
$:.unshift "lib" # to pick up lib/minitest/test_task.rb when minitest not installed
|
|
5
5
|
|
|
6
6
|
Hoe.plugin :seattlerb
|
|
7
|
+
Hoe.plugin :isolate
|
|
7
8
|
Hoe.plugin :rdoc
|
|
9
|
+
Hoe.plugin :cov
|
|
8
10
|
|
|
9
11
|
Hoe.spec "minitest" do
|
|
10
12
|
developer "Ryan Davis", "ryand-ruby@zenspider.com"
|
|
11
13
|
|
|
12
14
|
license "MIT"
|
|
13
15
|
|
|
14
|
-
require_ruby_version ">= 3.
|
|
16
|
+
require_ruby_version ">= 3.2"
|
|
17
|
+
|
|
18
|
+
dependency "prism", "~> 1.5"
|
|
19
|
+
|
|
20
|
+
self.cov_filter = %w[ tmp ]
|
|
15
21
|
end
|
|
16
22
|
|
|
17
23
|
desc "Find missing expectations"
|
data/bin/minitest
ADDED
data/lib/minitest/assertions.rb
CHANGED
|
@@ -186,9 +186,8 @@ module Minitest
|
|
|
186
186
|
# Fails unless +obj+ is empty.
|
|
187
187
|
|
|
188
188
|
def assert_empty obj, msg = nil
|
|
189
|
-
msg = message(msg) { "Expected #{mu_pp
|
|
190
|
-
|
|
191
|
-
assert obj.empty?, msg
|
|
189
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
|
|
190
|
+
assert_predicate obj, :empty?, msg
|
|
192
191
|
end
|
|
193
192
|
|
|
194
193
|
def _where # :nodoc:
|
|
@@ -196,8 +195,6 @@ module Minitest
|
|
|
196
195
|
.split(":in ", 2).first # clean up noise
|
|
197
196
|
end
|
|
198
197
|
|
|
199
|
-
E = "" # :nodoc:
|
|
200
|
-
|
|
201
198
|
##
|
|
202
199
|
# Fails unless <tt>exp == act</tt> printing the difference between
|
|
203
200
|
# the two, if possible.
|
|
@@ -212,18 +209,11 @@ module Minitest
|
|
|
212
209
|
# See also: Minitest::Assertions.diff
|
|
213
210
|
|
|
214
211
|
def assert_equal exp, act, msg = nil
|
|
215
|
-
msg = message(msg,
|
|
216
|
-
result = assert exp == act, msg
|
|
212
|
+
msg = message(msg, nil) { diff exp, act }
|
|
217
213
|
|
|
218
|
-
if nil
|
|
219
|
-
if Minitest::VERSION >= "6" then
|
|
220
|
-
refute_nil exp, "Use assert_nil if expecting nil."
|
|
221
|
-
else
|
|
222
|
-
warn "DEPRECATED: Use assert_nil if expecting nil from #{_where}. This will fail in Minitest 6."
|
|
223
|
-
end
|
|
224
|
-
end
|
|
214
|
+
refute_nil exp, message { "Use assert_nil if expecting nil" } if exp.nil? # don't count
|
|
225
215
|
|
|
226
|
-
|
|
216
|
+
assert exp == act, msg
|
|
227
217
|
end
|
|
228
218
|
|
|
229
219
|
##
|
|
@@ -255,8 +245,7 @@ module Minitest
|
|
|
255
245
|
msg = message(msg) {
|
|
256
246
|
"Expected #{mu_pp collection} to include #{mu_pp obj}"
|
|
257
247
|
}
|
|
258
|
-
|
|
259
|
-
assert collection.include?(obj), msg
|
|
248
|
+
assert_operator collection, :include?, obj, msg
|
|
260
249
|
end
|
|
261
250
|
|
|
262
251
|
##
|
|
@@ -308,6 +297,7 @@ module Minitest
|
|
|
308
297
|
|
|
309
298
|
def assert_operator o1, op, o2 = UNDEFINED, msg = nil
|
|
310
299
|
return assert_predicate o1, op, msg if UNDEFINED == o2
|
|
300
|
+
assert_respond_to o1, op
|
|
311
301
|
msg = message(msg) { "Expected #{mu_pp o1} to be #{op} #{mu_pp o2}" }
|
|
312
302
|
assert o1.__send__(op, o2), msg
|
|
313
303
|
end
|
|
@@ -368,15 +358,12 @@ module Minitest
|
|
|
368
358
|
# error.
|
|
369
359
|
|
|
370
360
|
def assert_pattern
|
|
371
|
-
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
372
361
|
flunk "assert_pattern requires a block to capture errors." unless block_given?
|
|
373
362
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
flunk e.message
|
|
379
|
-
end
|
|
363
|
+
yield
|
|
364
|
+
pass
|
|
365
|
+
rescue NoMatchingPatternError => e
|
|
366
|
+
flunk e.message
|
|
380
367
|
end
|
|
381
368
|
|
|
382
369
|
##
|
|
@@ -389,6 +376,7 @@ module Minitest
|
|
|
389
376
|
# str.must_be :empty?
|
|
390
377
|
|
|
391
378
|
def assert_predicate o1, op, msg = nil
|
|
379
|
+
assert_respond_to o1, op, include_all:true
|
|
392
380
|
msg = message(msg) { "Expected #{mu_pp o1} to be #{op}" }
|
|
393
381
|
assert o1.__send__(op), msg
|
|
394
382
|
end
|
|
@@ -448,9 +436,7 @@ module Minitest
|
|
|
448
436
|
# include_all defaults to false to match Object#respond_to?
|
|
449
437
|
|
|
450
438
|
def assert_respond_to obj, meth, msg = nil, include_all: false
|
|
451
|
-
msg = message(msg) {
|
|
452
|
-
"Expected #{mu_pp obj} (#{obj.class}) to respond to ##{meth}"
|
|
453
|
-
}
|
|
439
|
+
msg = message(msg) { "Expected #{mu_pp obj} (#{obj.class}) to respond to ##{meth}" }
|
|
454
440
|
assert obj.respond_to?(meth, include_all), msg
|
|
455
441
|
end
|
|
456
442
|
|
|
@@ -465,21 +451,6 @@ module Minitest
|
|
|
465
451
|
assert exp.equal?(act), msg
|
|
466
452
|
end
|
|
467
453
|
|
|
468
|
-
##
|
|
469
|
-
# +send_ary+ is a receiver, message and arguments.
|
|
470
|
-
#
|
|
471
|
-
# Fails unless the call returns a true value
|
|
472
|
-
|
|
473
|
-
def assert_send send_ary, m = nil
|
|
474
|
-
warn "DEPRECATED: assert_send. From #{_where}"
|
|
475
|
-
|
|
476
|
-
recv, msg, *args = send_ary
|
|
477
|
-
m = message(m) {
|
|
478
|
-
"Expected #{mu_pp recv}.#{msg}(*#{mu_pp args}) to return true"
|
|
479
|
-
}
|
|
480
|
-
assert recv.__send__(msg, *args), m
|
|
481
|
-
end
|
|
482
|
-
|
|
483
454
|
##
|
|
484
455
|
# Fails if the block outputs anything to stderr or stdout.
|
|
485
456
|
#
|
|
@@ -624,13 +595,16 @@ module Minitest
|
|
|
624
595
|
end
|
|
625
596
|
|
|
626
597
|
##
|
|
627
|
-
# Returns a proc that
|
|
598
|
+
# Returns a proc that delays generation of an output message. If
|
|
599
|
+
# +msg+ is a proc (eg, from another +message+ call) return +msg+
|
|
600
|
+
# as-is. Otherwise, return a proc that will output +msg+ along
|
|
601
|
+
# with the value of the result of the block passed to +message+.
|
|
628
602
|
|
|
629
|
-
def message msg = nil, ending =
|
|
603
|
+
def message msg = nil, ending = ".", &default
|
|
604
|
+
return msg if Proc === msg
|
|
630
605
|
proc {
|
|
631
|
-
msg = msg.call.chomp(".") if Proc === msg
|
|
632
606
|
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
|
|
633
|
-
"#{custom_message}#{default.call}#{ending
|
|
607
|
+
"#{custom_message}#{default.call}#{ending}"
|
|
634
608
|
}
|
|
635
609
|
end
|
|
636
610
|
|
|
@@ -654,8 +628,7 @@ module Minitest
|
|
|
654
628
|
|
|
655
629
|
def refute_empty obj, msg = nil
|
|
656
630
|
msg = message(msg) { "Expected #{mu_pp obj} to not be empty" }
|
|
657
|
-
|
|
658
|
-
refute obj.empty?, msg
|
|
631
|
+
refute_predicate obj, :empty?, msg
|
|
659
632
|
end
|
|
660
633
|
|
|
661
634
|
##
|
|
@@ -692,14 +665,11 @@ module Minitest
|
|
|
692
665
|
end
|
|
693
666
|
|
|
694
667
|
##
|
|
695
|
-
# Fails if +
|
|
668
|
+
# Fails if +obj+ includes +sub+.
|
|
696
669
|
|
|
697
|
-
def refute_includes
|
|
698
|
-
msg = message(msg) {
|
|
699
|
-
|
|
700
|
-
}
|
|
701
|
-
assert_respond_to collection, :include?
|
|
702
|
-
refute collection.include?(obj), msg
|
|
670
|
+
def refute_includes obj, sub, msg = nil
|
|
671
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not include #{mu_pp sub}" }
|
|
672
|
+
refute_operator obj, :include?, sub, msg
|
|
703
673
|
end
|
|
704
674
|
|
|
705
675
|
##
|
|
@@ -725,9 +695,8 @@ module Minitest
|
|
|
725
695
|
|
|
726
696
|
def refute_match matcher, obj, msg = nil
|
|
727
697
|
msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
|
|
728
|
-
assert_respond_to matcher, :=~
|
|
729
698
|
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
|
730
|
-
|
|
699
|
+
refute_operator matcher, :=~, obj, msg
|
|
731
700
|
end
|
|
732
701
|
|
|
733
702
|
##
|
|
@@ -751,15 +720,12 @@ module Minitest
|
|
|
751
720
|
# other exceptions will be raised as normal and generate a test error.
|
|
752
721
|
|
|
753
722
|
def refute_pattern
|
|
754
|
-
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
755
723
|
flunk "refute_pattern requires a block to capture errors." unless block_given?
|
|
756
724
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
pass
|
|
762
|
-
end
|
|
725
|
+
yield
|
|
726
|
+
flunk "NoMatchingPatternError expected, but nothing was raised."
|
|
727
|
+
rescue NoMatchingPatternError
|
|
728
|
+
pass
|
|
763
729
|
end
|
|
764
730
|
|
|
765
731
|
##
|
|
@@ -770,6 +736,7 @@ module Minitest
|
|
|
770
736
|
|
|
771
737
|
def refute_operator o1, op, o2 = UNDEFINED, msg = nil
|
|
772
738
|
return refute_predicate o1, op, msg if UNDEFINED == o2
|
|
739
|
+
assert_respond_to o1, op
|
|
773
740
|
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op} #{mu_pp o2}" }
|
|
774
741
|
refute o1.__send__(op, o2), msg
|
|
775
742
|
end
|
|
@@ -792,6 +759,7 @@ module Minitest
|
|
|
792
759
|
# str.wont_be :empty?
|
|
793
760
|
|
|
794
761
|
def refute_predicate o1, op, msg = nil
|
|
762
|
+
assert_respond_to o1, op
|
|
795
763
|
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op}" }
|
|
796
764
|
refute o1.__send__(op), msg
|
|
797
765
|
end
|
data/lib/minitest/autorun.rb
CHANGED
data/lib/minitest/benchmark.rb
CHANGED