class TestMetaStatic

Public Instance Methods

test_children() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 726
def test_children
  Minitest::Spec.children.clear # prevents parallel run

  y = z = nil
  x = describe "top-level thingy" do
    y = describe "first thingy" do end

    it "top-level-it" do end

    z = describe "second thingy" do end
  end

  assert_equal [x], Minitest::Spec.children
  assert_equal [y, z], x.children
  assert_equal [], y.children
  assert_equal [], z.children
end
test_it_wont_add_test_methods_to_children() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 763
def test_it_wont_add_test_methods_to_children
  Minitest::Spec.children.clear # prevents parallel run

  inner = nil
  outer = describe "outer" do
    inner = describe "inner" do end
    it do
      assert true
    end
  end

  assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
  assert_equal 0, inner.public_instance_methods.grep(/^test_/).count
end
test_it_wont_remove_existing_child_test_methods() click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 744
def test_it_wont_remove_existing_child_test_methods
  Minitest::Spec.children.clear # prevents parallel run

  inner = nil
  outer = describe "outer" do
    inner = describe "inner" do
      it do
        assert true
      end
    end
    it do
      assert true
    end
  end

  assert_equal 1, outer.public_instance_methods.grep(/^test_/).count
  assert_equal 1, inner.public_instance_methods.grep(/^test_/).count
end