class TestMeta
Public Instance Methods
test_bug_dsl_expectations()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 847 def test_bug_dsl_expectations spec_class = Class.new MiniSpecB do it "should work" do _(0).must_equal 0 end end test_name = spec_class.instance_methods.sort.grep(/test/).first spec = spec_class.new test_name result = spec.run assert spec.passed? assert result.passed? assert_equal 1, result.assertions end
test_describe_first_structure()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 938 def test_describe_first_structure x1 = x2 = y = z = nil x = describe "top-level thingy" do y = describe "first thingy" do end x1 = it "top level it" do end x2 = it "не латинские &いった α, β, γ, δ, ε hello!!! world" do end z = describe "second thingy" do end end test_methods = ["test_0001_top level it", "test_0002_не латинские &いった α, β, γ, δ, ε hello!!! world", ].sort assert_equal test_methods, [x1, x2] assert_equal test_methods, x.instance_methods.grep(/^test/).map(&:to_s).sort assert_equal [], y.instance_methods.grep(/^test/) assert_equal [], z.instance_methods.grep(/^test/) end
test_name()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 865 def test_name spec_a = describe ExampleA do; end spec_b = describe ExampleB, :random_method do; end spec_c = describe ExampleB, :random_method, :addl_context do; end assert_equal "ExampleA", spec_a.name assert_equal "ExampleB::random_method", spec_b.name assert_equal "ExampleB::random_method::addl_context", spec_c.name end
test_name2()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 875 def test_name2 assert_equal "NamedExampleA", NamedExampleA.name assert_equal "NamedExampleB", NamedExampleB.name assert_equal "NamedExampleC", NamedExampleC.name spec_a = describe ExampleA do; end spec_b = describe ExampleB, :random_method do; end assert_equal "ExampleA", spec_a.name assert_equal "ExampleB::random_method", spec_b.name end
test_register_spec_type()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 811 def test_register_spec_type original_types = Minitest::Spec::TYPES.dup assert_includes Minitest::Spec::TYPES, [//, Minitest::Spec] Minitest::Spec.register_spec_type(/woot/, TestMeta) p = lambda do |_| true end Minitest::Spec.register_spec_type TestMeta, &p keys = Minitest::Spec::TYPES.map(&:first) assert_includes keys, /woot/ assert_includes keys, p ensure Minitest::Spec::TYPES.replace original_types end
test_setup_teardown_behavior()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 926 def test_setup_teardown_behavior _, _, z, before_list, after_list = util_structure @tu = z run_tu_with_fresh_reporter size = z.runnable_methods.size assert_equal [1, 2, 3] * size, before_list assert_equal [3, 2, 1] * size, after_list end
test_spec_type()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 829 def test_spec_type original_types = Minitest::Spec::TYPES.dup Minitest::Spec.register_spec_type(/A$/, MiniSpecA) Minitest::Spec.register_spec_type MiniSpecB do |desc| desc.superclass == ExampleA end Minitest::Spec.register_spec_type MiniSpecC do |_desc, *addl| addl.include? :woot end assert_equal MiniSpecA, Minitest::Spec.spec_type(ExampleA) assert_equal MiniSpecB, Minitest::Spec.spec_type(ExampleB) assert_equal MiniSpecC, Minitest::Spec.spec_type(ExampleB, :woot) ensure Minitest::Spec::TYPES.replace original_types end
test_structure()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 887 def test_structure x, y, z, * = util_structure assert_equal "top-level thingy", x.to_s assert_equal "top-level thingy::inner thingy", y.to_s assert_equal "top-level thingy::inner thingy::very inner thingy", z.to_s assert_equal "top-level thingy", x.desc assert_equal "inner thingy", y.desc assert_equal "very inner thingy", z.desc top_methods = %w[setup teardown test_0001_top-level-it] inner_methods1 = %w[setup teardown test_0001_inner-it] inner_methods2 = inner_methods1 + %w[test_0002_anonymous test_0003_anonymous] assert_equal top_methods, x.instance_methods(false).sort.map(&:to_s) assert_equal inner_methods1, y.instance_methods(false).sort.map(&:to_s) assert_equal inner_methods2, z.instance_methods(false).sort.map(&:to_s) end
test_structure_postfix_it()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 908 def test_structure_postfix_it z = nil y = describe "outer" do # NOT here, below the inner-describe! # it "inner-it" do end z = describe "inner" do it "inner-it" do end end # defined AFTER inner describe means we'll try to wipe out the inner-it it "inner-it" do end end assert_equal %w[test_0001_inner-it], y.instance_methods(false).map(&:to_s) assert_equal %w[test_0001_inner-it], z.instance_methods(false).map(&:to_s) end
test_structure_subclasses()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 959 def test_structure_subclasses z = nil x = Class.new Minitest::Spec do def xyz; end end y = Class.new x do z = describe("inner") { } end assert_respond_to x.new(nil), "xyz" assert_respond_to y.new(nil), "xyz" assert_respond_to z.new(nil), "xyz" end
util_structure()
click to toggle source
do not call parallelize_me! here because specs use register_spec_type globally
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 782 def util_structure y = z = nil before_list = [] after_list = [] x = describe "top-level thingy" do before { before_list << 1 } after { after_list << 1 } it "top-level-it" do end y = describe "inner thingy" do before { before_list << 2 } after { after_list << 2 } it "inner-it" do end z = describe "very inner thingy" do before { before_list << 3 } after { after_list << 3 } it "inner-it" do end it { } # ignore me specify { } # anonymous it end end end return x, y, z, before_list, after_list end
xyz()
click to toggle source
# File minitest-5.13.0/test/minitest/test_minitest_spec.rb, line 962 def xyz; end