minitest 5.24.1 → 5.25.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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(klass) do
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
- if expected
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
- case expected
35
- when String then
36
- assert_equal expected, msg
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 =~ /must/ }
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(/must/, "wont") }.sort
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
@@ -399,12 +395,12 @@ describe Minitest::Spec do
399
395
  it "needs to verify instances of a class" do
400
396
  assert_success _(42).wont_be_instance_of(String)
401
397
 
402
- assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
403
- _(42).wont_be_kind_of Int
398
+ assert_triggered "Expected 42 to not be a kind of Integer." do
399
+ _(42).wont_be_kind_of Integer
404
400
  end
405
401
 
406
- assert_triggered "msg.\nExpected 42 to not be an instance of #{Int.name}." do
407
- _(42).wont_be_instance_of Int, "msg"
402
+ assert_triggered "msg.\nExpected 42 to not be an instance of Integer." do
403
+ _(42).wont_be_instance_of Integer, "msg"
408
404
  end
409
405
  end
410
406
 
@@ -414,26 +410,26 @@ describe Minitest::Spec do
414
410
  assert_success _(42).wont_be_kind_of(String)
415
411
  assert_success _(proc {}).wont_be_kind_of(String)
416
412
 
417
- assert_triggered "Expected 42 to not be a kind of #{Int.name}." do
418
- _(42).wont_be_kind_of Int
413
+ assert_triggered "Expected 42 to not be a kind of Integer." do
414
+ _(42).wont_be_kind_of Integer
419
415
  end
420
416
 
421
- assert_triggered "msg.\nExpected 42 to not be a kind of #{Int.name}." do
422
- _(42).wont_be_kind_of Int, "msg"
417
+ assert_triggered "msg.\nExpected 42 to not be a kind of Integer." do
418
+ _(42).wont_be_kind_of Integer, "msg"
423
419
  end
424
420
  end
425
421
 
426
422
  it "needs to verify kinds of objects" do
427
423
  @assertion_count += 3 # extra test
428
424
 
429
- assert_success _(6 * 7).must_be_kind_of(Int)
425
+ assert_success _(6 * 7).must_be_kind_of(Integer)
430
426
  assert_success _(6 * 7).must_be_kind_of(Numeric)
431
427
 
432
- assert_triggered "Expected 42 to be a kind of String, not #{Int.name}." do
428
+ assert_triggered "Expected 42 to be a kind of String, not Integer." do
433
429
  _(6 * 7).must_be_kind_of String
434
430
  end
435
431
 
436
- assert_triggered "msg.\nExpected 42 to be a kind of String, not #{Int.name}." do
432
+ assert_triggered "msg.\nExpected 42 to be a kind of String, not Integer." do
437
433
  _(6 * 7).must_be_kind_of String, "msg"
438
434
  end
439
435
 
@@ -588,7 +584,7 @@ describe Minitest::Spec do
588
584
  e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
589
585
  capture_io do
590
586
  Thread.new { # forces ctx to be nil
591
- describe("woot") do
587
+ describe "woot" do
592
588
  (1 + 1).must_equal 2
593
589
  end
594
590
  }.join
@@ -656,9 +652,9 @@ describe Minitest::Spec do
656
652
  end
657
653
 
658
654
  it "needs to verify types of objects" do
659
- assert_success _(6 * 7).must_be_instance_of(Int)
655
+ assert_success _(6 * 7).must_be_instance_of(Integer)
660
656
 
661
- exp = "Expected 42 to be an instance of String, not #{Int.name}."
657
+ exp = "Expected 42 to be an instance of String, not Integer."
662
658
 
663
659
  assert_triggered exp do
664
660
  _(6 * 7).must_be_instance_of String
@@ -685,7 +681,7 @@ describe Minitest::Spec do
685
681
  assert_success _(41).must_be(:<, 42)
686
682
 
687
683
  assert_triggered "Expected 42 to be < 41." do
688
- _(42).must_be(:<, 41)
684
+ _(42).must_be :<, 41
689
685
  end
690
686
  end
691
687
 
@@ -702,11 +698,11 @@ describe Minitest::Spec do
702
698
  it "needs to verify using respond_to" do
703
699
  assert_success _(42).must_respond_to(:+)
704
700
 
705
- assert_triggered "Expected 42 (#{Int.name}) to respond to #clear." do
701
+ assert_triggered "Expected 42 (Integer) to respond to #clear." do
706
702
  _(42).must_respond_to :clear
707
703
  end
708
704
 
709
- assert_triggered "msg.\nExpected 42 (#{Int.name}) to respond to #clear." do
705
+ assert_triggered "msg.\nExpected 42 (Integer) to respond to #clear." do
710
706
  _(42).must_respond_to :clear, "msg"
711
707
  end
712
708
  end
@@ -753,9 +749,9 @@ describe Minitest::Spec, :let do
753
749
  it "doesn't raise an error if it is just another let" do
754
750
  v = proc do
755
751
  describe :outer do
756
- let(:bar)
752
+ let :bar
757
753
  describe :inner do
758
- let(:bar)
754
+ let :bar
759
755
  end
760
756
  end
761
757
  :good
@@ -1018,8 +1014,9 @@ class TestMeta < MetaMetaMetaTestCase
1018
1014
  z = describe "second thingy" do end
1019
1015
  end
1020
1016
 
1021
- test_methods = ["test_0001_top level it",
1022
- "test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
1017
+ test_methods = [
1018
+ "test_0001_top level it",
1019
+ "test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world",
1023
1020
  ].sort
1024
1021
 
1025
1022
  assert_equal test_methods, [x1, x2]