Permalink
Browse files

Reduced diff with RubyGems::RDoc

  • Loading branch information...
1 parent 3a34c2c commit 9b0b5e5ad13ae69183ff0dda7de46f53813b27de @drbrain drbrain committed Dec 14, 2012
Showing with 41 additions and 20 deletions.
  1. +5 −3 lib/rdoc/rubygems_hook.rb
  2. +36 −17 test/test_rdoc_rubygems_hook.rb
View
8 lib/rdoc/rubygems_hook.rb
@@ -68,10 +68,12 @@ def self.load_rdoc
##
# Creates a new documentation generator for +spec+. RDoc and ri data
- # generation can be disabled through +generate_rdoc+ and +generate_ri+
- # respectively.
+ # generation can be enabled or disabled through +generate_rdoc+ and
+ # +generate_ri+ respectively.
+ #
+ # Only +generate_ri+ is enabled by default.
- def initialize spec, generate_rdoc = true, generate_ri = true
+ def initialize spec, generate_rdoc = false, generate_ri = true
@doc_dir = spec.doc_dir
@force = false
@rdoc = nil
View
53 test/test_rdoc_rubygems_hook.rb
@@ -32,7 +32,7 @@ def setup
end
def test_initialize
- assert @hook.generate_rdoc
+ refute @hook.generate_rdoc
assert @hook.generate_ri
rdoc = RDoc::RubygemsHook.new @a, false, false
@@ -74,6 +74,27 @@ def test_generate
@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?
@@ -145,7 +166,7 @@ def test_generate_force
@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
@@ -195,7 +216,7 @@ def test_remove_unwritable
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?
@@ -214,20 +235,18 @@ def test_setup
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

0 comments on commit 9b0b5e5

Please sign in to comment.