[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / test / rdoc / test_rdoc_generator_pot.rb
blobbafe9ecca56f9f8495860d4f01cfbdf0af8763c8
1 # frozen_string_literal: true
2 require_relative 'helper'
4 class TestRDocGeneratorPOT < RDoc::TestCase
6   def setup
7     super
9     @options = RDoc::Options.new
10     @tmpdir = File.join Dir.tmpdir, "test_rdoc_generator_pot_#{$$}"
11     FileUtils.mkdir_p @tmpdir
13     @generator = RDoc::Generator::POT.new @store, @options
15     @top_level = @store.add_file 'file.rb'
16     @klass = @top_level.add_class RDoc::NormalClass, 'Object'
17     @klass.add_comment 'This is a class', @top_level
18     @klass.add_section 'This is a section', comment('This is a section comment')
20     @const = RDoc::Constant.new "CONSTANT", "29", "This is a constant"
22     @meth = RDoc::AnyMethod.new nil, 'method'
23     @meth.record_location @top_level
24     @meth.comment = 'This is a method'
26     @attr = RDoc::Attr.new nil, 'attr', 'RW', ''
27     @attr.record_location @top_level
28     @attr.comment = 'This is an attribute'
30     @klass.add_constant @const
31     @klass.add_method @meth
32     @klass.add_attribute @attr
34     Dir.chdir @tmpdir
35   end
37   def teardown
38     super
40     Dir.chdir @pwd
41     FileUtils.rm_rf @tmpdir
42   end
44   def test_generate
45     @generator.generate
47     assert_equal <<-POT, File.read(File.join(@tmpdir, 'rdoc.pot'))
48 # SOME DESCRIPTIVE TITLE.
49 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
50 # This file is distributed under the same license as the PACKAGE package.
51 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
52 #, fuzzy
53 msgid ""
54 msgstr ""
55 "Project-Id-Version: PACKAGE VERSEION\\n"
56 "Report-Msgid-Bugs-To:\\n"
57 "PO-Revision-Date: YEAR-MO_DA HO:MI+ZONE\\n"
58 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
59 "Language-Team: LANGUAGE <LL@li.org>\\n"
60 "Language:\\n"
61 "MIME-Version: 1.0\\n"
62 "Content-Type: text/plain; charset=CHARSET\\n"
63 "Content-Transfer-Encoding: 8bit\\n"
64 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
66 #. Object
67 msgid "This is a class"
68 msgstr ""
70 #. Object::CONSTANT
71 msgid "This is a constant"
72 msgstr ""
74 #. Object#method
75 msgid "This is a method"
76 msgstr ""
78 #. Object: section title
79 msgid "This is a section"
80 msgstr ""
82 #. Object: This is a section
83 msgid "This is a section comment"
84 msgstr ""
86 #. Object#attr
87 msgid "This is an attribute"
88 msgstr ""
89     POT
90   end
92 end