Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/twine.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_formatters.rb')
-rw-r--r--test/test_formatters.rb58
1 files changed, 29 insertions, 29 deletions
diff --git a/test/test_formatters.rb b/test/test_formatters.rb
index dd363c6..574cbec 100644
--- a/test/test_formatters.rb
+++ b/test/test_formatters.rb
@@ -6,33 +6,33 @@ class FormatterTest < TwineTestCase
@twine_file = build_twine_file 'en' do
add_section 'Section 1' do
- add_row key1: 'value1-english', comment: 'comment key1'
- add_row key2: 'value2-english'
+ add_definition key1: 'value1-english', comment: 'comment key1'
+ add_definition key2: 'value2-english'
end
add_section 'Section 2' do
- add_row key3: 'value3-english'
- add_row key4: 'value4-english', comment: 'comment key4'
+ add_definition key3: 'value3-english'
+ add_definition key4: 'value4-english', comment: 'comment key4'
end
end
- @strings = Twine::StringsFile.new
+ @empty_twine_file = Twine::TwineFile.new
@formatter = formatter_class.new
- @formatter.strings = @strings
+ @formatter.twine_file = @empty_twine_file
@formatter.options = { consume_all: true, consume_comments: true }
end
def assert_translations_read_correctly
1.upto(4) do |i|
- assert_equal "value#{i}-english", @strings.strings_map["key#{i}"].translations['en']
+ assert_equal "value#{i}-english", @empty_twine_file.definitions_by_key["key#{i}"].translations['en']
end
end
def assert_file_contents_read_correctly
assert_translations_read_correctly
- assert_equal "comment key1", @strings.strings_map["key1"].comment
- assert_equal "comment key4", @strings.strings_map["key4"].comment
+ assert_equal "comment key1", @empty_twine_file.definitions_by_key["key1"].comment
+ assert_equal "comment key4", @empty_twine_file.definitions_by_key["key4"].comment
end
end
@@ -49,27 +49,27 @@ class TestAndroidFormatter < FormatterTest
def test_set_translation_converts_leading_spaces
@formatter.set_translation_for_key 'key1', 'en', "\u0020value"
- assert_equal ' value', @strings.strings_map['key1'].translations['en']
+ assert_equal ' value', @empty_twine_file.definitions_by_key['key1'].translations['en']
end
def test_set_translation_coverts_trailing_spaces
@formatter.set_translation_for_key 'key1', 'en', "value\u0020\u0020"
- assert_equal 'value ', @strings.strings_map['key1'].translations['en']
+ assert_equal 'value ', @empty_twine_file.definitions_by_key['key1'].translations['en']
end
def test_set_translation_converts_string_placeholders
@formatter.set_translation_for_key 'key1', 'en', "value %s"
- assert_equal 'value %@', @strings.strings_map['key1'].translations['en']
+ assert_equal 'value %@', @empty_twine_file.definitions_by_key['key1'].translations['en']
end
def test_set_translation_unescapes_at_signs
@formatter.set_translation_for_key 'key1', 'en', '\@value'
- assert_equal '@value', @strings.strings_map['key1'].translations['en']
+ assert_equal '@value', @empty_twine_file.definitions_by_key['key1'].translations['en']
end
def test_format_file
formatter = Twine::Formatters::Android.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_android.xml'), formatter.format_file('en')
end
@@ -139,47 +139,47 @@ class TestAppleFormatter < FormatterTest
def test_reads_quoted_keys
@formatter.read StringIO.new('"key" = "value"'), 'en'
- assert_equal 'value', @strings.strings_map['key'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['key'].translations['en']
end
def test_reads_unquoted_keys
@formatter.read StringIO.new('key = "value"'), 'en'
- assert_equal 'value', @strings.strings_map['key'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['key'].translations['en']
end
def test_ignores_leading_whitespace_before_quoted_keys
@formatter.read StringIO.new("\t \"key\" = \"value\""), 'en'
- assert_equal 'value', @strings.strings_map['key'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['key'].translations['en']
end
def test_ignores_leading_whitespace_before_unquoted_keys
@formatter.read StringIO.new("\t key = \"value\""), 'en'
- assert_equal 'value', @strings.strings_map['key'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['key'].translations['en']
end
def test_allows_quotes_in_quoted_keys
@formatter.read StringIO.new('"ke\"y" = "value"'), 'en'
- assert_equal 'value', @strings.strings_map['ke"y'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['ke"y'].translations['en']
end
def test_does_not_allow_quotes_in_quoted_keys
@formatter.read StringIO.new('ke"y = "value"'), 'en'
- assert_nil @strings.strings_map['key']
+ assert_nil @empty_twine_file.definitions_by_key['key']
end
def test_allows_equal_signs_in_quoted_keys
@formatter.read StringIO.new('"k=ey" = "value"'), 'en'
- assert_equal 'value', @strings.strings_map['k=ey'].translations['en']
+ assert_equal 'value', @empty_twine_file.definitions_by_key['k=ey'].translations['en']
end
def test_does_not_allow_equal_signs_in_unquoted_keys
@formatter.read StringIO.new('k=ey = "value"'), 'en'
- assert_nil @strings.strings_map['key']
+ assert_nil @empty_twine_file.definitions_by_key['key']
end
def test_format_file
formatter = Twine::Formatters::Apple.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_apple.strings'), formatter.format_file('en')
end
@@ -210,7 +210,7 @@ class TestJQueryFormatter < FormatterTest
def test_format_file
formatter = Twine::Formatters::JQuery.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_jquery.json'), formatter.format_file('en')
end
@@ -234,12 +234,12 @@ class TestGettextFormatter < FormatterTest
def test_read_with_multiple_line_value
@formatter.read content_io('gettext_multiline.po'), 'en'
- assert_equal 'multiline\nstring', @strings.strings_map['key1'].translations['en']
+ assert_equal 'multiline\nstring', @empty_twine_file.definitions_by_key['key1'].translations['en']
end
def test_format_file
formatter = Twine::Formatters::Gettext.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_gettext.po'), formatter.format_file('en')
end
@@ -260,7 +260,7 @@ class TestTizenFormatter < FormatterTest
def test_format_file
formatter = Twine::Formatters::Tizen.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_tizen.xml'), formatter.format_file('en')
end
@@ -279,7 +279,7 @@ class TestDjangoFormatter < FormatterTest
def test_format_file
formatter = Twine::Formatters::Django.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_django.po'), formatter.format_file('en')
end
end
@@ -297,7 +297,7 @@ class TestFlashFormatter < FormatterTest
def test_format_file
formatter = Twine::Formatters::Flash.new
- formatter.strings = @twine_file
+ formatter.twine_file = @twine_file
assert_equal content('formatter_flash.properties'), formatter.format_file('en')
end
end