File: test_minitest_excludes.rb

package info (click to toggle)
ruby-minitest-excludes 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120 kB
  • sloc: ruby: 147; makefile: 6
file content (58 lines) | stat: -rw-r--r-- 1,704 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'test/metametameta'
require 'minitest/excludes'

class TestMinitestExcludes < MetaMetaMetaTestCase
  def test_cls_excludes
    Minitest.seed = 42 if Minitest.respond_to?(:seed=)
    srand 42
    old_exclude_base = Minitest::Test::EXCLUDE_DIR

    @assertion_count = 0

    Dir.mktmpdir do |path|
      Minitest::Test::EXCLUDE_DIR.replace(path)
      Dir.mkdir File.join path, "ATestCase"

      s = 'exclude :test_test2, "because it is borked"'

      File.write File.join(path, "ATestCase.rb"), s
      File.write File.join(path, "ATestCase/Nested.rb"), s

      tc1 = tc2 = nil

      tc1 = Class.new(Minitest::Test) do
        def test_test1; assert true  end
        def test_test2; assert false end # oh noes!
        def test_test3; assert true  end

        tc2 = Class.new(Minitest::Test) do
          def test_test1; assert true  end
          def test_test2; assert false end # oh noes!
          def test_test3; assert true  end
        end
      end

      Object.const_set(:ATestCase, tc1)
      ATestCase.const_set(:Nested, tc2)

      @tus = [tc1, tc2]

      assert_equal %w(test_test1 test_test3), ATestCase.runnable_methods.sort
      assert_equal %w(test_test1 test_test3), ATestCase::Nested.runnable_methods.sort

      expected = <<-EOM.gsub(/^ {8}/, '')
        ATestCase#test_test3 = 0.00 s = .
        ATestCase#test_test1 = 0.00 s = .
        ATestCase::Nested#test_test3 = 0.00 s = .
        ATestCase::Nested#test_test1 = 0.00 s = .

        Finished in 0.00

        4 runs, 4 assertions, 0 failures, 0 errors, 0 skips
      EOM
      assert_report expected, %w[--seed 42 --verbose]
    end
  ensure
    Minitest::Test::EXCLUDE_DIR.replace(old_exclude_base)
  end
end