minitest 5.13.0 → 5.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b98534b771e1eb6b67bae4b151e957f74f7e2159b589c3527e5eb0762aaa94
4
- data.tar.gz: c5e6fab215fc67cf3133867954b55d438b00d11c1fa2df17efe456fc2ea29fb3
3
+ metadata.gz: c0b1641b87002f1e0b64cc5e81815a6bdbd22e22fa25f54f80316fe009f5ad72
4
+ data.tar.gz: d63d8373fa0888051f79d4ca405e267e97a5334ffb22aee248227e1485400af3
5
5
  SHA512:
6
- metadata.gz: ee628ae22e60b6457c8896b86e35cef293d2bd16277b9ed55ebb7b866a98c65087ca09416c214476c821a2147e40ad3ca0a7eeab9c6ce43f19e68807b5f1753e
7
- data.tar.gz: 99c5476047e5418137429ea4d8a5ead8d6f2bca2fb5e316dcff656d083d318ee2b19b66ce2365ee639b6217ef1ad5c22fda103497953639aebb0c5876c8f0683
6
+ metadata.gz: 76fa5340f5d7f9086b802c13440dad142be63e81d7874d4eb4ec42f60f4530038b74cac18830e2066c80572408f095b45c5639879a38790bacfd3c4a4e13730d
7
+ data.tar.gz: 80e644aeb07febab6f16d32af2e8435045e415d86d145c37afba0a6f694cba304b934a1ff146186a34b108ae3039ff610318e585af6fd087b5b8143aa1f3808a
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,16 @@
1
+ === 5.14.0 / 2020-01-11
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Block-assertions (eg assert_output) now error if raised inside the block. (casperisfine)
6
+ * Changed assert_raises to only catch Assertion since that covers Skip and friends.
7
+
8
+ * 3 bug fixes:
9
+
10
+ * Added example for value wrapper with block to Expectations module. (stomar)
11
+ * Fixed use of must/wont_be_within_delta on Expectation instance. (stomar)
12
+ * Renamed UnexpectedError#exception to #error to avoid problems with reraising. (casperisfine)
13
+
1
14
  === 5.13.0 / 2019-10-29
2
15
 
3
16
  * 9 minor enhancements:
@@ -677,6 +677,7 @@ minitest-unordered :: Adds a new assertion to minitest for checking the
677
677
  contents of a collection, ignoring element order.
678
678
  minitest-vcr :: Automatic cassette managment with Minitest::Spec
679
679
  and VCR.
680
+ minitest_log :: Adds structured logging, data explication, and verdicts.
680
681
  minitest_owrapper :: Get tests results as a TestResult object.
681
682
  minitest_should :: Shoulda style syntax for minitest test::unit.
682
683
  minitest_tu_shim :: Bridges between test/unit and minitest.
@@ -8,7 +8,7 @@ require "stringio"
8
8
  # :include: README.rdoc
9
9
 
10
10
  module Minitest
11
- VERSION = "5.13.0" # :nodoc:
11
+ VERSION = "5.14.0" # :nodoc:
12
12
  ENCS = "".respond_to? :encoding # :nodoc:
13
13
 
14
14
  @@installed_at_exit ||= false
@@ -907,24 +907,21 @@ module Minitest
907
907
  # Assertion wrapping an unexpected error that was raised during a run.
908
908
 
909
909
  class UnexpectedError < Assertion
910
- attr_accessor :exception # :nodoc:
910
+ # TODO: figure out how to use `cause` instead
911
+ attr_accessor :error # :nodoc:
911
912
 
912
- def initialize exception # :nodoc:
913
+ def initialize error # :nodoc:
913
914
  super "Unexpected exception"
914
- self.exception = exception
915
+ self.error = error
915
916
  end
916
917
 
917
918
  def backtrace # :nodoc:
918
- self.exception.backtrace
919
- end
920
-
921
- def error # :nodoc:
922
- self.exception
919
+ self.error.backtrace
923
920
  end
924
921
 
925
922
  def message # :nodoc:
926
923
  bt = Minitest.filter_backtrace(self.backtrace).join "\n "
927
- "#{self.exception.class}: #{self.exception.message}\n #{bt}"
924
+ "#{self.error.class}: #{self.error.message}\n #{bt}"
928
925
  end
929
926
 
930
927
  def result_label # :nodoc:
@@ -341,6 +341,10 @@ module Minitest
341
341
  x = send out_msg, stdout, out, "In stdout" if out_msg
342
342
 
343
343
  (!stdout || x) && (!stderr || y)
344
+ rescue Assertion
345
+ raise
346
+ rescue => e
347
+ raise UnexpectedError, e
344
348
  end
345
349
 
346
350
  ##
@@ -399,7 +403,7 @@ module Minitest
399
403
  rescue *exp => e
400
404
  pass # count assertion
401
405
  return e
