minitest 5.22.3 → 5.25.1
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 +70 -0
- data/Manifest.txt +2 -0
- data/README.rdoc +15 -13
- data/Rakefile +6 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/autorun.rb +0 -7
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +11 -0
- data/lib/minitest/manual_plugins.rb +16 -0
- data/lib/minitest/mock.rb +13 -13
- data/lib/minitest/parallel.rb +5 -5
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +5 -5
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +17 -11
- data/lib/minitest.rb +204 -135
- data/test/minitest/metametameta.rb +18 -10
- data/test/minitest/test_minitest_assertions.rb +133 -134
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +79 -74
- data/test/minitest/test_minitest_reporter.rb +12 -16
- data/test/minitest/test_minitest_spec.rb +54 -55
- data/test/minitest/test_minitest_test.rb +84 -103
- data/test/minitest/test_minitest_test_task.rb +18 -9
- data.tar.gz.sig +0 -0
- metadata +5 -3
- metadata.gz.sig +0 -0
| @@ -1,4 +1,3 @@ | |
| 1 | 
            -
            # encoding: utf-8
         | 
| 2 1 | 
             
            require "minitest/metametameta"
         | 
| 3 2 | 
             
            require "stringio"
         | 
| 4 3 |  | 
| @@ -12,15 +11,12 @@ class ExampleA; end | |
| 12 11 | 
             
            class ExampleB < ExampleA; end
         | 
| 13 12 |  | 
| 14 13 | 
             
            describe Minitest::Spec do
         | 
| 15 | 
            -
              # helps to deal with 2.4 deprecation of Fixnum for Integer
         | 
| 16 | 
            -
              Int = 1.class
         | 
| 17 | 
            -
             | 
| 18 14 | 
             
              # do not parallelize this suite... it just can"t handle it.
         | 
| 19 15 |  | 
| 20 16 | 
             
              def assert_triggered expected = "blah", klass = Minitest::Assertion
         | 
| 21 17 | 
             
                @assertion_count += 1
         | 
| 22 18 |  | 
| 23 | 
            -
                e = assert_raises | 
| 19 | 
            +
                e = assert_raises klass do
         | 
| 24 20 | 
             
                  yield
         | 
| 25 21 | 
             
                end
         | 
| 26 22 |  | 
| @@ -29,17 +25,17 @@ describe Minitest::Spec do | |
| 29 25 | 
             
                msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
         | 
| 30 26 | 
             
                msg.gsub!(/:0x[Xa-fA-F0-9]{4,}[ @].+?>/, ":0xXXXXXX@PATH>")
         | 
| 31 27 |  | 
| 32 | 
            -
                 | 
| 28 | 
            +
                return unless expected
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                @assertion_count += 1
         | 
| 31 | 
            +
                case expected
         | 
| 32 | 
            +
                when String then
         | 
| 33 | 
            +
                  assert_equal expected, msg
         | 
| 34 | 
            +
                when Regexp then
         | 
| 33 35 | 
             
                  @assertion_count += 1
         | 
| 34 | 
            -
                   | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
                  when Regexp then
         | 
| 38 | 
            -
                    @assertion_count += 1
         | 
| 39 | 
            -
                    assert_match expected, msg
         | 
| 40 | 
            -
                  else
         | 
| 41 | 
            -
                    flunk "Unknown: #{expected.inspect}"
         | 
| 42 | 
            -
                  end
         | 
| 36 | 
            +
                  assert_match expected, msg
         | 
| 37 | 
            +
                else
         | 
| 38 | 
            +
                  flunk "Unknown: #{expected.inspect}"
         | 
| 43 39 | 
             
                end
         | 
| 44 40 | 
             
              end
         | 
| 45 41 |  | 
| @@ -196,7 +192,7 @@ describe Minitest::Spec do | |
| 196 192 | 
             
                methods = Minitest::Expectations.public_instance_methods.grep(/must|wont/)
         | 
| 197 193 | 
             
                methods.map!(&:to_s) if Symbol === methods.first
         | 
