summaryrefslogtreecommitdiff
path: root/test/rdoc
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-11 07:44:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-11 07:44:56 +0000
commitb65b75bf2ce955dc8f5fb589732927acc8b72c29 (patch)
tree0e33d09bc3aeeef5c35dbf6fc404d7ab4658b9e8 /test/rdoc
parentd5ba73e0d9fd2fb9d1c787247c8755fa8ccc8404 (diff)
* lib/rdoc/options.rb: Added --page-dir option for moving pages in
doc/ to the top-level. * lib/rdoc/rdoc.rb: ditto. * test/rdoc/test_rdoc_options.rb: Test for the above. * test/rdoc/test_rdoc_rdoc.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rdoc')
-rw-r--r--test/rdoc/test_rdoc_options.rb38
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb19
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