402
- rescue Minitest::Skip, Minitest::Assertion
406
+ rescue Minitest::Assertion # incl Skip & UnexpectedError
403
407
  # don't count assertion
404
408
  raise
405
409
  rescue SignalException, SystemExit
@@ -485,6 +489,10 @@ module Minitest
485
489
  end
486
490
 
487
491
  assert caught, message(msg) { default }
492
+ rescue Assertion
493
+ raise
494
+ rescue => e
495
+ raise UnexpectedError, e
488
496
  end
489
497
 
490
498
  ##
@@ -557,6 +565,11 @@ module Minitest
557
565
  captured_stderr.unlink
558
566
  $stdout.reopen orig_stdout
559
567
  $stderr.reopen orig_stderr
568
+
569
+ orig_stdout.close
570
+ orig_stderr.close
571
+ captured_stdout.close
572
+ captured_stderr.close
560
573
  end
561
574
  end
562
575
  end
@@ -9,10 +9,11 @@
9
9
  #
10
10
  # it "should still work in threads" do
11
11
  # my_threaded_thingy do
12
- # (1+1).must_equal 2 # bad
13
- # assert_equal 2, 1+1 # good
14
- # _(1 + 1).must_equal 2 # good
15
- # value(1 + 1).must_equal 2 # good, also #expect
12
+ # (1+1).must_equal 2 # bad
13
+ # assert_equal 2, 1+1 # good
14
+ # _(1 + 1).must_equal 2 # good
15
+ # value(1 + 1).must_equal 2 # good, also #expect
16
+ # _ { 1 + "1" }.must_raise TypeError # good
16
17
  # end
17
18
  # end
18
19
 
@@ -45,7 +46,7 @@ module Minitest::Expectations
45
46
 
46
47
  infect_an_assertion :assert_in_delta, :must_be_close_to
47
48
 
48
- alias :must_be_within_delta :must_be_close_to # :nodoc:
49
+ infect_an_assertion :assert_in_delta, :must_be_within_delta # :nodoc:
49
50
 
50
51
  ##
51
52
  # See Minitest::Assertions#assert_in_epsilon
@@ -213,7 +214,7 @@ module Minitest::Expectations
213
214
 
214
215
  infect_an_assertion :refute_in_delta, :wont_be_close_to
215
216
 
216
- alias :wont_be_within_delta :wont_be_close_to # :nodoc:
217
+ infect_an_assertion :refute_in_delta, :wont_be_within_delta # :nodoc:
217
218
 
218
219
  ##
219
220
  # See Minitest::Assertions#refute_in_epsilon
@@ -77,6 +77,14 @@ class TestMinitestAssertions < Minitest::Test
77
77
  self.send assert_msg, expected, msg
78
78
  end
79
79
 
80
+ def assert_unexpected expected
81
+ expected = Regexp.new expected if String === expected
82
+
83
+ assert_triggered expected, Minitest::UnexpectedError do
84
+ yield
85
+ end
86
+ end
87
+
80
88
  def clean s
81
89
  s.gsub(/^ {6,10}/, "")
82
90
  end
@@ -603,12 +611,117 @@ class TestMinitestAssertions < Minitest::Test
603
611
  end
604
612
  end
605
613
 
606
- def test_assert_output_without_block
614
+ def test_assert_output_no_block
607
615
  assert_triggered "assert_output requires a block to capture output." do
608
616
  @tc.assert_output "blah"
609
617
  end
610
618
  end
611
619
 
