minitest 5.16.2 → 6.0.5

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/History.rdoc +373 -1
  4. data/Manifest.txt +16 -4
  5. data/README.rdoc +48 -118
  6. data/Rakefile +17 -2
  7. data/bin/minitest +5 -0
  8. data/design_rationale.rb +21 -19
  9. data/lib/hoe/minitest.rb +4 -2
  10. data/lib/minitest/assertions.rb +142 -124
  11. data/lib/minitest/autorun.rb +3 -11
  12. data/lib/minitest/benchmark.rb +9 -12
  13. data/lib/minitest/bisect.rb +304 -0
  14. data/lib/minitest/complete.rb +56 -0
  15. data/lib/minitest/compress.rb +94 -0
  16. data/lib/minitest/error_on_warning.rb +11 -0
  17. data/lib/minitest/expectations.rb +18 -0
  18. data/lib/minitest/find_minimal_combination.rb +127 -0
  19. data/lib/minitest/hell.rb +1 -1
  20. data/lib/minitest/manual_plugins.rb +4 -0
  21. data/lib/minitest/parallel.rb +10 -8
  22. data/lib/minitest/path_expander.rb +432 -0
  23. data/lib/minitest/pride.rb +2 -2
  24. data/lib/minitest/pride_plugin.rb +17 -24
  25. data/lib/minitest/server.rb +49 -0
  26. data/lib/minitest/server_plugin.rb +88 -0
  27. data/lib/minitest/spec.rb +27 -46
  28. data/lib/minitest/sprint.rb +105 -0
  29. data/lib/minitest/sprint_plugin.rb +39 -0
  30. data/lib/minitest/test.rb +32 -52
  31. data/lib/minitest/test_task.rb +68 -42
  32. data/lib/minitest.rb +361 -215
  33. data/test/minitest/metametameta.rb +33 -19
  34. data/test/minitest/test_bisect.rb +249 -0
  35. data/test/minitest/test_find_minimal_combination.rb +138 -0
  36. data/test/minitest/test_minitest_assertions.rb +311 -173
  37. data/test/minitest/test_minitest_benchmark.rb +15 -1
  38. data/test/minitest/test_minitest_reporter.rb +148 -23
  39. data/test/minitest/test_minitest_spec.rb +157 -132
  40. data/test/minitest/test_minitest_test.rb +270 -204
  41. data/test/minitest/test_minitest_test_task.rb +18 -7
  42. data/test/minitest/test_path_expander.rb +229 -0
  43. data/test/minitest/test_server.rb +146 -0
  44. data.tar.gz.sig +2 -2
  45. metadata +97 -37
  46. metadata.gz.sig +0 -0
  47. data/.autotest +0 -34
  48. data/lib/minitest/mock.rb +0 -323
  49. data/lib/minitest/unit.rb +0 -42
  50. data/test/minitest/test_minitest_mock.rb +0 -1139
data/README.rdoc CHANGED
@@ -1,15 +1,17 @@
1
- = minitest/{test,spec,mock,benchmark}
1
+ = minitest/{test,spec,benchmark}
2
2
 
3
- home :: https://github.com/seattlerb/minitest
4
- bugs :: https://github.com/seattlerb/minitest/issues
3
+ home :: https://minite.st/
4
+ code :: https://github.com/minitest/minitest
5
+ bugs :: https://github.com/minitest/minitest/issues
5
6
  rdoc :: https://docs.seattlerb.org/minitest
6
- vim :: https://github.com/sunaku/vim-ruby-minitest
7
+ clog :: https://github.com/minitest/minitest/blob/master/History.rdoc
7
8
  emacs:: https://github.com/arthurnn/minitest-emacs
9
+ vim :: https://github.com/vim-test/vim-test
8
10
 
9
11
  == DESCRIPTION:
10
12
 
11
13
  minitest provides a complete suite of testing facilities supporting
12
- TDD, BDD, mocking, and benchmarking.
14
+ TDD, BDD, and benchmarking.
13
15
 
14
16
  "I had a class with Jim Weirich on testing last week and we were
15
17
  allowed to choose our testing frameworks. Kirk Haines and I were
@@ -35,9 +37,6 @@ algorithms in a repeatable manner. Now you can assert that your newb
35
37
  co-worker doesn't replace your linear algorithm with an exponential
36
38
  one!
37
39
 
38
- minitest/mock by Steven Baker, is a beautifully tiny mock (and stub)
39
- object framework.
40
-
41
40
  minitest/pride shows pride in testing and adds coloring to your test
42
41
  output. I guess it is an example of how to write IO pipes too. :P
43
42
 
