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_generator_ri.rb
hsbt ba6ae341ba * lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0.beta2
Fixed ri parse defect with left-hand matched classes.
  https://github.com/rdoc/rdoc/pull/420

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07 22:23:38 +00:00

76 lines
1.7 KiB
Ruby

# frozen_string_literal: false
require 'rdoc/test_case'
class TestRDocGeneratorRI < RDoc::TestCase
def setup
super
@options = RDoc::Options.new
@options.encoding = Encoding::UTF_8
@store.encoding = Encoding::UTF_8
@tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_ri_#{$$}"
FileUtils.mkdir_p @tmpdir
@g = RDoc::Generator::RI.new @store, @options
@top_level = @store.add_file 'file.rb'
@klass = @top_level.add_class RDoc::NormalClass, 'Object'
@meth = RDoc::AnyMethod.new nil, 'method'
@meth.record_location @top_level
@meth_bang = RDoc::AnyMethod.new nil, 'method!'
@meth_bang.record_location @top_level
@attr = RDoc::Attr.new nil, 'attr', 'RW', ''
@attr.record_location @top_level
@klass.add_method @meth
@klass.add_method @meth_bang
@klass.add_attribute @attr
Dir.chdir @tmpdir
end
def teardown
super
Dir.chdir @pwd
FileUtils.rm_rf @tmpdir
end
def test_generate
@g.generate
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')
store = RDoc::RI::Store.new @tmpdir
store.load_cache
encoding = Encoding::UTF_8
assert_equal encoding, store.encoding
end
def test_generate_dry_run
@store.dry_run = true
@g = RDoc::Generator::RI.new @store, @options
top_level = @store.add_file 'file.rb'
top_level.add_class @klass.class, @klass.name
@g.generate
refute_file File.join(@tmpdir, 'cache.ri')
refute_file File.join(@tmpdir, 'Object')
end
end