620
+ def test_assert_output_nested_assert_uncaught
621
+ @assertion_count = 1
622
+
623
+ assert_triggered "Epic Fail!" do
624
+ @tc.assert_output "blah\n" do
625
+ puts "blah"
626
+ @tc.flunk
627
+ end
628
+ end
629
+ end
630
+
631
+ def test_assert_output_nested_raise
632
+ @assertion_count = 2
633
+
634
+ @tc.assert_output "blah\n" do
635
+ @tc.assert_raises RuntimeError do
636
+ puts "blah"
637
+ raise "boom!"
638
+ end
639
+ end
640
+ end
641
+
642
+ def test_assert_output_nested_raise_bad
643
+ @assertion_count = 0
644
+
645
+ assert_unexpected "boom!" do
646
+ @tc.assert_raises do # 2) bypassed via UnexpectedError
647
+ @tc.assert_output "blah\n" do # 1) captures and raises UnexpectedError
648
+ puts "not_blah"
649
+ raise "boom!"
650
+ end
651
+ end
652
+ end
653
+ end
654
+
655
+ def test_assert_output_nested_raise_mismatch
656
+ # this test is redundant, but illustrative
657
+ @assertion_count = 0
658
+
659
+ assert_unexpected "boom!" do
660
+ @tc.assert_raises RuntimeError do # 2) bypassed via UnexpectedError
661
+ @tc.assert_output "blah\n" do # 1) captures and raises UnexpectedError
662
+ puts "not_blah"
663
+ raise ArgumentError, "boom!"
664
+ end
665
+ end
666
+ end
667
+ end
668
+
669
+ def test_assert_output_nested_throw_caught
670
+ @assertion_count = 2
671
+
672
+ @tc.assert_output "blah\n" do
673
+ @tc.assert_throws :boom! do
674
+ puts "blah"
675
+ throw :boom!
676
+ end
677
+ end
678
+ end
679
+
680
+ def test_assert_output_nested_throw_caught_bad
681
+ @assertion_count = 1 # want 0; can't prevent throw from escaping :(
682
+
683
+ @tc.assert_throws :boom! do # 2) captured via catch
684
+ @tc.assert_output "blah\n" do # 1) bypassed via throw
685
+ puts "not_blah"
686
+ throw :boom!
687
+ end
688
+ end
689
+ end
690
+
691
+ def test_assert_output_nested_throw_mismatch
692
+ @assertion_count = 0
693
+
694
+ assert_unexpected "uncaught throw :boom!" do
695
+ @tc.assert_throws :not_boom! do # 2) captured via assert_throws+rescue
696
+ @tc.assert_output "blah\n" do # 1) bypassed via throw
697
+ puts "not_blah"
698
+ throw :boom!
699
+ end
700
+ end
701
+ end
702
+ end
703
+
704
+ def test_assert_output_uncaught_raise
705
+ @assertion_count = 0
706
+
707
+ assert_unexpected "RuntimeError: boom!" do
708
+ @tc.assert_output "blah\n" do
709
+ puts "not_blah"
710
+ raise "boom!"
711
+ end
712
+ end
713
+ end
714
+
715
+ def test_assert_output_uncaught_throw
716
+ @assertion_count = 0
717
+
718
+ assert_unexpected "uncaught throw :boom!" do
719
+ @tc.assert_output "blah\n" do
720
+ puts "not_blah"
721
+ throw :boom!
722
+ end
723
+ end
724
+ end
612
725
  def test_assert_predicate
613
726
  @tc.assert_predicate "", :empty?
614
727
  end
@@ -671,6 +784,19 @@ class TestMinitestAssertions < Minitest::Test
671
784
  end
672
785
  end
673
786
 
787
+ def test_assert_raises_throw_nested_bad
788
+ @assertion_count = 0
789
+
790
+ assert_unexpected "RuntimeError: boom!" do
791
+ @tc.assert_raises do
792
+ @tc.assert_throws :blah do
793
+ raise "boom!"
794
+ throw :not_blah
795
+ end
796
+ end
797
+ end
798
+ end
799
+
674
800
  ##
675
801
  # *sigh* This is quite an odd scenario, but it is from real (albeit
676
802
  # ugly) test code in ruby-core:
@@ -875,7 +1001,9 @@ class TestMinitestAssertions < Minitest::Test
875
1001
  end
876
1002
 
877
1003
  def test_assert_throws_argument_exception
878
- @tc.assert_raises ArgumentError do
1004
+ @assertion_count = 0
1005
+
1006
+ assert_unexpected "ArgumentError" do
879
1007
  @tc.assert_throws :blah do
880
1008
  raise ArgumentError
881
1009
  end
@@ -891,7 +1019,9 @@ class TestMinitestAssertions < Minitest::Test
891
1019
  end
892
1020
 
893
1021
  def test_assert_throws_name_error
894
- @tc.assert_raises NameError do
1022
+ @assertion_count = 0
1023
+
1024
+ assert_unexpected "NameError" do
895
1025
  @tc.assert_throws :blah do
896
1026
  raise NameError
897
1027
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.0
4
+ version: 5.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBBDANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE
15
+ GRYDY29tMB4XDTE5MTIxMzAwMDIwNFoXDTIwMTIxMjAwMDIwNFowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB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.000000000 Z
32
+ date: 2020-01-12 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rdoc
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.18'
60
+ version: '3.21'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.18'
67
+ version: '3.21'
68
68
  description: |-
69
69
  minitest provides a complete suite of testing facilities supporting
70
70
  TDD, BDD, mocking, and benchmarking.
@@ -158,7 +158,9 @@ files:
158
158
  homepage: https://github.com/seattlerb/minitest
159
159
  licenses:
160
160
  - MIT
161
- metadata: {}
161
+ metadata:
162
+ homepage_uri: https://github.com/seattlerb/minitest
163
+ bug_tracker_uri: https://github.com/seattlerb/minitest/issues
162
164
  post_install_message:
163
165
  rdoc_options:
164
166
  - "--main"
@@ -176,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
178
  - !ruby/object:Gem::Version
177
179
  version: '0'
178
180
  requirements: []
179
- rubygems_version: 3.0.6
181
+ rubygems_version: 3.0.3
180
182
  signing_key:
181
183
  specification_version: 4
182
184
  summary: minitest provides a complete suite of testing facilities supporting TDD,
metadata.gz.sig CHANGED
Binary file