@@ -67,7 +66,6 @@ extract-method refactorings still apply.
67
66
  * minitest/autorun - the easy and explicit way to run all your tests.
68
67
  * minitest/test - a very fast, simple, and clean test system.
69
68
  * minitest/spec - a very fast, simple, and clean spec system.
70
- * minitest/mock - a simple and clean mock/stub system.
71
69
  * minitest/benchmark - an awesome way to assert your algorithm's performance.
72
70
  * minitest/pride - show your pride in testing!
73
71
  * minitest/test_task - a full-featured and clean rake task generator.
@@ -94,7 +92,9 @@ Given that you'd like to test the following class:
94
92
 
95
93
  === Unit tests
96
94
 
97
- Define your tests as methods beginning with +test_+.
95
+ Define your tests as methods beginning with +test_+. Use
96
+ {assertions}[/minitest/Minitest/Assertions.html] to test for results
97
+ or state.
98
98
 
99
99
  require "minitest/autorun"
100
100
 
@@ -118,6 +118,9 @@ Define your tests as methods beginning with +test_+.
118
118
 
119
119
  === Specs
120
120
 
121
+ Use {expectations}[/minitest/Minitest/Expectations.html] to check
122
+ results or state. They must be wrapped in a value call (eg +_+).
123
+
121
124
  require "minitest/autorun"
122
125
 
123
126
  describe Meme do
@@ -145,7 +148,7 @@ For matchers support check out:
145
148
 
146
149
  === Benchmarks
147
150
 
148
- Add benchmarks to your tests.
151
+ Add {benchmarks}[/minitest/Minitest/Benchmark.html] to your tests.
149
152
 
150
153
  # optionally run benchmarks, good for CI-only work!
151
154
  require "minitest/benchmark" if ENV["BENCH"]
@@ -184,85 +187,6 @@ outputs something like:
184
187
 
185
188
  Output is tab-delimited to make it easy to paste into a spreadsheet.
186
189
 
187
- === Mocks
188
-
189
- Mocks and stubs defined using terminology by Fowler & Meszaros at
190
- https://www.martinfowler.com/bliki/TestDouble.html:
191
-
192
- "Mocks are pre-programmed with expectations which form a specification
193
- of the calls they are expected to receive. They can throw an exception
194
- if they receive a call they don't expect and are checked during
195
- verification to ensure they got all the calls they were expecting."
196
-
197
- class MemeAsker
198
- def initialize(meme)
199
- @meme = meme
200
- end
201
-
202
- def ask(question)
203
- method = question.tr(" ", "_") + "?"
204
- @meme.__send__(method)
205
- end
206
- end
207
-
208
- require "minitest/autorun"
209
-
210
- describe MemeAsker, :ask do
211
- describe "when passed an unpunctuated question" do
212
- it "should invoke the appropriate predicate method on the meme" do
213
- @meme = Minitest::Mock.new
214
- @meme_asker = MemeAsker.new @meme
215
- @meme.expect :will_it_blend?, :return_value
216
-
217
- @meme_asker.ask "will it blend"
218
-
219
- @meme.verify
220
- end
221
- end
222
- end
223
-
224
- ==== Multi-threading and Mocks
225
-
226
- Minitest mocks do not support multi-threading. If it works, fine, if it doesn't
227
- you can use regular ruby patterns and facilities like local variables. Here's
228
- an example of asserting that code inside a thread is run:
229
-
230
- def test_called_inside_thread
231
- called = false
232
- pr = Proc.new { called = true }
233
- thread = Thread.new(&pr)
234
- thread.join
235
- assert called, "proc not called"
236
- end
237
-
238
- === Stubs
239
-
240
- Mocks and stubs are defined using terminology by Fowler & Meszaros at
241
- https://www.martinfowler.com/bliki/TestDouble.html:
242
-
243
- "Stubs provide canned answers to calls made during the test".
244
-
245
- Minitest's stub method overrides a single method for the duration of
246
- the block.
247
-
248
- def test_stale_eh
249
- obj_under_test = Something.new
250
-
251
- refute obj_under_test.stale?
252
-
253
- Time.stub :now, Time.at(0) do # stub goes away once the block is done
254
- assert obj_under_test.stale?
255
- end
256
- end
257
-
258
- A note on stubbing: In order to stub a method, the method must
259
- actually exist prior to stubbing. Use a singleton method to create a
260
- new non-existing method:
261
-
262
- def obj_under_test.fake_method
263
- ...
264
- end
265
-
266
190
  === Running Your Tests
267
191
 
268
192
  Ideally, you'll use a rake task to run your tests (see below), either
@@ -405,39 +329,43 @@ Using our example above, here is how we might implement MyCI:
405
329
 
