class TestMinitestUnit

Constants

BT_MIDDLE
MINITEST_BASE_DIR

Public Instance Methods

teardown() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 116
def teardown; assert true; end
test_filter_backtrace() click to toggle source
# File minitest-5.13.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

  fu = Minitest.filter_backtrace(bt)

  assert_equal ex, fu
end
test_filter_backtrace_all_unit() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 56
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_starts() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 65
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"]
  fu = Minitest.filter_backtrace bt
  assert_equal ex, fu
end
test_infectious_binary_encoding() click to toggle source

def test_default_runner_is_minitest_unit

assert_instance_of Minitest::Unit, Minitest::Unit.runner

end

# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 82
  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
      EF

      Finished in 0.00

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

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

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

    assert_report expected
  end
test_omg() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 117
def test_omg; assert true; end
test_passed_eh_teardown_flunked() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 142
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_good() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 114
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_skipped() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 128
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
test_this_is_non_ascii_failure_message() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 88
def test_this_is_non_ascii_failure_message
  fail 'ЁЁЁ'.force_encoding('ASCII-8BIT')
end
test_this_is_not_ascii_assertion() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 84
def test_this_is_not_ascii_assertion
  assert_equal "ЁЁЁ", "ёёё"
end
util_expand_bt(bt) click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_test.rb, line 156
def util_expand_bt bt
  if RUBY_VERSION >= "1.9.0" then
    bt.map { |f| (f =~ /^\./) ? File.expand_path(f) : f }
  else
    bt
  end
end