minitest 5.27.0 → 6.0.3
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 +108 -0
- data/Manifest.txt +13 -4
- data/README.rdoc +8 -90
- data/Rakefile +7 -15
- data/bin/minitest +5 -0
- data/lib/minitest/assertions.rb +26 -55
- data/lib/minitest/autorun.rb +0 -1
- data/lib/minitest/benchmark.rb +1 -1
- data/lib/minitest/bisect.rb +304 -0
- data/lib/minitest/complete.rb +56 -0
- data/lib/minitest/find_minimal_combination.rb +127 -0
- data/lib/minitest/manual_plugins.rb +4 -16
- data/lib/minitest/parallel.rb +3 -3
- data/lib/minitest/path_expander.rb +432 -0
- data/lib/minitest/pride.rb +1 -1
- data/lib/minitest/server.rb +49 -0
- data/lib/minitest/server_plugin.rb +88 -0
- data/lib/minitest/spec.rb +2 -31
- data/lib/minitest/sprint.rb +105 -0
- data/lib/minitest/sprint_plugin.rb +39 -0
- data/lib/minitest/test.rb +5 -11
- data/lib/minitest/test_task.rb +16 -9
- data/lib/minitest.rb +69 -87
- data/test/minitest/metametameta.rb +1 -1
- data/test/minitest/test_bisect.rb +249 -0
- data/test/minitest/test_find_minimal_combination.rb +138 -0
- data/test/minitest/test_minitest_assertions.rb +36 -44
- data/test/minitest/test_minitest_benchmark.rb +14 -0
- data/test/minitest/test_minitest_spec.rb +38 -102
- data/test/minitest/test_minitest_test.rb +20 -99
- data/test/minitest/test_path_expander.rb +229 -0
- data/test/minitest/test_server.rb +146 -0
- data.tar.gz.sig +0 -0
- metadata +87 -41
- metadata.gz.sig +2 -3
- 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: e0f8b6988a17af9be0525c9517ad1fe600b55c1068997c1e396e05b1769037af
|
|
4
|
+
data.tar.gz: 5c1a38b4c98d4ee9aec32c78b80c3bfe310988d2d7ff233dcff690b6113a640b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04db7b8165fbfe50f59dbb1ff663897fa564724e1202ccf897804b35e5b00ed0b2e8c3ddef0540e0c88abdecab36269e120c950faa452cd4c28463d864db7b82
|
|
7
|
+
data.tar.gz: 8c7c6a2a30a78c7e49cf66fdc4c10593855e1adff708078e9c98b6530ba058d9ee2542122e5cce28787b5e370a0c6e424eb7d080e3d8e580556ee1af898a284a
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,111 @@
|
|
|
1
|
+
=== 6.0.3 / 2026-03-31
|
|
2
|
+
|
|
3
|
+
* 1 bug fix:
|
|
4
|
+
|
|
5
|
+
* assert_same(nil, value) no longer allowed. Use assert_nil to be explicit. (paddor)
|
|
6
|
+
|
|
7
|
+
=== 6.0.2 / 2026-02-23
|
|
8
|
+
|
|
9
|
+
* 7 bug fixes:
|
|
10
|
+
|
|
11
|
+
* Added missing drb dependency from minitest-server. (y-yagi)
|
|
12
|
+
* Cleaned up bisect's sub-commands to load files directly, not ruby+require.
|
|
13
|
+
* Fixed bisect to use same cmd ($0) to run tests as original invocation.
|
|
14
|
+
* load server_plugin if server is loaded. (y-yagi)
|
|
15
|
+
* Manipulate local args instead of ARGV in Sprint.run.
|
|
16
|
+
* Only show --bisect in usage if using minitest.
|
|
17
|
+
* Remove -Itest:lib from bisect's rb_flags since bin/minitest adds them.
|
|
18
|
+
|
|
19
|
+
=== 6.0.1 / 2025-12-26
|
|
20
|
+
|
|
21
|
+
* 1 minor enhancement:
|
|
22
|
+
|
|
23
|
+
* Added new rake task `test:fu` to Minitest::TestTask, to only run
|
|
24
|
+
tests with FU (focused units?) in their name. This should mostly
|
|
25
|
+
obviate the need for the minitest-focus plugin.
|
|
26
|
+
|
|
27
|
+
* 5 bug fixes:
|
|
28
|
+
|
|
29
|
+
* Fixed --help and --version exiting 1. (grosser)
|
|
30
|
+
* Fixed method signature of Minitest::Benchmark.run. (flavorjones)
|
|
31
|
+
* Flush stdout/stderr before exit./bin/minitest -Ilib ./bug1046.rb:1 < /dev/null (grosser)
|
|
32
|
+
* Improved usage banner output by reordering and reformatting.
|
|
33
|
+
* Normalize paths while processing file.rb:line args.
|
|
34
|
+
|
|
35
|
+
=== 6.0.0 / 2025-12-17
|
|
36
|
+
|
|
37
|
+
This is a major release. Read this.
|
|
38
|
+
|
|
39
|
+
Please give feedback here: https://github.com/minitest/minitest/issues/1040
|
|
40
|
+
|
|
41
|
+
Oh god... here we go... (again)
|
|
42
|
+
|
|
43
|
+
* 8 deaths in the family(!!):
|
|
44
|
+
|
|
45
|
+
* Deleted MiniTest and MiniTest::Unit::TestCase compatibility namespaces.
|
|
46
|
+
* Deleted all use of Marshal for serialization.
|
|
47
|
+
* Deleted maglev? and rubinius? guard methods. LOL.
|
|
48
|
+
* Deleted all minitest/spec expectations from Object. Use _/value/expect.
|
|
49
|
+
* Dropped minitest/mock.rb. This has been extracted to the minitest-mock gem.
|
|
50
|
+
* assert_equal(nil, value) no longer allowed. Use assert_nil to be explicit.
|
|
51
|
+
* Removed assert_send. Use assert_predicate or assert_operator.
|
|
52
|
+
* Removed Minitest::Test#class_name.
|
|
53
|
+
|
|
54
|
+
* 7 major (oft incompatible) changes:
|
|
55
|
+
|
|
56
|
+
* Big: Major refactored MT6's run path!
|
|
57
|
+
* Minitest.__run -> Minitest.run_all_suites
|
|
58
|
+
* Runnable.run -> Runnable.run_suite & Runnable.filter_runnable_methods
|
|
59
|
+
* Runnable.run_one_method -> Runnable.run
|
|
60
|
+
* Removed Minitest.run_one_method (might bring it back to raise?)
|
|
61
|
+
* Removed deprecated <tt>ENV["N"]</tt> to specify number of parallel tests. Use MT_CPU.
|
|
62
|
+
* Renamed +options[:filter]+ to +options[:include]+, added <tt>--include</tt> cmdline option.
|
|
63
|
+
* <tt>--name</tt> is still handled, but that will be removed in the future.
|
|
64
|
+
* Renamed Minitest::Runnable#test_order to #run_order.
|
|
65
|
+
* If #message is passed a proc then that proc overrides all other output.
|
|
66
|
+
* They are no longer chained!
|
|
67
|
+
* And it does less for formatting of your output.
|
|
68
|
+
* Removed reporter arg from with_info_handler as it has never(?) been used. (HACK?)
|
|
69
|
+
* Plugin loading is now opt-in!
|
|
70
|
+
* Require the plugin in your test_helper.
|
|
71
|
+
* Or use Minitest.load :x
|
|
72
|
+
* Or call Minitest.load_plugins for the old autoloading behavior.
|
|
73
|
+
|
|
74
|
+
* 5 additions:
|
|
75
|
+
|
|
76
|
+
* Added minitest-sprint's minitest cmdline, now with line support!
|
|
77
|
+
* Added minitest-bisect. Run with minitest --bisect or -b.
|
|
78
|
+
* Added minitest-server.
|
|
79
|
+
* Added minitest/complete to help with shell's tab-completion of tests.
|
|
80
|
+
* Vendored latest version of path_expander.
|
|
81
|
+
|
|
82
|
+
* 5 other:
|
|
83
|
+
|
|
84
|
+
* Bumped to ruby 3.2+.
|
|
85
|
+
* Removed obsolete conditional for CompositeReporter#prerecord.
|
|
86
|
+
* Removed obsolete version guards around Minitest::Result in reporters.
|
|
87
|
+
* assert_operator and assert_predicate both call assert_respond_to first.
|
|
88
|
+
* Assertions reuse themselves a lot more. Bumps assertion count in some places.
|
|
89
|
+
|
|
90
|
+
=== 5.27.0 / 2025-12-11
|
|
91
|
+
|
|
92
|
+
* 1 major enhancement:
|
|
93
|
+
|
|
94
|
+
* Adding post install message announcing the EOL for minitest 5!
|
|
95
|
+
|
|
96
|
+
* 2 minor enhancements:
|
|
97
|
+
|
|
98
|
+
* Removed TestTask::Work#initialize since Queue can now initialize with an Enumerable! AMAZING!
|
|
99
|
+
* Use Kernel#warn uplevel argument for nicer warnings. (byroot)
|
|
100
|
+
|
|
101
|
+
* 5 bug fixes:
|
|
102
|
+
|
|
103
|
+
* Cleaned up option aliasing a tad.
|
|
104
|
+
* Removed obsolete conditional for prerecord
|
|
105
|
+
* Removed obsolete guards around Warning.
|
|
106
|
+
* Removed obsolete version guards for pattern matching assertions.
|
|
107
|
+
* Switched all internal requires to require_relative.
|
|
108
|
+
|
|
1
109
|
=== 5.26.2 / 2025-11-17
|
|
2
110
|
|
|
3
111
|
* 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_path_expander.rb
|
|
41
|
+
test/minitest/test_server.rb
|
data/README.rdoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
= minitest/{test,spec,
|
|
1
|
+
= minitest/{test,spec,benchmark}
|
|
2
2
|
|
|
3
3
|
home :: https://minite.st/
|
|
4
4
|
code :: https://github.com/minitest/minitest
|
|
@@ -11,7 +11,7 @@ vim :: https://github.com/vim-test/vim-test
|
|
|
11
11
|
== DESCRIPTION:
|
|
12
12
|
|
|
13
13
|
minitest provides a complete suite of testing facilities supporting
|
|
14
|
-
TDD, BDD,
|
|
14
|
+
TDD, BDD, and benchmarking.
|
|
15
15
|
|
|
16
16
|
"I had a class with Jim Weirich on testing last week and we were
|
|
17
17
|
allowed to choose our testing frameworks. Kirk Haines and I were
|
|
@@ -37,9 +37,6 @@ algorithms in a repeatable manner. Now you can assert that your newb
|
|
|
37
37
|
co-worker doesn't replace your linear algorithm with an exponential
|
|
38
38
|
one!
|
|
39
39
|
|
|
40
|
-
minitest/mock by Steven Baker, is a beautifully tiny mock (and stub)
|
|
41
|
-
object framework.
|
|
42
|
-
|
|
43
40
|
minitest/pride shows pride in testing and adds coloring to your test
|
|
44
41
|
output. I guess it is an example of how to write IO pipes too. :P
|
|
45
42
|
|
|
@@ -69,7 +66,6 @@ extract-method refactorings still apply.
|
|
|
69
66
|
* minitest/autorun - the easy and explicit way to run all your tests.
|
|
70
67
|
* minitest/test - a very fast, simple, and clean test system.
|
|
71
68
|
* minitest/spec - a very fast, simple, and clean spec system.
|
|
72
|
-
* minitest/mock - a simple and clean mock/stub system.
|
|
73
69
|
* minitest/benchmark - an awesome way to assert your algorithm's performance.
|
|
74
70
|
* minitest/pride - show your pride in testing!
|
|
75
71
|
* minitest/test_task - a full-featured and clean rake task generator.
|
|
@@ -191,85 +187,6 @@ outputs something like:
|
|
|
191
187
|
|
|
192
188
|
Output is tab-delimited to make it easy to paste into a spreadsheet.
|
|
193
189
|
|
|
194
|
-
=== Mocks
|
|
195
|
-
|
|
196
|
-
Mocks and stubs defined using terminology by Fowler & Meszaros at
|
|
197
|
-
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
198
|
-
|
|
199
|
-
"Mocks are pre-programmed with expectations which form a specification
|
|
200
|
-
of the calls they are expected to receive. They can throw an exception
|
|
201
|
-
if they receive a call they don't expect and are checked during
|
|
202
|
-
verification to ensure they got all the calls they were expecting."
|
|
203
|
-
|
|
204
|
-
class MemeAsker
|
|
205
|
-
def initialize(meme)
|
|
206
|
-
@meme = meme
|
|
207
|
-
end
|
|
208
|
-
|
|
209
|
-
def ask(question)
|
|
210
|
-
method = question.tr(" ", "_") + "?"
|
|
211
|
-
@meme.__send__(method)
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
require "minitest/autorun"
|
|
216
|
-
|
|
217
|
-
describe MemeAsker, :ask do
|
|
218
|
-
describe "when passed an unpunctuated question" do
|
|
219
|
-
it "should invoke the appropriate predicate method on the meme" do
|
|
220
|
-
@meme = Minitest::Mock.new
|
|
221
|
-
@meme_asker = MemeAsker.new @meme
|
|
222
|
-
@meme.expect :will_it_blend?, :return_value
|
|
223
|
-
|
|
224
|
-
@meme_asker.ask "will it blend"
|
|
225
|
-
|
|
226
|
-
@meme.verify
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
==== Multi-threading and Mocks
|
|
232
|
-
|
|
233
|
-
Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
|
|
234
|
-
you can use regular ruby patterns and facilities like local variables. Here's
|
|
235
|
-
an example of asserting that code inside a thread is run:
|
|
236
|
-
|
|
237
|
-
def test_called_inside_thread
|
|
238
|
-
called = false
|
|
239
|
-
pr = Proc.new { called = true }
|
|
240
|
-
thread = Thread.new(&pr)
|
|
241
|
-
thread.join
|
|
242
|
-
assert called, "proc not called"
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
=== Stubs
|
|
246
|
-
|
|
247
|
-
Mocks and stubs are defined using terminology by Fowler & Meszaros at
|
|
248
|
-
https://www.martinfowler.com/bliki/TestDouble.html:
|
|
249
|
-
|
|
250
|
-
"Stubs provide canned answers to calls made during the test".
|
|
251
|
-
|
|
252
|
-
Minitest's stub method overrides a single method for the duration of
|
|
253
|
-
the block.
|
|
254
|
-
|
|
255
|
-
def test_stale_eh
|
|
256
|
-
obj_under_test = Something.new
|
|
257
|
-
|
|
258
|
-
refute obj_under_test.stale?
|
|
259
|
-
|
|
260
|
-
Time.stub :now, Time.at(0) do # stub goes away once the block is done
|
|
261
|
-
assert obj_under_test.stale?
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
A note on stubbing: In order to stub a method, the method must
|
|
266
|
-
actually exist prior to stubbing. Use a singleton method to create a
|
|
267
|
-
new non-existing method:
|
|
268
|
-
|
|
269
|
-
def obj_under_test.fake_method
|
|
270
|
-
...
|
|
271
|
-
end
|
|
272
|
-
|
|
273
190
|
=== Running Your Tests
|
|
274
191
|
|
|
275
192
|
Ideally, you'll use a rake task to run your tests (see below), either
|
|
@@ -687,6 +604,9 @@ minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
|
|
|
687
604
|
minitest-have_tag :: Adds Minitest assertions to test for the existence of
|
|
688
605
|
HTML tags, including contents, within a provided string.
|
|
689
606
|
minitest-heat :: Reporting that builds a heat map of failure locations
|
|
607
|
+
minitest-holdify :: Stop maintaining large expected values in your
|
|
608
|
+
test/fixture files! Hold them automatically.
|
|
609
|
+
Update them effortlessly.
|
|
690
610
|
minitest-hooks :: Around and before_all/after_all/around_all hooks
|
|
691
611
|
minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
|
|
692
612
|
minitest-implicit-subject :: Implicit declaration of the test subject.
|
|
@@ -761,12 +681,10 @@ mongoid-minitest :: Minitest matchers for Mongoid.
|
|
|
761
681
|
mutant-minitest :: Minitest integration for mutant.
|
|
762
682
|
pry-rescue :: A pry plugin w/ minitest support. See
|
|
763
683
|
pry-rescue/minitest.rb.
|
|
764
|
-
rematch :: Declutter your test files from large hardcoded data
|
|
765
|
-
and update them automatically when your code changes.
|
|
766
684
|
rspec2minitest :: Easily translate any RSpec matchers to Minitest
|
|
767
685
|
assertions and expectations.
|
|
768
|
-
stubberry :: Multiple stubbing 'berries', sweet and useful
|
|
769
|
-
stub helpers and assertions. ( stub_must,
|
|
686
|
+
stubberry :: Multiple stubbing 'berries', sweet and useful
|
|
687
|
+
stub helpers and assertions. ( stub_must,
|
|
770
688
|
assert_method_called, stubbing ORM objects by id )
|
|
771
689
|
|
|
772
690
|
== Unknown Extensions:
|
|
@@ -797,7 +715,7 @@ Authors... Please send me a pull request with a description of your minitest ext
|
|
|
797
715
|
|
|
798
716
|
== REQUIREMENTS:
|
|
799
717
|
|
|
800
|
-
* Ruby 2
|
|
718
|
+
* Ruby 3.2+. No magic is involved. I hope.
|
|
801
719
|
|
|
802
720
|
== INSTALL:
|
|
803
721
|
|
data/Rakefile
CHANGED
|
@@ -4,31 +4,23 @@ 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"
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ruby 1.8 to 2.7. If you need to keep using these versions,
|
|
19
|
-
you need to pin your dependency to minitest with something
|
|
20
|
-
like "~> 5.0". See History.rdoc to locate compatible
|
|
21
|
-
versions.
|
|
18
|
+
dependency "prism", "~> 1.5"
|
|
19
|
+
dependency "drb", "~> 2.0"
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
self.rdoc_locations << "l:/home/www/minite.st/html/docs"
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
+ MiniTest::Unit
|
|
27
|
-
+ MiniTest::Unit::TestCase
|
|
28
|
-
+ assert_send (unless you argue for it well)
|
|
29
|
-
+ assert_equal nil, obj
|
|
30
|
-
+ mocks and stubs: moving minitest/mock.rb to its own gem
|
|
31
|
-
EOM
|
|
23
|
+
self.cov_filter = %w[ tmp ]
|
|
32
24
|
end
|
|
33
25
|
|
|
34
26
|
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,14 +195,6 @@ module Minitest
|
|
|
196
195
|
.split(":in ", 2).first # clean up noise
|
|
197
196
|
end
|
|
198
197
|
|
|
199
|
-
def _caller_uplevel # :nodoc:
|
|
200
|
-
backtrace = caller
|
|
201
|
-
real_caller = Minitest.filter_backtrace(caller).first
|
|
202
|
-
backtrace.index(real_caller)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
E = "" # :nodoc:
|
|
206
|
-
|
|
207
198
|
##
|
|
208
199
|
# Fails unless <tt>exp == act</tt> printing the difference between
|
|
209
200
|
# the two, if possible.
|
|
@@ -218,18 +209,11 @@ module Minitest
|
|
|
218
209
|
# See also: Minitest::Assertions.diff
|
|
219
210
|
|
|
220
211
|
def assert_equal exp, act, msg = nil
|
|
221
|
-
msg = message(msg,
|
|
222
|
-
result = assert exp == act, msg
|
|
212
|
+
msg = message(msg, nil) { diff exp, act }
|
|
223
213
|
|
|
224
|
-
if nil
|
|
225
|
-
if Minitest::VERSION >= "6" then
|
|
226
|
-
refute_nil exp, "Use assert_nil if expecting nil."
|
|
227
|
-
else
|
|
228
|
-
warn "DEPRECATED: Use assert_nil if expecting nil. This will fail in Minitest 6.", uplevel: _caller_uplevel
|
|
229
|
-
end
|
|
230
|
-
end
|
|
214
|
+
refute_nil exp, message { "Use assert_nil if expecting nil" } if exp.nil? # don't count
|
|
231
215
|
|
|
232
|
-
|
|
216
|
+
assert exp == act, msg
|
|
233
217
|
end
|
|
234
218
|
|
|
235
219
|
##
|
|
@@ -261,8 +245,7 @@ module Minitest
|
|
|
261
245
|
msg = message(msg) {
|
|
262
246
|
"Expected #{mu_pp collection} to include #{mu_pp obj}"
|
|
263
247
|
}
|
|
264
|
-
|
|
265
|
-
assert collection.include?(obj), msg
|
|
248
|
+
assert_operator collection, :include?, obj, msg
|
|
266
249
|
end
|
|
267
250
|
|
|
268
251
|
##
|
|
@@ -314,6 +297,7 @@ module Minitest
|
|
|
314
297
|
|
|
315
298
|
def assert_operator o1, op, o2 = UNDEFINED, msg = nil
|
|
316
299
|
return assert_predicate o1, op, msg if UNDEFINED == o2
|
|
300
|
+
assert_respond_to o1, op
|
|
317
301
|
msg = message(msg) { "Expected #{mu_pp o1} to be #{op} #{mu_pp o2}" }
|
|
318
302
|
assert o1.__send__(op, o2), msg
|
|
319
303
|
end
|
|
@@ -392,6 +376,7 @@ module Minitest
|
|
|
392
376
|
# str.must_be :empty?
|
|
393
377
|
|
|
394
378
|
def assert_predicate o1, op, msg = nil
|
|
379
|
+
assert_respond_to o1, op, include_all:true
|
|
395
380
|
msg = message(msg) { "Expected #{mu_pp o1} to be #{op}" }
|
|
396
381
|
assert o1.__send__(op), msg
|
|
397
382
|
end
|
|
@@ -451,9 +436,7 @@ module Minitest
|
|
|
451
436
|
# include_all defaults to false to match Object#respond_to?
|
|
452
437
|
|
|
453
438
|
def assert_respond_to obj, meth, msg = nil, include_all: false
|
|
454
|
-
msg = message(msg) {
|
|
455
|
-
"Expected #{mu_pp obj} (#{obj.class}) to respond to ##{meth}"
|
|
456
|
-
}
|
|
439
|
+
msg = message(msg) { "Expected #{mu_pp obj} (#{obj.class}) to respond to ##{meth}" }
|
|
457
440
|
assert obj.respond_to?(meth, include_all), msg
|
|
458
441
|
end
|
|
459
442
|
|
|
@@ -465,22 +448,10 @@ module Minitest
|
|
|
465
448
|
data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
|
|
466
449
|
"Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
|
|
467
450
|
}
|
|
468
|
-
assert exp.equal?(act), msg
|
|
469
|
-
end
|
|
470
451
|
|
|
471
|
-
|
|
472
|
-
# +send_ary+ is a receiver, message and arguments.
|
|
473
|
-
#
|
|
474
|
-
# Fails unless the call returns a true value
|
|
452
|
+
refute_nil exp, message { "Use assert_nil if expecting nil" } if exp.nil? # don't count
|
|
475
453
|
|
|
476
|
-
|
|
477
|
-
warn "DEPRECATED: assert_send.", uplevel: _caller_uplevel
|
|
478
|
-
|
|
479
|
-
recv, msg, *args = send_ary
|
|
480
|
-
m = message(m) {
|
|
481
|
-
"Expected #{mu_pp recv}.#{msg}(*#{mu_pp args}) to return true"
|
|
482
|
-
}
|
|
483
|
-
assert recv.__send__(msg, *args), m
|
|
454
|
+
assert exp.equal?(act), msg
|
|
484
455
|
end
|
|
485
456
|
|
|
486
457
|
##
|
|
@@ -627,13 +598,16 @@ module Minitest
|
|
|
627
598
|
end
|
|
628
599
|
|
|
629
600
|
##
|
|
630
|
-
# Returns a proc that
|
|
601
|
+
# Returns a proc that delays generation of an output message. If
|
|
602
|
+
# +msg+ is a proc (eg, from another +message+ call) return +msg+
|
|
603
|
+
# as-is. Otherwise, return a proc that will output +msg+ along
|
|
604
|
+
# with the value of the result of the block passed to +message+.
|
|
631
605
|
|
|
632
|
-
def message msg = nil, ending =
|
|
606
|
+
def message msg = nil, ending = ".", &default
|
|
607
|
+
return msg if Proc === msg
|
|
633
608
|
proc {
|
|
634
|
-
msg = msg.call.chomp(".") if Proc === msg
|
|
635
609
|
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
|
|
636
|
-
"#{custom_message}#{default.call}#{ending
|
|
610
|
+
"#{custom_message}#{default.call}#{ending}"
|
|
637
611
|
}
|
|
638
612
|
end
|
|
639
613
|
|
|
@@ -657,8 +631,7 @@ module Minitest
|
|
|
657
631
|
|
|
658
632
|
def refute_empty obj, msg = nil
|
|
659
633
|
msg = message(msg) { "Expected #{mu_pp obj} to not be empty" }
|
|
660
|
-
|
|
661
|
-
refute obj.empty?, msg
|
|
634
|
+
refute_predicate obj, :empty?, msg
|
|
662
635
|
end
|
|
663
636
|
|
|
664
637
|
##
|
|
@@ -695,14 +668,11 @@ module Minitest
|
|
|
695
668
|
end
|
|
696
669
|
|
|
697
670
|
##
|
|
698
|
-
# Fails if +
|
|
671
|
+
# Fails if +obj+ includes +sub+.
|
|
699
672
|
|
|
700
|
-
def refute_includes
|
|
701
|
-
msg = message(msg) {
|
|
702
|
-
|
|
703
|
-
}
|
|
704
|
-
assert_respond_to collection, :include?
|
|
705
|
-
refute collection.include?(obj), msg
|
|
673
|
+
def refute_includes obj, sub, msg = nil
|
|
674
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not include #{mu_pp sub}" }
|
|
675
|
+
refute_operator obj, :include?, sub, msg
|
|
706
676
|
end
|
|
707
677
|
|
|
708
678
|
##
|
|
@@ -728,9 +698,8 @@ module Minitest
|
|
|
728
698
|
|
|
729
699
|
def refute_match matcher, obj, msg = nil
|
|
730
700
|
msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
|
|
731
|
-
assert_respond_to matcher, :=~
|
|
732
701
|
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
|
733
|
-
|
|
702
|
+
refute_operator matcher, :=~, obj, msg
|
|
734
703
|
end
|
|
735
704
|
|
|
736
705
|
##
|
|
@@ -770,6 +739,7 @@ module Minitest
|
|
|
770
739
|
|
|
771
740
|
def refute_operator o1, op, o2 = UNDEFINED, msg = nil
|
|
772
741
|
return refute_predicate o1, op, msg if UNDEFINED == o2
|
|
742
|
+
assert_respond_to o1, op
|
|
773
743
|
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op} #{mu_pp o2}" }
|
|
774
744
|
refute o1.__send__(op, o2), msg
|
|
775
745
|
end
|
|
@@ -792,6 +762,7 @@ module Minitest
|
|
|
792
762
|
# str.wont_be :empty?
|
|
793
763
|
|
|
794
764
|
def refute_predicate o1, op, msg = nil
|
|
765
|
+
assert_respond_to o1, op
|
|
795
766
|
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op}" }
|
|
796
767
|
refute o1.__send__(op), msg
|
|
797
768
|
end
|
data/lib/minitest/autorun.rb
CHANGED