406
330
  === What versions are compatible with what? Or what versions are supported?
407
331
 
408
- Minitest is a dependency of rails, which until fairly recently had an
332
+ Minitest is a dependency of rails, which until very recently had an
409
333
  overzealous backwards compatibility policy. As such, I'm stuck
410
- supporting versions of ruby that are long past EOL. Once rails 5.2 is
411
- dropped (hopefully April 2021), I get to drop a bunch of versions of
412
- ruby that I have to currently test against.
334
+ supporting versions of ruby that are long past EOL. Hopefully I'll be
335
+ able to support only current versions of ruby sometime in the near
336
+ future.
337
+
338
+ NOTICE: At this point, I will only locally test/dev against the
339
+ currently 3 supported (non-EOL) versions of ruby. I cannot and will
340
+ not maintain that many builds.
413
341
 
414
- (As of 2021-01-31)
342
+ (As of 2025-02-03)
415
343
 
416
344
  Current versions of rails: (https://endoflife.date/rails)
417
345
 
418
- | rails | min ruby | rec ruby | minitest | status |
419
- |-------+----------+----------+----------+----------|
420
- | 7.0 | >= 2.7 | 3.0 | >= 5.1 | Future |
421
- | 6.1 | >= 2.5 | 3.0 | >= 5.1 | Current |
422
- | 6.0 | >= 2.5 | 2.6 | >= 5.1 | Security |
423
- | 5.2 | >= 2.2.2 | 2.5 | ~> 5.1 | Security | EOL @railsconf 2021?
346
+ | rails | min ruby | minitest | status | EOL Date |
347
+ |-------+----------+----------+----------+------------|
348
+ | 8.1 | >= 3.2 | >= 5.1 | Current | 2027-10-07 |
349
+ | 8.0 | >= 3.2 | >= 5.1 | Current | 2026-11-07 |
350
+ | 7.2 | >= 3.1 | >= 5.1 | Security | 2026-08-09 |
351
+ | 7.1 | >= 2.7 | >= 5.1 | EOL | 2025-10-01 |
352
+
353
+ If you want to look at the requirements for a specific version, run:
354
+
355
+ gem spec -r --ruby rails -v 8.0.0
424
356
 
425
357
  Current versions of ruby: (https://endoflife.date/ruby)
426
358
 
427
359
  | ruby | Status | EOL Date |
428
360
  |------+---------+------------|
429
- | 3.0 | Current | 2024-03-31 |
430
- | 2.7 | Maint | 2023-03-31 |
431
- | 2.6 | Maint* | 2022-03-31 |
361
+ | 3.4 | Current | 2028-03-31 |
362
+ | 3.3 | Maint | 2027-03-31 |
363
+ | 3.2 | Security| 2026-03-31 |
364
+ | 3.1 | EOL | 2025-03-31 |
365
+ | 3.0 | EOL | 2024-03-31 |
366
+ | 2.7 | EOL | 2023-03-31 |
367
+ | 2.6 | EOL | 2022-03-31 |
432
368
  | 2.5 | EOL | 2021-03-31 |
433
- | 2.4 | EOL | 2020-03-31 |
434
- | 2.3 | EOL | 2019-03-31 |
435
- | 2.2 | EOL | 2018-03-31 |
436
-
437
- See also:
438
-
439
- * https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
440
- * https://jamesjeffersconsulting.com/ruby-rails-version-matrix/
441
369
 
442
370
  === How to test SimpleDelegates?
443
371
 
@@ -641,6 +569,7 @@ minitest-capistrano :: Assertions and expectations for testing
641
569
  Capistrano recipes.
642
570
  minitest-capybara :: Capybara matchers support for minitest unit and
643
571
  spec.
572
+ minitest-cc :: It provides minimal information about code coverage.
644
573
  minitest-chef-handler :: Run Minitest suites as Chef report handlers
645
574
  minitest-ci :: CI reporter plugin for Minitest.
646
575
  minitest-context :: Defines contexts for code reuse in Minitest
@@ -675,6 +604,9 @@ minitest-happy :: GLOBALLY ACTIVATE MINITEST PRIDE! RAWR!
675
604
  minitest-have_tag :: Adds Minitest assertions to test for the existence of
676
605
  HTML tags, including contents, within a provided string.
677
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.
678
610
  minitest-hooks :: Around and before_all/after_all/around_all hooks
679
611
  minitest-hyper :: Pretty, single-page HTML reports for your Minitest runs
680
612
  minitest-implicit-subject :: Implicit declaration of the test subject.
@@ -739,7 +671,7 @@ minitest-stub-const :: Stub constants for the duration of a block.
739
671
  minitest-tags :: Add tags for minitest.
740
672
  minitest-unordered :: Adds a new assertion to minitest for checking the
741
673
  contents of a collection, ignoring element order.
742
- minitest-vcr :: Automatic cassette managment with Minitest::Spec
674
+ minitest-vcr :: Automatic cassette management with Minitest::Spec
743
675
  and VCR.
744
676
  minitest_log :: Adds structured logging, data explication, and verdicts.
745
677
  minitest_owrapper :: Get tests results as a TestResult object.
@@ -749,12 +681,10 @@ mongoid-minitest :: Minitest matchers for Mongoid.
749
681
  mutant-minitest :: Minitest integration for mutant.
750
682
  pry-rescue :: A pry plugin w/ minitest support. See
751
683
  pry-rescue/minitest.rb.
752
- rematch :: Declutter your test files from large hardcoded data
753
- and update them automatically when your code changes.
754
684
  rspec2minitest :: Easily translate any RSpec matchers to Minitest
755
685
  assertions and expectations.
756
- stubberry :: Multiple stubbing 'berries', sweet and useful
757
- stub helpers and assertions. ( stub_must,
686
+ stubberry :: Multiple stubbing 'berries', sweet and useful
687
+ stub helpers and assertions. ( stub_must,
758
688
  assert_method_called, stubbing ORM objects by id )
759
689
 
760
690
  == Unknown Extensions:
@@ -785,7 +715,7 @@ Authors... Please send me a pull request with a description of your minitest ext
785
715
 
786
716
  == REQUIREMENTS:
787
717
 
788
- * Ruby 2.3+. No magic is involved. I hope.
718
+ * Ruby 3.2+. No magic is involved. I hope.
789
719
 
790
720
  == INSTALL:
791
721
 
data/Rakefile CHANGED
@@ -1,17 +1,26 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require "rubygems"
4
3
  require "hoe"
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 [">= 2.6", "< 4.0"]
16
+ require_ruby_version ">= 3.2"
17
+
18
+ dependency "prism", "~> 1.5"
19
+ dependency "drb", "~> 2.0"
20
+
21
+ self.rdoc_locations << "l:/home/www/minite.st/html/docs"
22
+
23
+ self.cov_filter = %w[ tmp ]
15
24
  end
16
25
 
17
26
  desc "Find missing expectations"
@@ -32,6 +41,7 @@ task :specs do
32
41
  /_includes/ => "_include",
33
42
  /(must|wont)_(.*_of|nil|silent|empty)/ => '\1_be_\2',
34
43
  /must_raises/ => "must_raise",
44
+ /(must|wont)_pattern/ => '\1_pattern_match',
35
45
  /(must|wont)_predicate/ => '\1_be',
36
46
  /(must|wont)_path_exists/ => 'path_\1_exist',
37
47
  }
@@ -71,4 +81,9 @@ task :bugs do
71
81
  sh "for f in bug*.rb ; do echo $f; echo; #{Gem.ruby} -Ilib $f && rm $f ; done"
72
82
  end
73
83
 
84
+ Minitest::TestTask.create :testW0 do |t|
85
+ t.warning = false
86
+ t.test_prelude = "$-w = nil"
87
+ end
88
+
74
89
  # vim: syntax=Ruby
data/bin/minitest ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S ruby
2
+
3
+ require_relative "../lib/minitest/sprint"
4
+
5
+ Minitest::Sprint.run
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
- it "should do the second thing" do # do_more_setup
18
- 2.must_equal 2 # end
19
- end #
20
- end # def test_second_thing
21
- end # assert_equal 2, 2
22
- # end
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
- assert_equal 1, 1
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
- assert_equal 2, 2
52
+ _(2).must_equal 2
51
53
  end
52
54
  end
data/lib/hoe/minitest.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # :stopdoc:
2
2
 
3
3
  class Hoe
4
+ # empty
4
5
  end
5
6
 
6
7
  module Hoe::Minitest
@@ -10,13 +11,14 @@ module Hoe::Minitest
10
11
 
11
12
  def initialize_minitest
12
13
  unless minitest? then
13
- dir = "../../minitest/dev/lib"
14
+ dir = File.expand_path "../..", __FILE__
15
+
14
16
  Hoe.add_include_dirs dir if File.directory? dir
15
17
  end
16
18
 
17
19
  gem "minitest"
18
20
  require "minitest"
19
- version = Minitest::VERSION.split(/\./).first(2).join(".")
21
+ version = Minitest::VERSION.split(".").first(2).join "."
20
22
 
21
23
  dependency "minitest", "~> #{version}", :development unless
22
24
  minitest? or ENV["MT_NO_ISOLATE"]