2017-11-27 05:45:24 -05:00
|
|
|
# frozen_string_literal: true
|
2018-03-26 01:56:26 -04:00
|
|
|
require 'minitest_helper'
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
class TestRDocGeneratorRI < RDoc::TestCase
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
def setup
|
2012-11-26 23:28:14 -05:00
|
|
|
super
|
2010-12-19 22:22:49 -05:00
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
@options = RDoc::Options.new
|
2016-09-07 18:23:38 -04:00
|
|
|
@options.encoding = Encoding::UTF_8
|
|
|
|
@store.encoding = Encoding::UTF_8
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
|
|
|
|
FileUtils.mkdir_p @tmpdir
|
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
@g = RDoc::Generator::RI.new @store, @options
|
2010-04-01 03:45:16 -04:00
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
@top_level = @store.add_file 'file.rb'
|
2010-04-01 03:45:16 -04:00
|
|
|
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
|
2011-06-16 00:59:24 -04:00
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
@meth = RDoc::AnyMethod.new nil, 'method'
|
2011-06-16 00:59:24 -04:00
|
|
|
@meth.record_location @top_level
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
|
2011-06-16 00:59:24 -04:00
|
|
|
@meth_bang.record_location @top_level
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
|
2011-06-16 00:59:24 -04:00
|
|
|
@attr.record_location @top_level
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
@klass.add_method @meth
|
|
|
|
@klass.add_method @meth_bang
|
|
|
|
@klass.add_attribute @attr
|
2012-11-26 23:28:14 -05:00
|
|
|
|
|
|
|
Dir.chdir @tmpdir
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
2012-11-26 23:28:14 -05:00
|
|
|
super
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
Dir.chdir @pwd
|
|
|
|
FileUtils.rm_rf @tmpdir
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_generate
|
2012-11-26 23:28:14 -05:00
|
|
|
@g.generate
|
2010-04-01 03:45:16 -04:00
|
|
|
|
|
|
|
assert_file File.join(@tmpdir, 'cache.ri')
|
|
|
|
|
|
|
|
assert_file File.join(@tmpdir, 'Object', 'cdesc-Object.ri')
|
|
|
|
|
|
|
|
assert_file File.join(@tmpdir, 'Object', 'attr-i.ri')
|
|
|
|
assert_file File.join(@tmpdir, 'Object', 'method-i.ri')
|
|
|
|
assert_file File.join(@tmpdir, 'Object', 'method%21-i.ri')
|
2011-06-16 00:59:24 -04:00
|
|
|
|
|
|
|
store = RDoc::RI::Store.new @tmpdir
|
|
|
|
store.load_cache
|
|
|
|
|
2016-09-07 18:23:38 -04:00
|
|
|
encoding = Encoding::UTF_8
|
2011-06-16 00:59:24 -04:00
|
|
|
|
|
|
|
assert_equal encoding, store.encoding
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
def test_generate_dry_run
|
2012-11-26 23:28:14 -05:00
|
|
|
@store.dry_run = true
|
|
|
|
@g = RDoc::Generator::RI.new @store, @options
|
2010-12-19 22:22:49 -05:00
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
top_level = @store.add_file 'file.rb'
|
2010-12-19 22:22:49 -05:00
|
|
|
top_level.add_class @klass.class, @klass.name
|
|
|
|
|
2012-11-26 23:28:14 -05:00
|
|
|
@g.generate
|
2010-12-19 22:22:49 -05:00
|
|
|
|
|
|
|
refute_file File.join(@tmpdir, 'cache.ri')
|
|
|
|
refute_file File.join(@tmpdir, 'Object')
|
|
|
|
end
|
|
|
|
|
2010-04-01 03:45:16 -04:00
|
|
|
end
|