minitest 5.25.1 → 5.27.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +76 -0
- data/README.rdoc +25 -15
- data/Rakefile +18 -2
- data/design_rationale.rb +21 -19
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +21 -26
- data/lib/minitest/autorun.rb +4 -4
- data/lib/minitest/benchmark.rb +2 -2
- data/lib/minitest/expectations.rb +2 -2
- data/lib/minitest/hell.rb +1 -1
- data/lib/minitest/manual_plugins.rb +1 -1
- data/lib/minitest/mock.rb +27 -29
- data/lib/minitest/parallel.rb +2 -0
- data/lib/minitest/pride.rb +1 -1
- data/lib/minitest/pride_plugin.rb +2 -2
- data/lib/minitest/spec.rb +17 -13
- data/lib/minitest/test.rb +5 -4
- data/lib/minitest/test_task.rb +28 -11
- data/lib/minitest/unit.rb +1 -1
- data/lib/minitest.rb +50 -34
- data/test/minitest/test_minitest_assertions.rb +19 -62
- data/test/minitest/test_minitest_mock.rb +77 -15
- data/test/minitest/test_minitest_reporter.rb +17 -16
- data/test/minitest/test_minitest_spec.rb +42 -28
- data/test/minitest/test_minitest_test.rb +20 -2
- data.tar.gz.sig +0 -0
- metadata +32 -22
- metadata.gz.sig +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9144898bc998f49d23688386cb435165b7ba6fadf83acc47f8120992d2799c6
|
|
4
|
+
data.tar.gz: f90178ecc10c76e8d0cea4c2206972b3bbb899f552c53f1b22743e00d9898a02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a157620a20602d17c8aaf088cc9c709401d7fd3507569fceb85d358c5519596fdb2bd71ef8b1b597942ba9ba5ef9b0af1530fb97a47fac28add36600516d2edc
|
|
7
|
+
data.tar.gz: 17c0fdb228c63bda818fbc4009c30c88138df74e325e087050843bef8128ea54afade9de4c0e5af6d5f734ad114d34dd97e4eed2ac4e577662144ad8c49f261e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
+
=== 5.26.2 / 2025-11-17
|
|
2
|
+
|
|
3
|
+
* 5 bug fixes:
|
|
4
|
+
|
|
5
|
+
* Bumped minimum ruby to 3.1.
|
|
6
|
+
* Alias Spec#name to #inspect for cleaner output in repls.
|
|
7
|
+
* Fix pathing for Hoe::Minitest initialization to be more generic.
|
|
8
|
+
* Fixed refute_in_epsilon to use min of abs values. (wtn)
|
|
9
|
+
* Improved options processing and usage output to be more clear.
|
|
10
|
+
|
|
11
|
+
=== 5.26.1 / 2025-11-08
|
|
12
|
+
|
|
13
|
+
The Ocean Shores, Slightly Less Tipsy Edition!
|
|
14
|
+
|
|
15
|
+
* 3 bug fixes:
|
|
16
|
+
|
|
17
|
+
* Add links to API doco in README.
|
|
18
|
+
* Add missing require thread.
|
|
19
|
+
* Bumped ruby version to include 4.0 (trunk). (hsbt)
|
|
20
|
+
(see also 5.14.2)
|
|
21
|
+
|
|
22
|
+
=== 5.26.0 / 2025-10-07
|
|
23
|
+
|
|
24
|
+
The Seattle.rb Nerd Party, Slightly Tipsy Edition!
|
|
25
|
+
|
|
26
|
+
* 2 minor enhancements:
|
|
27
|
+
|
|
28
|
+
* Added extra documentation to Minitest::TestTask options.
|
|
29
|
+
* Make parallelize_me! a no-op when n_threads=1.
|
|
30
|
+
|
|
31
|
+
* 9 bug fixes:
|
|
32
|
+
|
|
33
|
+
* Bypass parallel_executor entirely when n_threads=1.
|
|
34
|
+
* Don't require rubygems in Rakefile... it is 2025.
|
|
35
|
+
* Ensure that minitest exits non-zero on Interrupt. (tavianator)
|
|
36
|
+
* Fix Minitest.run sequence rdoc to include loop vars and read consistently.
|
|
37
|
+
* Fix call to parallel_executor.shutdown when it isn't defined.
|
|
38
|
+
* Removed some 1.8/1.9-based code from the assertions and expectations.
|
|
39
|
+
* Still fighting with rdoc? Yup. Still fighting with rdoc...
|
|
40
|
+
* Switched assert_equal's diff from Tempfile.open to Tempfile.create.
|
|
41
|
+
* Use Regexp.escape for BASE_RE in case pwd has special chars. (astra_1993)
|
|
42
|
+
|
|
43
|
+
=== 5.25.5 / 2025-03-12
|
|
44
|
+
|
|
45
|
+
* 4 bug fixes:
|
|
46
|
+
|
|
47
|
+
* Bumped minimum ruby to 2.7.
|
|
48
|
+
* Fixed expectation docs for must/wont_pattern_match. (jaredcwhite)
|
|
49
|
+
* Reorder Minitest::Test.ancestors to allow reaching Minitest::Assertions#skipped? (Edouard-chin)
|
|
50
|
+
* Update the ruby and rails compatibility tables. (bquorning)
|
|
51
|
+
|
|
52
|
+
=== 5.25.4 / 2024-12-03
|
|
53
|
+
|
|
54
|
+
* 1 bug fix:
|
|
55
|
+
|
|
56
|
+
* Fix for must_verify definition if only requiring minitest/mock (but why?).
|
|
57
|
+
|
|
58
|
+
=== 5.25.3 / 2024-12-03
|
|
59
|
+
|
|
60
|
+
* 5 bug fixes:
|
|
61
|
+
|
|
62
|
+
* Fixed assert_mock to fail instead of raise on unmet mock expectations.
|
|
63
|
+
* Fixed assert_mock to take an optional message argument.
|
|
64
|
+
* Fixed formatting of unmet mock expectation messages.
|
|
65
|
+
* Fixed missing must_verify expectation to match assert_mock.
|
|
66
|
+
* minitest/pride: Fixed to use true colors with *-direct terminals (bk2204)
|
|
67
|
+
|
|
68
|
+
=== 5.25.2 / 2024-11-21
|
|
69
|
+
|
|
70
|
+
* 4 bug fixes:
|
|
71
|
+
|
|
72
|
+
* Include class name in spec name. (thomasmarshall)
|
|
73
|
+
* Fixed 'redefining object_id' warning from ruby 3.4. (mattbrictson)
|
|
74
|
+
* Minitest top-level namespace no longer includes entire contents of README.rdoc. Too much!
|
|
75
|
+
* Refactored spec's describe to more cleanly determine the superclass and name
|
|
76
|
+
|
|
1
77
|
=== 5.25.1 / 2024-08-16
|
|
2
78
|
|
|
3
79
|
* 2 bug fixes:
|
data/README.rdoc
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
= minitest/{test,spec,mock,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
|
|
|
@@ -95,7 +96,9 @@ Given that you'd like to test the following class:
|
|
|
95
96
|
|
|
96
97
|
=== Unit tests
|
|
97
98
|
|
|
98
|
-
Define your tests as methods beginning with +test_+.
|
|
99
|
+
Define your tests as methods beginning with +test_+. Use
|
|
100
|
+
{assertions}[/minitest/Minitest/Assertions.html] to test for results
|
|
101
|
+
or state.
|
|
99
102
|
|
|
100
103
|
require "minitest/autorun"
|
|
101
104
|
|
|
@@ -119,6 +122,9 @@ Define your tests as methods beginning with +test_+.
|
|
|
119
122
|
|
|
120
123
|
=== Specs
|
|
121
124
|
|
|
125
|
+
Use {expectations}[/minitest/Minitest/Expectations.html] to check
|
|
126
|
+
results or state. They must be wrapped in a value call (eg +_+).
|
|
127
|
+
|
|
122
128
|
require "minitest/autorun"
|
|
123
129
|
|
|
124
130
|
describe Meme do
|
|
@@ -146,7 +152,7 @@ For matchers support check out:
|
|
|
146
152
|
|
|
147
153
|
=== Benchmarks
|
|
148
154
|
|
|
149
|
-
Add benchmarks to your tests.
|
|
155
|
+
Add {benchmarks}[/minitest/Minitest/Benchmark.html] to your tests.
|
|
150
156
|
|
|
151
157
|
# optionally run benchmarks, good for CI-only work!
|
|
152
158
|
require "minitest/benchmark" if ENV["BENCH"]
|
|
@@ -412,33 +418,37 @@ supporting versions of ruby that are long past EOL. Hopefully I'll be
|
|
|
412
418
|
able to support only current versions of ruby sometime in the near
|
|
413
419
|
future.
|
|
414
420
|
|
|
415
|
-
|
|
421
|
+
NOTICE: At this point, I will only locally test/dev against the
|
|
422
|
+
currently 3 supported (non-EOL) versions of ruby. I cannot and will
|
|
423
|
+
not maintain that many builds.
|
|
424
|
+
|
|
425
|
+
(As of 2025-02-03)
|
|
416
426
|
|
|
417
427
|
Current versions of rails: (https://endoflife.date/rails)
|
|
418
428
|
|
|
419
429
|
| rails | min ruby | minitest | status | EOL Date |
|
|
420
430
|
|-------+----------+----------+----------+------------|
|
|
421
|
-
|
|
|
422
|
-
|
|
|
423
|
-
|
|
|
424
|
-
|
|
|
425
|
-
| 5.2 | >= 2.2.2 | ~> 5.1 | EOL | 2022-06-01 |
|
|
431
|
+
| 8.1 | >= 3.2 | >= 5.1 | Current | 2027-10-07 |
|
|
432
|
+
| 8.0 | >= 3.2 | >= 5.1 | Current | 2026-11-07 |
|
|
433
|
+
| 7.2 | >= 3.1 | >= 5.1 | Security | 2026-08-09 |
|
|
434
|
+
| 7.1 | >= 2.7 | >= 5.1 | EOL | 2025-10-01 |
|
|
426
435
|
|
|
427
436
|
If you want to look at the requirements for a specific version, run:
|
|
428
437
|
|
|
429
|
-
gem spec -r --ruby rails -v
|
|
438
|
+
gem spec -r --ruby rails -v 8.0.0
|
|
430
439
|
|
|
431
440
|
Current versions of ruby: (https://endoflife.date/ruby)
|
|
432
441
|
|
|
433
442
|
| ruby | Status | EOL Date |
|
|
434
443
|
|------+---------+------------|
|
|
435
|
-
| 3.
|
|
436
|
-
| 3.
|
|
437
|
-
| 3.
|
|
444
|
+
| 3.4 | Current | 2028-03-31 |
|
|
445
|
+
| 3.3 | Maint | 2027-03-31 |
|
|
446
|
+
| 3.2 | Security| 2026-03-31 |
|
|
447
|
+
| 3.1 | EOL | 2025-03-31 |
|
|
438
448
|
| 3.0 | EOL | 2024-03-31 |
|
|
439
449
|
| 2.7 | EOL | 2023-03-31 |
|
|
440
450
|
| 2.6 | EOL | 2022-03-31 |
|
|
441
|
-
| 2.5 | EOL | 2021-03-31 |
|
|
451
|
+
| 2.5 | EOL | 2021-03-31 |
|
|
442
452
|
|
|
443
453
|
=== How to test SimpleDelegates?
|
|
444
454
|
|
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,24 @@ Hoe.spec "minitest" do
|
|
|
12
11
|
|
|
13
12
|
license "MIT"
|
|
14
13
|
|
|
15
|
-
require_ruby_version
|
|
14
|
+
require_ruby_version ">= 3.1"
|
|
15
|
+
|
|
16
|
+
self.post_install_message = <<~EOM
|
|
17
|
+
NOTE: minitest 5 will be the last in the minitest family to support
|
|
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.
|
|
22
|
+
|
|
23
|
+
Further, minitest 6 will be dropping the following:
|
|
24
|
+
|
|
25
|
+
+ MiniTest (it's been Minitest for >10 years)
|
|
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
|
|
16
32
|
end
|
|
17
33
|
|
|
18
34
|
desc "Find missing expectations"
|
data/design_rationale.rb
CHANGED
|
@@ -2,25 +2,27 @@
|
|
|
2
2
|
###############################################################################
|
|
3
3
|
describe Thingy do # class TestThingy < Minitest::Test
|
|
4
4
|
before do # def setup
|
|
5
|
-
do_some_setup # super
|
|
6
|
-
end # do_some_setup
|
|
7
|
-
# end
|
|
8
|
-
it "should do the first thing" do #
|
|
9
|
-
1.must_equal 1 # def test_first_thing
|
|
10
|
-
end # assert_equal 1, 1
|
|
11
|
-
# end
|
|
12
|
-
describe SubThingy do # end
|
|
13
|
-
before do #
|
|
14
|
-
do_more_setup # class TestSubThingy < TestThingy
|
|
15
|
-
end # def setup
|
|
16
5
|
# super
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
do_some_setup # do_some_setup
|
|
7
|
+
end # end
|
|
8
|
+
#
|
|
9
|
+
it "should do the first thing" do # def test_first_thing
|
|
10
|
+
_(1).must_equal 1 # assert_equal 1, 1
|
|
11
|
+
end # end
|
|
23
12
|
# end
|
|
13
|
+
#
|
|
14
|
+
describe SubThingy do # class TestSubThingy < TestThingy
|
|
15
|
+
before do # def setup
|
|
16
|
+
# super
|
|
17
|
+
do_more_setup # do_more_setup
|
|
18
|
+
end # end
|
|
19
|
+
#
|
|
20
|
+
it "should do the second thing" do # def test_second_thing
|
|
21
|
+
_(2).must_equal 2 # assert_equal 2, 2
|
|
22
|
+
end # end
|
|
23
|
+
end # end
|
|
24
|
+
end #
|
|
25
|
+
#
|
|
24
26
|
###############################################################################
|
|
25
27
|
# runs 2 specs # runs 3 tests
|
|
26
28
|
###############################################################################
|
|
@@ -33,7 +35,7 @@ class ThingySpec < Minitest::Spec
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def test_should_do_the_first_thing
|
|
36
|
-
|
|
38
|
+
_(1).must_equal 1
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
|
|
@@ -47,6 +49,6 @@ class SubThingySpec < ThingySpec
|
|
|
47
49
|
remove_method :test_should_do_the_first_thing
|
|
48
50
|
|
|
49
51
|
def test_should_do_the_second_thing
|
|
50
|
-
|
|
52
|
+
_(2).must_equal 2
|
|
51
53
|
end
|
|
52
54
|
end
|
data/lib/hoe/minitest.rb
CHANGED
data/lib/minitest/assertions.rb
CHANGED
|
@@ -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.
|
|
65
|
+
Tempfile.create "expect" do |a|
|
|
66
66
|
a.puts expect
|
|
67
67
|
a.flush
|
|
68
68
|
|
|
69
|
-
Tempfile.
|
|
69
|
+
Tempfile.create "butwas" do |b|
|
|
70
70
|
b.puts butwas
|
|
71
71
|
b.flush
|
|
72
72
|
|
|
@@ -196,6 +196,12 @@ module Minitest
|
|
|
196
196
|
.split(":in ", 2).first # clean up noise
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
+
def _caller_uplevel # :nodoc:
|
|
200
|
+
backtrace = caller
|
|
201
|
+
real_caller = Minitest.filter_backtrace(caller).first
|
|
202
|
+
backtrace.index(real_caller)
|
|
203
|
+
end
|
|
204
|
+
|
|
199
205
|
E = "" # :nodoc:
|
|
200
206
|
|
|
201
207
|
##
|
|
@@ -219,7 +225,7 @@ module Minitest
|
|
|
219
225
|
if Minitest::VERSION >= "6" then
|
|
220
226
|
refute_nil exp, "Use assert_nil if expecting nil."
|
|
221
227
|
else
|
|
222
|
-
warn "DEPRECATED: Use assert_nil if expecting nil
|
|
228
|
+
warn "DEPRECATED: Use assert_nil if expecting nil. This will fail in Minitest 6.", uplevel: _caller_uplevel
|
|
223
229
|
end
|
|
224
230
|
end
|
|
225
231
|
|
|
@@ -368,15 +374,12 @@ module Minitest
|
|
|
368
374
|
# error.
|
|
369
375
|
|
|
370
376
|
def assert_pattern
|
|
371
|
-
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
372
377
|
flunk "assert_pattern requires a block to capture errors." unless block_given?
|
|
373
378
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
flunk e.message
|
|
379
|
-
end
|
|
379
|
+
yield
|
|
380
|
+
pass
|
|
381
|
+
rescue NoMatchingPatternError => e
|
|
382
|
+
flunk e.message
|
|
380
383
|
end
|
|
381
384
|
|
|
382
385
|
##
|
|
@@ -471,7 +474,7 @@ module Minitest
|
|
|
471
474
|
# Fails unless the call returns a true value
|
|
472
475
|
|
|
473
476
|
def assert_send send_ary, m = nil
|
|
474
|
-
warn "DEPRECATED: assert_send.
|
|
477
|
+
warn "DEPRECATED: assert_send.", uplevel: _caller_uplevel
|
|
475
478
|
|
|
476
479
|
recv, msg, *args = send_ary
|
|
477
480
|
m = message(m) {
|
|
@@ -500,14 +503,9 @@ module Minitest
|
|
|
500
503
|
value = catch sym do
|
|
501
504
|
begin
|
|
502
505
|
yield
|
|
503
|
-
rescue
|
|
504
|
-
default += ", not :#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
|
|
505
|
-
rescue ArgumentError => e # 1.9 exception
|
|
506
|
+
rescue ArgumentError => e # 1.9+ exception
|
|
506
507
|
raise e unless e.message.include? "uncaught throw"
|
|
507
508
|
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
509
|
end
|
|
512
510
|
caught = false
|
|
513
511
|
end
|
|
@@ -692,8 +690,8 @@ module Minitest
|
|
|
692
690
|
# For comparing Floats. Fails if +exp+ and +act+ have a relative error
|
|
693
691
|
# less than +epsilon+.
|
|
694
692
|
|
|
695
|
-
def refute_in_epsilon
|
|
696
|
-
refute_in_delta
|
|
693
|
+
def refute_in_epsilon exp, act, epsilon = 0.001, msg = nil
|
|
694
|
+
refute_in_delta exp, act, [exp.abs, act.abs].min * epsilon, msg
|
|
697
695
|
end
|
|
698
696
|
|
|
699
697
|
##
|
|
@@ -756,15 +754,12 @@ module Minitest
|
|
|
756
754
|
# other exceptions will be raised as normal and generate a test error.
|
|
757
755
|
|
|
758
756
|
def refute_pattern
|
|
759
|
-
raise NotImplementedError, "only available in Ruby 3.0+" unless RUBY_VERSION >= "3.0"
|
|
760
757
|
flunk "refute_pattern requires a block to capture errors." unless block_given?
|
|
761
758
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
pass
|
|
767
|
-
end
|
|
759
|
+
yield
|
|
760
|
+
flunk "NoMatchingPatternError expected, but nothing was raised."
|
|
761
|
+
rescue NoMatchingPatternError
|
|
762
|
+
pass
|
|
768
763
|
end
|
|
769
764
|
|
|
770
765
|
##
|
data/lib/minitest/autorun.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require_relative "../minitest"
|
|
2
|
+
require_relative "spec"
|
|
3
|
+
require_relative "mock"
|
|
4
|
+
require_relative "hell" if ENV["MT_HELL"]
|
|
5
5
|
|
|
6
6
|
Minitest.autorun
|
data/lib/minitest/benchmark.rb
CHANGED
|
@@ -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#
|
|
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#
|
|
296
|
+
# See Minitest::Assertions#refute_pattern
|
|
297
297
|
#
|
|
298
298
|
# _ { ... }.wont_pattern_match [...]
|
|
299
299
|
#
|
data/lib/minitest/hell.rb
CHANGED
data/lib/minitest/mock.rb
CHANGED
|
@@ -30,21 +30,16 @@ 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
|
-
method_missing(method_id, *args, &b)
|
|
37
|
-
else
|
|
38
|
-
method_missing(method_id, *args, **kwargs, &b)
|
|
39
|
-
end
|
|
36
|
+
method_missing(method_id, *args, **kwargs, &b)
|
|
40
37
|
else
|
|
41
|
-
|
|
42
|
-
super(*args, &b)
|
|
43
|
-
else
|
|
44
|
-
super(*args, **kwargs, &b)
|
|
45
|
-
end
|
|
38
|
+
super(*args, **kwargs, &b)
|
|
46
39
|
end
|
|
47
40
|
end
|
|
41
|
+
ensure
|
|
42
|
+
$-w = old_w
|
|
48
43
|
end
|
|
49
44
|
|
|
50
45
|
def initialize delegator = nil # :nodoc:
|
|
@@ -142,8 +137,8 @@ module Minitest # :nodoc:
|
|
|
142
137
|
def verify
|
|
143
138
|
@expected_calls.each do |name, expected|
|
|
144
139
|
actual = @actual_calls.fetch name, nil # defaults to []
|
|
145
|
-
raise MockExpectationError, "
|
|
146
|
-
raise MockExpectationError, "
|
|
140
|
+
raise MockExpectationError, "Expected #{__call name, expected[0]}" unless actual
|
|
141
|
+
raise MockExpectationError, "Expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
|
|
147
142
|
actual.size < expected.size
|
|
148
143
|
end
|
|
149
144
|
true
|
|
@@ -152,11 +147,7 @@ module Minitest # :nodoc:
|
|
|
152
147
|
def method_missing sym, *args, **kwargs, &block # :nodoc:
|
|
153
148
|
unless @expected_calls.key? sym then
|
|
154
149
|
if @delegator && @delegator.respond_to?(sym)
|
|
155
|
-
|
|
156
|
-
return @delegator.public_send(sym, *args, &block)
|
|
157
|
-
else
|
|
158
|
-
return @delegator.public_send(sym, *args, **kwargs, &block)
|
|
159
|
-
end
|
|
150
|
+
return @delegator.public_send(sym, *args, **kwargs, &block)
|
|
160
151
|
else
|
|
161
152
|
raise NoMethodError, "unmocked method %p, expected one of %p" %
|
|
162
153
|
[sym, @expected_calls.keys.sort_by(&:to_s)]
|
|
@@ -245,13 +236,28 @@ end
|
|
|
245
236
|
|
|
246
237
|
module Minitest::Assertions
|
|
247
238
|
##
|
|
248
|
-
# Assert that the mock verifies correctly.
|
|
239
|
+
# Assert that the mock verifies correctly and fail if not.
|
|
249
240
|
|
|
250
|
-
def assert_mock mock
|
|
241
|
+
def assert_mock mock, msg = nil
|
|
251
242
|
assert mock.verify
|
|
243
|
+
rescue MockExpectationError => e
|
|
244
|
+
msg = message(msg) { e.message }
|
|
245
|
+
flunk msg
|
|
252
246
|
end
|
|
253
247
|
end
|
|
254
248
|
|
|
249
|
+
module Minitest::Expectations
|
|
250
|
+
##
|
|
251
|
+
# See Minitest::Assertions#assert_mock.
|
|
252
|
+
#
|
|
253
|
+
# _(collection).must_verify
|
|
254
|
+
#
|
|
255
|
+
# :method: must_verify
|
|
256
|
+
|
|
257
|
+
infect_an_assertion :assert_mock, :must_verify, :unary if
|
|
258
|
+
defined?(infect_an_assertion)
|
|
259
|
+
end
|
|
260
|
+
|
|
255
261
|
##
|
|
256
262
|
# Object extensions for Minitest::Mock.
|
|
257
263
|
|
|
@@ -302,18 +308,10 @@ class Object
|
|
|
302
308
|
else
|
|
303
309
|
metaclass.send :define_method, name do |*args, **kwargs, &blk|
|
|
304
310
|
if val_or_callable.respond_to? :call then
|
|
305
|
-
|
|
306
|
-
val_or_callable.call(*args, &blk)
|
|
307
|
-
else
|
|
308
|
-
val_or_callable.call(*args, **kwargs, &blk)
|
|
309
|
-
end
|
|
311
|
+
val_or_callable.call(*args, **kwargs, &blk)
|
|
310
312
|
else
|
|
311
313
|
if blk then
|
|
312
|
-
|
|
313
|
-
blk.call(*block_args)
|
|
314
|
-
else
|
|
315
|
-
blk.call(*block_args, **block_kwargs)
|
|
316
|
-
end
|
|
314
|
+
blk.call(*block_args, **block_kwargs)
|
|
317
315
|
end
|
|
318
316
|
val_or_callable
|
|
319
317
|
end
|
data/lib/minitest/parallel.rb
CHANGED
data/lib/minitest/pride.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "../minitest"
|
|
2
2
|
|
|
3
3
|
module Minitest
|
|
4
4
|
def self.plugin_pride_options opts, _options # :nodoc:
|
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "test"
|
|
2
2
|
|
|
3
3
|
class Module # :nodoc:
|
|
4
4
|
def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
|
|
@@ -38,7 +38,11 @@ class Module # :nodoc:
|
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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,8 @@ class Minitest::Spec < Minitest::Test
|
|
|
284
289
|
defined?(@name) ? @name : super
|
|
285
290
|
end
|
|
286
291
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
end
|
|
292
|
+
alias to_s name
|
|
293
|
+
alias inspect name
|
|
290
294
|
|
|
291
295
|
attr_reader :desc # :nodoc:
|
|
292
296
|
alias specify it
|
|
@@ -342,7 +346,7 @@ class Minitest::Spec < Minitest::Test
|
|
|
342
346
|
TYPES = DSL::TYPES # :nodoc:
|
|
343
347
|
end
|
|
344
348
|
|
|
345
|
-
|
|
349
|
+
require_relative "expectations"
|
|
346
350
|
|
|
347
351
|
class Object # :nodoc:
|
|
348
352
|
include Minitest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
|