From 76c7388c1f41fb0ae3dacda0d9c02e7562a6655d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 18 Aug 2021 13:48:12 +0900 Subject: [ruby/rdoc] Add tests for `--template-stylesheets` option Also flattens `@options.template_stylesheets` when parsing the command lines. Fixes #205 Fixes #828 too https://github.com/ruby/rdoc/commit/857002a763 --- test/rdoc/test_rdoc_generator_darkfish.rb | 14 ++++++++++++++ test/rdoc/test_rdoc_options.rb | 15 +++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'test/rdoc') diff --git a/test/rdoc/test_rdoc_generator_darkfish.rb b/test/rdoc/test_rdoc_generator_darkfish.rb index f5858bce6e..3de4f8b6d6 100644 --- a/test/rdoc/test_rdoc_generator_darkfish.rb +++ b/test/rdoc/test_rdoc_generator_darkfish.rb @@ -220,6 +220,20 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase assert_includes method_name, '{ |%<<script>alert("atui")</script>>, yield_arg| ... }' end + def test_template_stylesheets + css = Tempfile.create(%W'hoge .css', Dir.mktmpdir('tmp', '.')) + File.write(css, '') + base = File.basename(css) + refute_file(base) + + @options.template_stylesheets << css + + @g.generate + + assert_file base + assert_include File.read('index.html'), %Q[href="./#{base}"] + end + ## # Asserts that +filename+ has a link count greater than 1 if hard links to # @tmpdir are supported. diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 206ddeeb2c..7c264c5e86 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -632,6 +632,21 @@ rdoc_include: $LOAD_PATH.replace orig_LOAD_PATH end + def test_parse_template_stylesheets + css = nil + Dir.mktmpdir do |dir| + css = File.join(dir, "hoge.css") + File.write(css, "") + out, err = capture_output do + @options.parse %W[--template-stylesheets #{css}] + end + + assert_empty out + assert_empty err + end + assert_include @options.template_stylesheets, css + end + def test_parse_visibility @options.parse %w[--visibility=public] assert_equal :public, @options.visibility -- cgit v1.2.3