Sha256: ef01851c20498836a8ce876bdc0df96b6cf498c779b1f9ca3a0fb90bee22f981

Contents?: true

Size: 1.78 KB

Versions: 11

Compression:

Stored size: 1.78 KB

Contents

require 'rdoc/test_case'

class TestRDocGeneratorRI < RDoc::TestCase

  def setup
    super

    @options = RDoc::Options.new
    if Object.const_defined? :Encoding then
      @options.encoding = Encoding::UTF_8
      @store.encoding = Encoding::UTF_8
    end

    @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 = Object.const_defined?(:Encoding) ? Encoding::UTF_8 : nil

    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

Version data entries

11 entries across 9 versions & 2 rubygems

Version Path
rdoc-4.3.0 test/test_rdoc_generator_ri.rb
rdoc-4.2.2 test/test_rdoc_generator_ri.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/rdoc-4.1.1/test/test_rdoc_generator_ri.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/rdoc-4.1.1/test/test_rdoc_generator_ri.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/rdoc-4.1.1/test/test_rdoc_generator_ri.rb
rdoc-4.2.1 test/test_rdoc_generator_ri.rb
rdoc-4.2.0 test/test_rdoc_generator_ri.rb
rdoc-4.1.2 test/test_rdoc_generator_ri.rb
rdoc-4.1.1 test/test_rdoc_generator_ri.rb
rdoc-4.1.0 test/test_rdoc_generator_ri.rb
rdoc-4.1.0.preview.3 test/test_rdoc_generator_ri.rb