diff options
Diffstat (limited to 'test/rdoc')
-rw-r--r-- | test/rdoc/test_rdoc_options.rb | 38 | ||||
-rw-r--r-- | test/rdoc/test_rdoc_rdoc.rb | 19 |
2 files changed, 57 insertions, 0 deletions
diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb index 723a2dccfd..d53acf2a6c 100644 --- a/test/rdoc/test_rdoc_options.rb +++ b/test/rdoc/test_rdoc_options.rb @@ -76,6 +76,7 @@ class TestRDocOptions < RDoc::TestCase 'line_numbers' => false, 'main_page' => nil, 'markup' => 'rdoc', + 'page_dir' => nil, 'rdoc_include' => [], 'show_hash' => false, 'static_path' => [], @@ -430,6 +431,43 @@ rdoc_include: assert_equal 'tomdoc', @options.markup end + def test_parse_page_dir + assert_nil @options.page_dir + + out, err = capture_io do + @options.parse %W[--page-dir #{Dir.tmpdir}] + end + + assert_empty out + assert_empty err + + expected = + Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root + + assert_equal expected, @options.page_dir + assert_equal [Dir.tmpdir], @options.files + end + + def test_parse_page_dir_root + assert_nil @options.page_dir + + Dir.mktmpdir do |dir| + abs_root = dir + abs_page_dir = File.join dir, 'pages' + FileUtils.mkdir abs_page_dir + + out, err = capture_io do + @options.parse %W[--page-dir #{abs_page_dir} --root #{abs_root}] + end + + assert_empty out + assert_empty err + + assert_equal Pathname('pages'), @options.page_dir + assert_equal [abs_page_dir], @options.files + end + end + def test_parse_root assert_equal Pathname(Dir.pwd), @options.root diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 643f1eff77..e29363a47a 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -158,6 +158,25 @@ class TestRDocRDoc < RDoc::TestCase end end + def test_parse_file_page_dir + @rdoc.store = RDoc::Store.new + + temp_dir do |dir| + FileUtils.mkdir 'pages' + @rdoc.options.page_dir = Pathname('pages') + @rdoc.options.root = Pathname(Dir.pwd) + + open 'pages/test.txt', 'w' do |io| + io.puts 'hi' + end + + top_level = @rdoc.parse_file 'pages/test.txt' + + assert_equal 'pages/test.txt', top_level.absolute_name + assert_equal 'test.txt', top_level.relative_name + end + end + def test_parse_file_relative pwd = Dir.pwd |