| 198 194 |  | 
| 199 | 
            -
                musts, wonts = methods.sort.partition { |m| m  | 
| 195 | 
            +
                musts, wonts = methods.sort.partition { |m| m.include? "must" }
         | 
| 200 196 |  | 
| 201 197 | 
             
                expected_musts = %w[must_be
         | 
| 202 198 | 
             
                                    must_be_close_to
         | 
| @@ -220,7 +216,7 @@ describe Minitest::Spec do | |
| 220 216 |  | 
| 221 217 | 
             
                bad = %w[not raise throw send output be_silent]
         | 
| 222 218 |  | 
| 223 | 
            -
                expected_wonts = expected_musts.map { |m| m.sub( | 
| 219 | 
            +
                expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
         | 
| 224 220 | 
             
                expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
         | 
| 225 221 |  | 
| 226 222 | 
             
                _(musts).must_equal expected_musts
         | 
| @@ -284,18 +280,14 @@ describe Minitest::Spec do | |
| 284 280 | 
             
              end
         | 
| 285 281 |  | 
| 286 282 | 
             
              it "needs to warn on equality with nil" do
         | 
| 287 | 
            -
                @assertion_count  | 
| 283 | 
            +
                @assertion_count = 3
         | 
| 284 | 
            +
                @assertion_count += 2 unless error_on_warn? # 2 extra assertions
         | 
| 288 285 |  | 
| 289 | 
            -
                 | 
| 286 | 
            +
                exp = /DEPRECATED: Use assert_nil if expecting nil from .* This will fail in Minitest 6./
         | 
| 287 | 
            +
             | 
| 288 | 
            +
                assert_deprecation exp do
         | 
| 290 289 | 
             
                  assert_success _(nil).must_equal(nil)
         | 
| 291 290 | 
             
                end
         | 
| 292 | 
            -
             | 
| 293 | 
            -
                exp = "DEPRECATED: Use assert_nil if expecting nil from #{__FILE__}:#{__LINE__-3}. " \
         | 
| 294 | 
            -
                  "This will fail in Minitest 6.\n"
         | 
| 295 | 
            -
                exp = "" if $-w.nil?
         | 
| 296 | 
            -
             | 
| 297 | 
            -
                assert_empty out
         | 
| 298 | 
            -
                assert_equal exp, err
         | 
| 299 291 | 
             
              end
         | 
| 300 292 |  | 
| 301 293 | 
             
              it "needs to verify floats outside a delta" do
         | 
| @@ -403,12 +395,12 @@ describe Minitest::Spec do | |
| 403 395 | 
             
              it "needs to verify instances of a class" do
         | 
| 404 396 | 
             
                assert_success _(42).wont_be_instance_of(String)
         | 
| 405 397 |  | 
| 406 | 
            -
                assert_triggered "Expected 42 to not be a kind of  | 
| 407 | 
            -
                  _(42).wont_be_kind_of  | 
| 398 | 
            +
                assert_triggered "Expected 42 to not be a kind of Integer." do
         | 
| 399 | 
            +
                  _(42).wont_be_kind_of Integer
         | 
| 408 400 | 
             
                end
         | 
| 409 401 |  | 
| 410 | 
            -
                assert_triggered "msg.\nExpected 42 to not be an instance of  | 
| 411 | 
            -
                  _(42).wont_be_instance_of  | 
| 402 | 
            +
                assert_triggered "msg.\nExpected 42 to not be an instance of Integer." do
         | 
| 403 | 
            +
                  _(42).wont_be_instance_of Integer, "msg"
         | 
| 412 404 | 
             
                end
         | 
| 413 405 | 
             
              end
         | 
| 414 406 |  | 
| @@ -418,26 +410,26 @@ describe Minitest::Spec do | |
| 418 410 | 
             
                assert_success _(42).wont_be_kind_of(String)
         | 
| 419 411 | 
             
                assert_success _(proc {}).wont_be_kind_of(String)
         | 
| 420 412 |  | 
| 421 | 
            -
                assert_triggered "Expected 42 to not be a kind of  | 
| 422 | 
            -
                  _(42).wont_be_kind_of  | 
| 413 | 
            +
                assert_triggered "Expected 42 to not be a kind of Integer." do
         | 
| 414 | 
            +
                  _(42).wont_be_kind_of Integer
         | 
| 423 415 | 
             
                end
         | 
| 424 416 |  | 
| 425 | 
            -
                assert_triggered "msg.\nExpected 42 to not be a kind of  | 
| 426 | 
            -
                  _(42).wont_be_kind_of  | 
| 417 | 
            +
                assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
         | 
| 418 | 
            +
                  _(42).wont_be_kind_of Integer, "msg"
         | 
| 427 419 | 
             
                end
         | 
| 428 420 | 
             
              end
         | 
| 429 421 |  | 
| 430 422 | 
             
              it "needs to verify kinds of objects" do
         | 
| 431 423 | 
             
                @assertion_count += 3 # extra test
         | 
| 432 424 |  | 
| 433 | 
            -
                assert_success _(6 * 7).must_be_kind_of( | 
| 425 | 
            +
                assert_success _(6 * 7).must_be_kind_of(Integer)
         | 
| 434 426 | 
             
                assert_success _(6 * 7).must_be_kind_of(Numeric)
         | 
| 435 427 |  | 
| 436 | 
            -
                assert_triggered "Expected 42 to be a kind of String, not  | 
| 428 | 
            +
                assert_triggered "Expected 42 to be a kind of String, not Integer." do
         | 
| 437 429 | 
             
                  _(6 * 7).must_be_kind_of String
         | 
| 438 430 | 
             
                end
         | 
| 439 431 |  | 
| 440 | 
            -
                assert_triggered "msg.\nExpected 42 to be a kind of String, not  | 
| 432 | 
            +
                assert_triggered "msg.\nExpected 42 to be a kind of String, not Integer." do
         | 
| 441 433 | 
             
                  _(6 * 7).must_be_kind_of String, "msg"
         | 
| 442 434 | 
             
                end
         | 
| 443 435 |  | 
| @@ -576,7 +568,8 @@ describe Minitest::Spec do | |
| 576 568 |  | 
| 577 569 | 
             
                it "can NOT use must_equal in a thread. It must use expect in a thread" do
         | 
| 578 570 | 
             
                  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
         | 
| 579 | 
            -
             | 
| 571 | 
            +
             | 
| 572 | 
            +
                  assert_raises RuntimeError, Minitest::UnexpectedWarning do
         | 
| 580 573 | 
             
                    capture_io do
         | 
| 581 574 | 
             
                      Thread.new { (1 + 1).must_equal 2 }.join
         | 
| 582 575 | 
             
                    end
         | 
| @@ -586,29 +579,33 @@ describe Minitest::Spec do | |
| 586 579 | 
             
                it "fails gracefully when expectation used outside of `it`" do
         | 
| 587 580 | 
             
                  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
         | 
| 588 581 |  | 
| 589 | 
            -
                  @assertion_count +=  | 
| 582 | 
            +
                  @assertion_count += 2 # assert_match is compound
         | 
| 590 583 |  | 
| 591 | 
            -
                  e = assert_raises RuntimeError do
         | 
| 584 | 
            +
                  e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
         | 
| 592 585 | 
             
                    capture_io do
         | 
| 593 586 | 
             
                      Thread.new { # forces ctx to be nil
         | 
| 594 | 
            -
                        describe | 
| 587 | 
            +
                        describe "woot" do
         | 
| 595 588 | 
             
                          (1 + 1).must_equal 2
         | 
| 596 589 | 
             
                        end
         | 
| 597 590 | 
             
                      }.join
         | 
| 598 591 | 
             
                    end
         | 
| 599 592 | 
             
                  end
         | 
| 600 593 |  | 
| 601 | 
            -
                   | 
| 594 | 
            +
                  exp = "Calling #must_equal outside of test."
         | 
| 595 | 
            +
                  exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
         | 
| 596 | 
            +
             | 
| 597 | 
            +
                  assert_match exp, e.message
         | 
| 602 598 | 
             
                end
         | 
| 603 599 |  | 
| 604 600 | 
             
                it "deprecates expectation used without _" do
         | 
| 605 601 | 
             
                  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
         | 
| 606 602 |  | 
| 607 | 
            -
                  @assertion_count +=  | 
| 603 | 
            +
                  @assertion_count += 1
         | 
| 604 | 
            +
                  @assertion_count += 2 unless error_on_warn?
         | 
| 608 605 |  | 
| 609 606 | 
             
                  exp = /DEPRECATED: global use of must_equal from/
         | 
| 610 607 |  | 
| 611 | 
            -
                   | 
| 608 | 
            +
                  assert_deprecation exp do
         | 
| 612 609 | 
             
                    (1 + 1).must_equal 2
         | 
| 613 610 | 
             
                  end
         | 
| 614 611 | 
             
                end
         | 
| @@ -618,12 +615,13 @@ describe Minitest::Spec do | |
| 618 615 | 
             
                it "deprecates expectation used without _ with empty backtrace_filter" do
         | 
| 619 616 | 
             
                  skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
         | 
| 620 617 |  | 
| 621 | 
            -
                  @assertion_count +=  | 
| 618 | 
            +
                  @assertion_count += 1
         | 
| 619 | 
            +
                  @assertion_count += 2 unless error_on_warn?
         | 
| 622 620 |  | 
| 623 621 | 
             
                  exp = /DEPRECATED: global use of must_equal from/
         | 
| 624 622 |  | 
| 625 623 | 
             
                  with_empty_backtrace_filter do
         | 
| 626 | 
            -
                     | 
| 624 | 
            +
                    assert_deprecation exp do
         | 
| 627 625 | 
             
                      (1 + 1).must_equal 2
         | 
| 628 626 | 
             
                    end
         | 
| 629 627 | 
             
                  end
         | 
| @@ -654,9 +652,9 @@ describe Minitest::Spec do | |
| 654 652 | 
             
              end
         | 
| 655 653 |  | 
| 656 654 | 
             
              it "needs to verify types of objects" do
         | 
| 657 | 
            -
                assert_success _(6 * 7).must_be_instance_of( | 
| 655 | 
            +
                assert_success _(6 * 7).must_be_instance_of(Integer)
         | 
| 658 656 |  | 
| 659 | 
            -
                exp = "Expected 42 to be an instance of String, not  | 
| 657 | 
            +
                exp = "Expected 42 to be an instance of String, not Integer."
         | 
| 660 658 |  | 
| 661 659 | 
             
                assert_triggered exp do
         | 
| 662 660 | 
             
                  _(6 * 7).must_be_instance_of String
         | 
| @@ -683,7 +681,7 @@ describe Minitest::Spec do | |
| 683 681 | 
             
                assert_success _(41).must_be(:<, 42)
         | 
| 684 682 |  | 
| 685 683 | 
             
                assert_triggered "Expected 42 to be < 41." do
         | 
| 686 | 
            -
                  _(42).must_be | 
| 684 | 
            +
                  _(42).must_be :<, 41
         | 
| 687 685 | 
             
                end
         | 
| 688 686 | 
             
              end
         | 
| 689 687 |  | 
| @@ -700,11 +698,11 @@ describe Minitest::Spec do | |
| 700 698 | 
             
              it "needs to verify using respond_to" do
         | 
| 701 699 | 
             
                assert_success _(42).must_respond_to(:+)
         | 
| 702 700 |  | 
| 703 | 
            -
                assert_triggered "Expected 42 ( | 
| 701 | 
            +
                assert_triggered "Expected 42 (Integer) to respond to #clear." do
         | 
| 704 702 | 
             
                  _(42).must_respond_to :clear
         | 
| 705 703 | 
             
                end
         | 
| 706 704 |  | 
| 707 | 
            -
                assert_triggered "msg.\nExpected 42 ( | 
| 705 | 
            +
                assert_triggered "msg.\nExpected 42 (Integer) to respond to #clear." do
         | 
| 708 706 | 
             
                  _(42).must_respond_to :clear, "msg"
         | 
| 709 707 | 
             
                end
         | 
| 710 708 | 
             
              end
         | 
| @@ -751,9 +749,9 @@ describe Minitest::Spec, :let do | |
| 751 749 | 
             
              it "doesn't raise an error if it is just another let" do
         | 
| 752 750 | 
             
                v = proc do
         | 
| 753 751 | 
             
                  describe :outer do
         | 
| 754 | 
            -
                    let | 
| 752 | 
            +
                    let :bar
         | 
| 755 753 | 
             
                    describe :inner do
         | 
| 756 | 
            -
                      let | 
| 754 | 
            +
                      let :bar
         | 
| 757 755 | 
             
                    end
         | 
| 758 756 | 
             
                  end
         | 
| 759 757 | 
             
                  :good
         | 
| @@ -1016,8 +1014,9 @@ class TestMeta < MetaMetaMetaTestCase | |
| 1016 1014 | 
             
                  z = describe "second thingy" do end
         | 
| 1017 1015 | 
             
                end
         | 
| 1018 1016 |  | 
| 1019 | 
            -
                test_methods = [ | 
| 1020 | 
            -
             | 
| 1017 | 
            +
                test_methods = [
         | 
| 1018 | 
            +
                                 "test_0001_top level it",
         | 
| 1019 | 
            +
                                 "test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
         | 
| 1021 1020 | 
             
                               ].sort
         | 
| 1022 1021 |  | 
| 1023 1022 | 
             
                assert_equal test_methods, [x1, x2]
         |