diff options
| author | Stan Lo <stan001212@gmail.com> | 2024-11-18 10:32:25 +0000 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-11-18 10:32:31 +0000 |
| commit | ee0915feeb1afdc448af610f2d470945a991a118 (patch) | |
| tree | b06917631776ab3ae67eed5723105413af1d0e8b /test | |
| parent | 7b8db102be6b33db7f38c87ae6aca7be56c62b84 (diff) | |
[ruby/rdoc] Extract excerpt from raw pages correctly
(https://github.com/ruby/rdoc/pull/1200)
Fixes https://bugs.ruby-lang.org/issues/20862
https://github.com/ruby/rdoc/commit/3c678249e2
Diffstat (limited to 'test')
| -rw-r--r-- | test/rdoc/test_rdoc_generator_darkfish.rb | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index f6c0a1e1cf..0a9be7e4ee 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require_relative 'helper' -class TestRDocGeneratorDarkfish < RDoc::TestCase +class RDocGeneratorDarkfishTest < RDoc::TestCase def setup super @@ -348,7 +348,7 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase ) end - def test_meta_tags_for_pages + def test_meta_tags_for_rdoc_files top_level = @store.add_file("CONTRIBUTING.rdoc", parser: RDoc::Parser::Simple) top_level.comment = <<~RDOC = Contributing @@ -367,6 +367,52 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase ) end + def test_meta_tags_for_markdown_files + top_level = @store.add_file("MyPage.md", parser: RDoc::Parser::Markdown) + top_level.comment = <<~MARKDOWN + # MyPage + + This is a comment + MARKDOWN + + @g.generate + + content = File.binread("MyPage_md.html") + assert_include(content, '<meta name="keywords" content="ruby,documentation,MyPage">') + assert_include( + content, + '<meta name="description" content="MyPage: # MyPage This is a comment">', + ) + end + + def test_meta_tags_for_raw_pages + top_level = @store.add_file("MyPage", parser: RDoc::Parser::Simple) + top_level.comment = RDoc::Markup::Document.new(RDoc::Markup::Paragraph.new('this is a comment')) + + @g.generate + + content = File.binread("MyPage.html") + assert_include(content, '<meta name="keywords" content="ruby,documentation,MyPage">') + assert_include( + content, + '<meta name="description" content="MyPage: this is a comment ">', + ) + end + + def test_meta_tags_for_empty_document + top_level = @store.add_file("MyPage", parser: RDoc::Parser::Simple) + top_level.comment = RDoc::Markup::Document.new + + @g.generate + + content = File.binread("MyPage.html") + assert_include(content, '<meta name="keywords" content="ruby,documentation,MyPage">') + assert_include( + content, + '<meta name="description" content="MyPage: ">', + ) + end + ## # Asserts that +filename+ has a link count greater than 1 if hard links to # @tmpdir are supported. |
