2017-11-27 13:45:24 +03:00
|
|
|
# frozen_string_literal: true
|
2019-08-08 17:09:24 +03:00
|
|
|
require_relative 'helper'
|
2015-04-09 09:01:27 +03:00
|
|
|
begin
|
|
|
|
require 'rake'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2010-04-01 11:45:16 +04:00
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
class TestRDocTask < RDoc::TestCase
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def setup
|
2012-11-27 08:28:14 +04:00
|
|
|
super
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
Rake::Task.clear
|
2011-02-02 03:32:30 +03:00
|
|
|
|
|
|
|
@t = RDoc::Task.new
|
2010-04-01 11:45:16 +04:00
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_clobber_task_description
|
|
|
|
assert_equal 'Remove RDoc HTML files', @t.clobber_task_description
|
|
|
|
end
|
2010-12-29 01:08:56 +03:00
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
def test_inline_source
|
2019-08-11 00:12:46 +03:00
|
|
|
_, err = verbose_capture_output do
|
2011-02-02 03:32:30 +03:00
|
|
|
assert @t.inline_source
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal "RDoc::Task#inline_source is deprecated\n", err
|
|
|
|
|
2019-08-11 00:12:46 +03:00
|
|
|
_, err = verbose_capture_output do
|
2011-02-02 03:32:30 +03:00
|
|
|
@t.inline_source = false
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal "RDoc::Task#inline_source is deprecated\n", err
|
|
|
|
|
2019-08-11 00:12:46 +03:00
|
|
|
capture_output do
|
2011-02-02 03:32:30 +03:00
|
|
|
assert @t.inline_source
|
2010-12-29 01:08:56 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-27 08:28:14 +04:00
|
|
|
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
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def test_tasks_creation
|
|
|
|
RDoc::Task.new
|
|
|
|
assert Rake::Task[:rdoc]
|
|
|
|
assert Rake::Task[:clobber_rdoc]
|
|
|
|
assert Rake::Task[:rerdoc]
|
2014-09-05 05:41:25 +04:00
|
|
|
assert_equal ["html/created.rid"], Rake::Task[:rdoc].prerequisites
|
2010-04-01 11:45:16 +04:00
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
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
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2014-09-05 05:41:25 +04:00
|
|
|
def test_tasks_option_parser
|
|
|
|
rdoc_task = RDoc::Task.new do |rd|
|
|
|
|
rd.title = "Test Tasks Option Parser"
|
|
|
|
rd.main = "README.md"
|
|
|
|
rd.rdoc_files.include("README.md")
|
|
|
|
rd.options << "--all"
|
|
|
|
end
|
|
|
|
|
2021-06-30 05:29:59 +03:00
|
|
|
assert_equal "Test Tasks Option Parser", rdoc_task.title
|
|
|
|
assert_equal "README.md", rdoc_task.main
|
2014-09-05 05:41:25 +04:00
|
|
|
assert rdoc_task.rdoc_files.include?("README.md")
|
|
|
|
assert rdoc_task.options.include?("--all")
|
|
|
|
|
|
|
|
args = %w[--all -o html --main README.md] << "--title" << "Test Tasks Option Parser" << "README.md"
|
|
|
|
assert_equal args, rdoc_task.option_list + rdoc_task.rdoc_files
|
|
|
|
end
|
|
|
|
|
2010-12-29 01:08:56 +03:00
|
|
|
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
|
|
|
|
|
2014-09-05 05:41:25 +04:00
|
|
|
def test_main_option
|
|
|
|
rdoc_task = RDoc::Task.new do |rd|
|
|
|
|
rd.main = "README.md"
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal %w[-o html --main README.md], rdoc_task.option_list
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_output_dir_option
|
|
|
|
rdoc_task = RDoc::Task.new do |rd|
|
|
|
|
rd.rdoc_dir = "zomg"
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal %w[-o zomg], rdoc_task.option_list
|
|
|
|
end
|
|
|
|
|
2011-02-02 03:32:30 +03:00
|
|
|
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
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
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
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def test_tasks_creation_with_custom_name_hash
|
2011-02-02 03:32:30 +03:00
|
|
|
options = {
|
|
|
|
:rdoc => "rdoc",
|
|
|
|
:clobber_rdoc => "rdoc:clean",
|
|
|
|
:rerdoc => "rdoc:force"
|
|
|
|
}
|
|
|
|
|
|
|
|
Rake::Task.clear
|
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
rd = RDoc::Task.new(options)
|
|
|
|
assert Rake::Task[:"rdoc"]
|
|
|
|
assert Rake::Task[:"rdoc:clean"]
|
|
|
|
assert Rake::Task[:"rdoc:force"]
|
2019-08-16 10:47:09 +03:00
|
|
|
assert_raise(RuntimeError) { Rake::Task[:clobber_rdoc] }
|
2010-04-01 11:45:16 +04:00
|
|
|
assert_equal options, rd.name
|
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
|
2010-12-20 06:22:49 +03:00
|
|
|
RDoc::Task.new(:clobber_rdoc => "rdoc:clean")
|
2010-04-01 11:45:16 +04:00
|
|
|
assert Rake::Task[:rdoc]
|
|
|
|
assert Rake::Task[:"rdoc:clean"]
|
|
|
|
assert Rake::Task[:rerdoc]
|
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
|
2019-08-16 10:47:09 +03:00
|
|
|
assert_raise(ArgumentError) do
|
2010-04-01 11:45:16 +04:00
|
|
|
RDoc::Task.new(:foo => "bar")
|
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2010-04-01 11:45:16 +04:00
|
|
|
begin
|
|
|
|
RDoc::Task.new(:foo => "bar")
|
|
|
|
rescue ArgumentError => e
|
|
|
|
assert_match(/foo/, e.message)
|
|
|
|
end
|
|
|
|
end
|
2010-04-02 08:40:47 +04:00
|
|
|
|
2014-09-05 05:41:25 +04:00
|
|
|
def test_template_option
|
|
|
|
rdoc_task = RDoc::Task.new do |rd|
|
|
|
|
rd.template = "foo"
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal %w[-o html -T foo], rdoc_task.option_list
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_title_option
|
|
|
|
rdoc_task = RDoc::Task.new do |rd|
|
|
|
|
rd.title = "Test Title Option"
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal %w[-o html] << "--title" << "Test Title Option", rdoc_task.option_list
|
|
|
|
end
|
|
|
|
|
2015-04-09 09:01:27 +03:00
|
|
|
end if defined?(Rake::Task)
|
2010-04-01 11:45:16 +04:00
|
|
|
|