Class: TestMinitestUnit

Inherits:
MetaMetaMetaTestCase show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb

Constant Summary collapse

MINITEST_BASE_DIR =
basedir[/\A\./] ? basedir : "./#{basedir}"
BT_MIDDLE =
["#{MINITEST_BASE_DIR}/test.rb:161:in `each'",
"#{MINITEST_BASE_DIR}/test.rb:158:in `each'",
"#{MINITEST_BASE_DIR}/test.rb:139:in `run'",
"#{MINITEST_BASE_DIR}/test.rb:106:in `run'"]

Constants inherited from Minitest::Test

Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS

Constants included from Minitest::Assertions

Minitest::Assertions::E, Minitest::Assertions::UNDEFINED

Constants inherited from Minitest::Runnable

Minitest::Runnable::SIGNALS

Instance Attribute Summary

Attributes inherited from MetaMetaMetaTestCase

#output, #reporter, #tu

Attributes inherited from Minitest::Runnable

#assertions, #failures, #time

Instance Method Summary collapse

Methods inherited from MetaMetaMetaTestCase

#assert_report, #first_reporter, #normalize_output, #restore_env, #run_tu_with_fresh_reporter, #setup, #with_stderr

Methods inherited from Minitest::Test

#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler

Methods included from Minitest::Guard

#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?

Methods included from Minitest::Test::LifecycleHooks

#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown

Methods included from Minitest::Reportable

#class_name, #error?, #location, #passed?, #result_code, #skipped?

Methods included from Minitest::Assertions

#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff

Methods inherited from Minitest::Runnable

#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler

Constructor Details

This class inherits a constructor from Minitest::Runnable

Instance Method Details

#test_filter_backtraceObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 36

def test_filter_backtrace
  # this is a semi-lame mix of relative paths.
  # I cheated by making the autotest parts not have ./
  bt = (["lib/autotest.rb:571:in `add_exception'",
         "test/test_autotest.rb:62:in `test_add_exception'",
         "#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
        BT_MIDDLE +
        ["#{MINITEST_BASE_DIR}/test.rb:29",
         "test/test_autotest.rb:422"])
  bt = util_expand_bt bt

  ex = ["lib/autotest.rb:571:in `add_exception'",
        "test/test_autotest.rb:62:in `test_add_exception'"]
  ex = util_expand_bt ex

  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
    fu = Minitest.filter_backtrace(bt)

    assert_equal ex, fu
  end
end

#test_filter_backtrace__emptyObject



82
83
84
85
86
87
88
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 82

def test_filter_backtrace__empty
  with_empty_backtrace_filter do
    bt = %w[first second third]
    fu = Minitest.filter_backtrace bt.dup
    assert_equal bt, fu
  end
end

#test_filter_backtrace_all_unitObject



58
59
60
61
62
63
64
65
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 58

def test_filter_backtrace_all_unit
  bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
        BT_MIDDLE +
        ["#{MINITEST_BASE_DIR}/test.rb:29"])
  ex = bt.clone
  fu = Minitest.filter_backtrace(bt)
  assert_equal ex, fu
end

#test_filter_backtrace_unit_startsObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 67

def test_filter_backtrace_unit_starts
  bt = (["#{MINITEST_BASE_DIR}/test.rb:165:in `__send__'"] +
        BT_MIDDLE +
        ["#{MINITEST_BASE_DIR}/mini/test.rb:29",
         "-e:1"])

  bt = util_expand_bt bt

  ex = ["-e:1"]
  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
    fu = Minitest.filter_backtrace bt
    assert_equal ex, fu
  end
end

#test_infectious_binary_encodingObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 90

def test_infectious_binary_encoding
  @tu = Class.new FakeNamedTest do
    def test_this_is_not_ascii_assertion
      assert_equal "ЁЁЁ", "ёёё"
    end

    def test_this_is_non_ascii_failure_message
      fail 'ЁЁЁ'.force_encoding('ASCII-8BIT')
    end
  end

  expected = clean <<-EOM
    FE

    Finished in 0.00

      1) Failure:
    FakeNamedTestXX#test_this_is_not_ascii_assertion [FILE:LINE]:
    Expected: \"ЁЁЁ\"
      Actual: \"ёёё\"

      2) Error:
    FakeNamedTestXX#test_this_is_non_ascii_failure_message:
    RuntimeError: ЁЁЁ
        FILE:LINE:in `test_this_is_non_ascii_failure_message'

    2 runs, 1 assertions, 1 failures, 1 errors, 0 skips
  EOM

  Minitest::Test.io_lock.synchronize do # try not to trounce in parallel
    assert_report expected
  end
end

#test_passed_eh_teardown_flunkedObject



152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 152

def test_passed_eh_teardown_flunked
  test_class = Class.new FakeNamedTest do
    def teardown; flunk;       end
    def test_omg; assert true; end
  end

  test = test_class.new :test_omg
  test.run

  refute_predicate test, :error?
  refute_predicate test, :passed?
  refute_predicate test, :skipped?
end

#test_passed_eh_teardown_goodObject



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 124

def test_passed_eh_teardown_good
  test_class = Class.new FakeNamedTest do
    def teardown; assert true; end
    def test_omg; assert true; end
  end

  test = test_class.new :test_omg
  test.run

  refute_predicate test, :error?
  assert_predicate test, :passed?
  refute_predicate test, :skipped?
end

#test_passed_eh_teardown_skippedObject



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 138

def test_passed_eh_teardown_skipped
  test_class = Class.new FakeNamedTest do
    def teardown; assert true; end
    def test_omg; skip "bork"; end
  end

  test = test_class.new :test_omg
  test.run

  refute_predicate test, :error?
  refute_predicate test, :passed?
  assert_predicate test, :skipped?
end

#util_expand_bt(bt) ⇒ Object



166
167
168
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/test/minitest/test_minitest_test.rb', line 166

def util_expand_bt bt
  bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
end