Add tests for gettext conversion

This commit is contained in:
Kevin Everets 2013-01-15 14:40:27 -05:00
parent 0d87dc38ce
commit 8c56b59474
3 changed files with 46 additions and 0 deletions

16
test/fixtures/en-1.po vendored Normal file
View file

@ -0,0 +1,16 @@
msgid ""
msgstr ""
"Language: en\n"
"X-Generator: Twine\n"
msgctxt "key1"
msgid "key1-english"
msgstr "key1-english"
msgctxt "key3"
msgid "key3-english"
msgstr ""
msgctxt "key5"
msgid "A new string"
msgstr "A new string"

14
test/fixtures/test-output-7.txt vendored Normal file
View file

@ -0,0 +1,14 @@
msgid ""
msgstr ""
"Language: en\n"
"X-Generator: Twine <%= Twine::VERSION %>\n"
.# "This is a comment"
msgctxt "key1"
msgid "key1-english"
msgstr "key1-english"
msgctxt "key3"
msgid "key3-english"
msgstr "key3-english"

View file

@ -36,6 +36,14 @@ class TwineTest < Test::Unit::TestCase
end
end
def test_generate_string_file_5
Dir.mktmpdir do |dir|
output_path = File.join(dir, 'en.po')
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} -t tag1))
assert_equal(ERB.new(File.read('test/fixtures/test-output-7.txt')).result, File.read(output_path))
end
end
def test_consume_string_file_1
Dir.mktmpdir do |dir|
output_path = File.join(dir, 'strings.txt')
@ -60,6 +68,14 @@ class TwineTest < Test::Unit::TestCase
end
end
def test_consume_string_file_4
Dir.mktmpdir do |dir|
output_path = File.join(dir, 'strings.txt')
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-1.po -o #{output_path} -l en -a))
assert_equal(File.read('test/fixtures/test-output-4.txt'), File.read(output_path))
end
end
def test_generate_report_1
Twine::Runner.run(%w(generate-report test/fixtures/strings-1.txt))
end