require 'spec_helper' describe Aigu::IosExporter do describe :parse_strings_file do let(:exporter) { Aigu::IosExporter.new } let(:parse_strings_file) { exporter.send(:parse_strings_file, content) } let(:content) do <<-EOS.unindent "STRING_1" = "Value of string #1"; "STRING_2" = "Value of string #2"; "STRING_3" = "Value with special chars (%ld) %@\\n = abc"; "STRING_4" = "Value with an interpolation %@."; "STRING_5" = "Value with %@ interpolations %@."; "STRING_6" = "Value with an interpolation with an identifier %1$@."; "STRING_7" = "Value with %1$@ interpolations with an identifier %2$@."; EOS end let(:expected_content) do { 'STRING_1' => 'Value of string #1', 'STRING_2' => 'Value of string #2', 'STRING_3' => 'Value with special chars (%ld) %s\n = abc', 'STRING_4' => 'Value with an interpolation %s.', 'STRING_5' => 'Value with %s interpolations %s.', 'STRING_6' => 'Value with an interpolation with an identifier %1$s.', 'STRING_7' => 'Value with %1$s interpolations with an identifier %2$s.' } end it { expect(parse_strings_file).to eql expected_content } end describe :parse_stringsdict_file do let(:exporter) { Aigu::IosExporter.new } let(:parse_stringsdict_file) { exporter.send(:parse_stringsdict_file, content) } let(:content) do <<-EOS.unindent BUNDLE_1 NSStringLocalizedFormatKey %1$\#@string1@ string1 NSStringFormatSpecTypeKey NSStringPluralRuleType NSStringFormatValueTypeKey d zero %d value #1 zero one %d value #1 one other %d value #1 other string2 NSStringFormatSpecTypeKey NSStringPluralRuleType NSStringFormatValueTypeKey d zero %d value #2 & zero one %d value #2 one other %d value #2 other BUNDLE_2 NSStringLocalizedFormatKey %1$\#@string1@ string1 NSStringFormatSpecTypeKey NSStringPluralRuleType NSStringFormatValueTypeKey d zero %d value #1 zero one %d value #1 one other %d value #1 other EOS end let(:expected_content) do { '__@DICT__BUNDLE_1__@STRING__string1__@ZERO' => '%d value #1 zero', '__@DICT__BUNDLE_1__@STRING__string1__@ONE' => '%d value #1 one', '__@DICT__BUNDLE_1__@STRING__string1__@OTHER' => '%d value #1 other', '__@DICT__BUNDLE_1__@STRING__string2__@ZERO' => '%d value #2 & zero', '__@DICT__BUNDLE_1__@STRING__string2__@ONE' => '%d value #2 one', '__@DICT__BUNDLE_1__@STRING__string2__@OTHER' => '%d value #2 other', '__@DICT__BUNDLE_2__@STRING__string1__@ZERO' => '%d value #1 zero', '__@DICT__BUNDLE_2__@STRING__string1__@ONE' => '%d value #1 one', '__@DICT__BUNDLE_2__@STRING__string1__@OTHER' => '%d value #1 other' } end it { expect(parse_stringsdict_file).to eql expected_content } end end