diff options
author | Sebastian Ludwig <sebastian@lurado.de> | 2015-11-27 22:10:24 +0300 |
---|---|---|
committer | Sebastian Ludwig <sebastian@lurado.de> | 2015-11-29 19:04:44 +0300 |
commit | ba4b69baf2e41b495db69b6c8dbc4d138e5752f1 (patch) | |
tree | 46295c9967ef4306a59fcfe31aab72c7ab356db0 | |
parent | 8815c095d8437350f6ac4d236a1c78506a1ba42e (diff) |
Added unit tests for loc drop generation and consumption.
-rw-r--r-- | test/fixtures/consume_loc_drop.zip | bin | 0 -> 548 bytes | |||
-rw-r--r-- | test/test_consume_loc_drop.rb | 27 | ||||
-rw-r--r-- | test/test_generate_loc_drop.rb | 44 |
3 files changed, 71 insertions, 0 deletions
diff --git a/test/fixtures/consume_loc_drop.zip b/test/fixtures/consume_loc_drop.zip Binary files differnew file mode 100644 index 0000000..5efca14 --- /dev/null +++ b/test/fixtures/consume_loc_drop.zip diff --git a/test/test_consume_loc_drop.rb b/test/test_consume_loc_drop.rb new file mode 100644 index 0000000..786eca7 --- /dev/null +++ b/test/test_consume_loc_drop.rb @@ -0,0 +1,27 @@ +require 'command_test_case' + +class TestConsumeLocDrop < CommandTestCase + def setup + super + + options = {} + options[:input_path] = fixture 'consume_loc_drop.zip' + options[:output_path] = @output_path + options[:format] = 'apple' + + @twine_file = build_twine_file 'en', 'es' do + add_section 'Section' do + add_row key1: 'value1' + end + end + + @runner = Twine::Runner.new(nil, options, @twine_file) + end + + def test_consumes_zip_file + @runner.consume_loc_drop + + assert @twine_file.strings_map['key1'].translations['en'], 'value1-english' + assert @twine_file.strings_map['key1'].translations['es'], 'value1-spanish' + end +end diff --git a/test/test_generate_loc_drop.rb b/test/test_generate_loc_drop.rb new file mode 100644 index 0000000..3571323 --- /dev/null +++ b/test/test_generate_loc_drop.rb @@ -0,0 +1,44 @@ +require 'command_test_case' + +class TestGenerateLocDrop < CommandTestCase + def setup + super + + options = {} + options[:output_path] = @output_path + options[:format] = 'apple' + + @twine_file = build_twine_file 'en', 'fr' do + add_section 'Section' do + add_row key: 'value' + end + end + + @runner = Twine::Runner.new(nil, options, @twine_file) + end + + def test_generates_zip_file + @runner.generate_loc_drop + + assert File.exists?(@output_path), "language folder should not be created" + end + + def test_zip_file_structure + @runner.generate_loc_drop + + names = [] + Zip::File.open(@output_path) do |zipfile| + zipfile.each do |entry| + names << entry.name + end + end + assert_equal ['Locales/', 'Locales/en.strings', 'Locales/fr.strings'], names + end + + def test_uses_formatter + formatter = prepare_mock_formatter Twine::Formatters::Apple + formatter.expects(:write_file).twice.with() { |path, lang| FileUtils.touch path } + + @runner.generate_loc_drop + end +end |