Skip to content

Commit

Permalink
Add test coverage for private mixed-in attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Oct 17, 2024
1 parent 634a4dc commit b0f6801
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/rdoc/test_rdoc_class_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,9 @@ def setup
incmod_private_method = @incmod.add_method(RDoc::AnyMethod.new(nil, "incmod_private_method"))
incmod_private_method.visibility = :private

incmod_private_attr = @incmod.add_attribute(RDoc::Attr.new(nil, "incmod_private_attr", "RW", ""))
incmod_private_attr.visibility = :private

extmod_tl = @store.add_file("extmod.rb")
@extmod = extmod_tl.add_module(RDoc::NormalModule, "Extmod")

Expand All @@ -1539,6 +1542,9 @@ def setup
extmod_private_method = @extmod.add_method(RDoc::AnyMethod.new(nil, "extmod_private_method"))
extmod_private_method.visibility = :private

extmod_private_attr = @extmod.add_attribute(RDoc::Attr.new(nil, "extmod_private_attr", "RW", "", true))
extmod_private_attr.visibility = :private

@klass.add_include(RDoc::Include.new("Incmod", nil))
@klass.add_extend(RDoc::Include.new("Extmod", nil))

Expand Down Expand Up @@ -1577,6 +1583,7 @@ def test_embed_mixin_when_true_embeds_methods_and_constants
assert_equal(@incmod, instance_attr.mixin_from)

refute(@klass.method_list.find { |m| m.name == "incmod_private_method" })
refute(@klass.attributes.find { |m| m.name == "incmod_private_attr" })

class_method = @klass.method_list.find { |m| m.name == "extmod_method" }
assert(class_method, "class method from extended mixin should be present")
Expand All @@ -1589,6 +1596,7 @@ def test_embed_mixin_when_true_embeds_methods_and_constants
assert_equal(@extmod, class_attr.mixin_from)

refute(@klass.method_list.find { |m| m.name == "extmod_private_method" })
refute(@klass.attributes.find { |m| m.name == "extmod_private_attr" })

# assert that sections are also imported
constant_section = @klass.sections.find { |s| s.title == "Incmod const section" }
Expand Down

0 comments on commit b0f6801

Please sign in to comment.