summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 05:16:56 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 05:16:56 +0000
commit8adec52962b261ade1ec1d538d93ebeea69db5b2 (patch)
tree5be48a871519733101cadc1bf67d7b1d2a1fb94a /test
parent1dfe3d93fa5d9ddabae8db067c5705ea6e551442 (diff)
* lib/rdoc/rubygems_hook.rb: Fixed generation of documentation.
Disabled rdoc generation by default to match RubyGems defaults. Reduced diff with RubyGems::RDoc. * test/rdoc/test_rdoc_rubygems_hook.rb: Tests for the above. * test/rubygems/test_gem_rdoc.rb: ditto. * lib/rdoc/store.rb: Removed useless variable assignment git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/rdoc/test_rdoc_rubygems_hook.rb67
-rw-r--r--test/rubygems/test_gem_rdoc.rb2
2 files changed, 50 insertions, 19 deletions
diff --git a/test/rdoc/test_rdoc_rubygems_hook.rb b/test/rdoc/test_rdoc_rubygems_hook.rb
index beba030c94..da9c3edd9f 100644
--- a/test/rdoc/test_rdoc_rubygems_hook.rb
+++ b/test/rdoc/test_rdoc_rubygems_hook.rb
@@ -10,7 +10,15 @@ class TestRDocRubygemsHook < Gem::TestCase
skip 'requires RubyGems 1.9+' unless
Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.9')
- @a = quick_spec 'a'
+ @a = quick_spec 'a' do |s|
+ s.rdoc_options = %w[--main MyTitle]
+ s.extra_rdoc_files = %w[README]
+ end
+
+ write_file File.join(@tempdir, 'lib', 'a.rb')
+ write_file File.join(@tempdir, 'README')
+
+ install_gem @a
@hook = RDoc::RubygemsHook.new @a
@@ -24,7 +32,7 @@ class TestRDocRubygemsHook < Gem::TestCase
end
def test_initialize
- assert @hook.generate_rdoc
+ refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = RDoc::RubygemsHook.new @a, false, false
@@ -66,12 +74,37 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
+ refute @hook.rdoc_installed?
+ assert @hook.ri_installed?
+
+ rdoc = @hook.instance_variable_get :@rdoc
+
+ refute rdoc.options.hyperlink_all
+ assert_equal Pathname(@a.full_gem_path), rdoc.options.root
+ assert_equal %w[README lib], rdoc.options.files.sort
+
+ assert_equal 'MyTitle', rdoc.store.main
+ end
+
+ def test_generate_all
+ @hook.generate_rdoc = true
+ @hook.generate_ri = true
+
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
+
+ @hook.generate
+
assert @hook.rdoc_installed?
assert @hook.ri_installed?
rdoc = @hook.instance_variable_get :@rdoc
refute rdoc.options.hyperlink_all
+ assert_equal Pathname(@a.full_gem_path), rdoc.options.root
+ assert_equal %w[README lib], rdoc.options.files.sort
+
+ assert_equal 'MyTitle', rdoc.store.main
end
def test_generate_configuration_rdoc_array
@@ -133,7 +166,7 @@ class TestRDocRubygemsHook < Gem::TestCase
@hook.generate
- assert_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
+ refute_path_exists File.join(@a.doc_dir('rdoc'), 'index.html')
assert_path_exists File.join(@a.doc_dir('ri'), 'cache.ri')
end
@@ -183,7 +216,7 @@ class TestRDocRubygemsHook < Gem::TestCase
assert_equal @a.base_dir, e.directory
ensure
- FileUtils.chmod 0755, @a.base_dir
+ FileUtils.chmod(0755, @a.base_dir) if File.directory?(@a.base_dir)
end
def test_ri_installed?
@@ -202,20 +235,18 @@ class TestRDocRubygemsHook < Gem::TestCase
def test_setup_unwritable
skip 'chmod not supported' if Gem.win_platform?
- begin
- FileUtils.mkdir_p @a.doc_dir
- FileUtils.chmod 0, @a.doc_dir
-
- e = assert_raises Gem::FilePermissionError do
- @hook.setup
- end
-
- assert_equal @a.doc_dir, e.directory
- ensure
- if File.exist? @a.doc_dir
- FileUtils.chmod 0755, @a.doc_dir
- FileUtils.rm_r @a.doc_dir
- end
+ FileUtils.mkdir_p @a.doc_dir
+ FileUtils.chmod 0, @a.doc_dir
+
+ e = assert_raises Gem::FilePermissionError do
+ @hook.setup
+ end
+
+ assert_equal @a.doc_dir, e.directory
+ ensure
+ if File.exist? @a.doc_dir
+ FileUtils.chmod 0755, @a.doc_dir
+ FileUtils.rm_r @a.doc_dir
end
end
diff --git a/test/rubygems/test_gem_rdoc.rb b/test/rubygems/test_gem_rdoc.rb
index 2d279e3372..bece6a1782 100644
--- a/test/rubygems/test_gem_rdoc.rb
+++ b/test/rubygems/test_gem_rdoc.rb
@@ -43,7 +43,7 @@ class TestGemRDoc < Gem::TestCase
end
def test_initialize
- assert @hook.generate_rdoc
+ refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = Gem::RDoc.new @a, false, false