Skip to content

Commit 5f4f6ae

Browse files
committed
Add test for the current .po generation behavior
1 parent 8427fb8 commit 5f4f6ae

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ RSpec/FilePath:
145145
- 'spec/ios_generate_strings_file_from_code_spec.rb'
146146
- 'spec/ios_l10n_helper_spec.rb'
147147
- 'spec/ios_merge_strings_files_spec.rb'
148+
- 'spec/gp_update_metadata_source_spec.rb'
148149

149150
# Offense count: 8
150151
# Cop supports --auto-correct.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require 'spec_helper'
2+
3+
describe Fastlane::Actions::GpUpdateMetadataSourceAction do
4+
it 'works' do
5+
Dir.mktmpdir do |dir|
6+
# Reminder: you can stub Fastlane stuff with calls like
7+
# expect(FastlaneCore::UI).to receive(:success).with('Done')
8+
9+
# 1: Create tmp location for the po file
10+
#
11+
# Note, can't use StringIO.new because of implementation details:
12+
#
13+
# Failure/Error: "#{File.dirname(orig_file_path)}/#{File.basename(orig_file_path, '.*')}.tmp"
14+
output_path = File.join(dir, 'output.po')
15+
# Also note: The file must exist already
16+
dummy_text = <<~PO
17+
msgctxt "key1"
18+
msgid "this value should change"
19+
msgstr ""
20+
msgctxt "key2"
21+
msgid "this value should change"
22+
msgstr ""
23+
PO
24+
File.write(output_path, dummy_text)
25+
26+
# 2: read a few sources
27+
file_1_path = File.join(dir, '1.txt')
28+
File.write(file_1_path, 'value 1')
29+
file_2_path = File.join(dir, '2.txt')
30+
File.write(file_2_path, 'value 2')
31+
32+
described_class.run(
33+
po_file_path: output_path,
34+
release_version: '1.23',
35+
source_files: {
36+
key1: file_1_path,
37+
key2: file_2_path
38+
}
39+
)
40+
41+
# 3: compare
42+
# notice that the new line after each block is added by the conversion
43+
expected = <<~PO
44+
msgctxt "key1"
45+
msgid "value 1"
46+
msgstr ""
47+
48+
msgctxt "key2"
49+
msgid "value 2"
50+
msgstr ""
51+
52+
PO
53+
expect(File.read(output_path)).to eq(expected)
54+
end
55+
end
56+
end

0 commit comments

Comments
 (0)