1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/rdoc/test_rdoc_task.rb
drbrain 1c279a7d27 * lib/rdoc*: Updated to RDoc 4.0 (pre-release)
* bin/rdoc:  ditto
* test/rdoc:  ditto
* NEWS:  Updated with RDoc 4.0 information


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-27 04:28:14 +00:00

120 lines
2.7 KiB
Ruby

require 'rdoc/test_case'
require 'rake'
class TestRDocTask < RDoc::TestCase
def setup
super
Rake::Task.clear
@t = RDoc::Task.new
end
def test_clobber_task_description
assert_equal 'Remove RDoc HTML files', @t.clobber_task_description
end
def test_inline_source
_, err = capture_io do
assert @t.inline_source
end
assert_equal "RDoc::Task#inline_source is deprecated\n", err
_, err = capture_io do
@t.inline_source = false
end
assert_equal "RDoc::Task#inline_source is deprecated\n", err
capture_io do
assert @t.inline_source
end
end
def test_markup_option
rdoc_task = RDoc::Task.new do |rd|
rd.markup = "tomdoc"
end
assert_equal %w[-o html --markup tomdoc], rdoc_task.option_list
end
def test_tasks_creation
RDoc::Task.new
assert Rake::Task[:rdoc]
assert Rake::Task[:clobber_rdoc]
assert Rake::Task[:rerdoc]
end
def test_tasks_creation_with_custom_name_symbol
rd = RDoc::Task.new(:rdoc_dev)
assert Rake::Task[:rdoc_dev]
assert Rake::Task[:clobber_rdoc_dev]
assert Rake::Task[:rerdoc_dev]
assert_equal :rdoc_dev, rd.name
end
def test_generator_option
rdoc_task = RDoc::Task.new do |rd|
rd.generator = "ri"
end
assert_equal %w[-o html -f ri], rdoc_task.option_list
end
def test_rdoc_task_description
assert_equal 'Build RDoc HTML files', @t.rdoc_task_description
end
def test_rerdoc_task_description
assert_equal 'Rebuild RDoc HTML files', @t.rerdoc_task_description
end
def test_tasks_creation_with_custom_name_string
rd = RDoc::Task.new("rdoc_dev")
assert Rake::Task[:rdoc_dev]
assert Rake::Task[:clobber_rdoc_dev]
assert Rake::Task[:rerdoc_dev]
assert_equal "rdoc_dev", rd.name
end
def test_tasks_creation_with_custom_name_hash
options = {
:rdoc => "rdoc",
:clobber_rdoc => "rdoc:clean",
:rerdoc => "rdoc:force"
}
Rake::Task.clear
rd = RDoc::Task.new(options)
assert Rake::Task[:"rdoc"]
assert Rake::Task[:"rdoc:clean"]
assert Rake::Task[:"rdoc:force"]
assert_raises(RuntimeError) { Rake::Task[:clobber_rdoc] }
assert_equal options, rd.name
end
def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
RDoc::Task.new(:clobber_rdoc => "rdoc:clean")
assert Rake::Task[:rdoc]
assert Rake::Task[:"rdoc:clean"]
assert Rake::Task[:rerdoc]
end
def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
assert_raises(ArgumentError) do
RDoc::Task.new(:foo => "bar")
end
begin
RDoc::Task.new(:foo => "bar")
rescue ArgumentError => e
assert_match(/foo/, e.message)
end
end
end