|
1 | 1 | require 'spec_helper'
|
| 2 | +require 'shared_examples_for_update_metadata_source_action' |
2 | 3 |
|
3 |
| -# See also `gp_update_metadata_source_spec.rb` for the iOS counterpart and an |
4 |
| -# annotated spec. |
5 |
| -# |
6 |
| -# The fact that we have an Android and iOS differentiation is not ideal and |
7 |
| -# something we hope to address in an upcoming refactor/rewrite. |
8 | 4 | describe Fastlane::Actions::AnUpdateMetadataSourceAction do
|
9 |
| - it 'updates any block in a given .po file with the values from the given sources' do |
10 |
| - Dir.mktmpdir do |dir| |
11 |
| - output_path = File.join(dir, 'output.po') |
12 |
| - dummy_text = <<~PO |
13 |
| - msgctxt "release_note_0122" |
14 |
| - msgid "previous version notes required to have current one added" |
15 |
| - msgstr "" |
16 |
| - msgctxt "release_note_0121" |
17 |
| - msgid "this older release notes block should be removed" |
18 |
| - msgstr "" |
19 |
| - msgctxt "key1" |
20 |
| - msgid "this value should change" |
21 |
| - msgstr "" |
22 |
| - msgctxt "key2" |
23 |
| - msgid "this value should change" |
24 |
| - msgstr "" |
25 |
| - PO |
26 |
| - File.write(output_path, dummy_text) |
27 |
| - |
28 |
| - release_notes_path = File.join(dir, 'release_notes.txt') |
29 |
| - File.write(release_notes_path, "- release notes\n- more release notes") |
30 |
| - file_1_path = File.join(dir, '1.txt') |
31 |
| - File.write(file_1_path, 'value 1') |
32 |
| - file_2_path = File.join(dir, '2.txt') |
33 |
| - File.write(file_2_path, 'value 2') |
34 |
| - |
35 |
| - described_class.run( |
36 |
| - po_file_path: output_path, |
37 |
| - release_version: '1.23', |
38 |
| - source_files: { |
39 |
| - release_note: release_notes_path, |
40 |
| - key1: file_1_path, |
41 |
| - key2: file_2_path |
42 |
| - } |
43 |
| - ) |
44 |
| - |
45 |
| - expected = <<~PO |
46 |
| - msgctxt "release_note_0123" |
47 |
| - msgid "" |
48 |
| - "1.23:\\n" |
49 |
| - "- release notes\\n" |
50 |
| - "- more release notes\\n" |
51 |
| - msgstr "" |
52 |
| -
|
53 |
| - msgctxt "release_note_0122" |
54 |
| - msgid "previous version notes required to have current one added" |
55 |
| - msgstr "" |
56 |
| - msgctxt "key1" |
57 |
| - msgid "value 1" |
58 |
| - msgstr "" |
59 |
| -
|
60 |
| - msgctxt "key2" |
61 |
| - msgid "value 2" |
62 |
| - msgstr "" |
63 |
| -
|
64 |
| - PO |
65 |
| - expect(File.read(output_path)).to eq(expected) |
66 |
| - end |
67 |
| - end |
68 |
| - |
69 |
| - it 'does not ignore the `whats_new` parameter' do |
70 |
| - pending 'this currently fails; in the long run, we might consolidate whats_new with release_notes' |
71 |
| - |
72 |
| - Dir.mktmpdir do |dir| |
73 |
| - output_path = File.join(dir, 'output.po') |
74 |
| - dummy_text = <<~PO |
75 |
| - msgctxt "v1.0-whats-new" |
76 |
| - msgid "this will not change" |
77 |
| - msgstr "" |
78 |
| - PO |
79 |
| - File.write(output_path, dummy_text) |
80 |
| - |
81 |
| - whats_new_path = File.join(dir, 'whats_new.txt') |
82 |
| - File.write(whats_new_path, "- something new\n- something else new") |
83 |
| - |
84 |
| - described_class.run( |
85 |
| - po_file_path: output_path, |
86 |
| - release_version: '1.23', |
87 |
| - source_files: { |
88 |
| - whats_new: whats_new_path |
89 |
| - } |
90 |
| - ) |
91 |
| - |
92 |
| - expected = <<~PO |
93 |
| - msgctxt "v1.23-whats-new" |
94 |
| - msgid "" |
95 |
| - "- something new\\n" |
96 |
| - "- something else new\\n" |
97 |
| - msgstr "" |
98 |
| -
|
99 |
| - PO |
100 |
| - expect(File.read(output_path)).to eq(expected) |
101 |
| - end |
102 |
| - end |
103 |
| - |
104 |
| - it 'adds entries passed as input even if not part of the original `.po` file' do |
105 |
| - pending 'this currently fails and will be addressed as part of the upcoming refactor/rewrite of the functionality' |
106 |
| - Dir.mktmpdir do |dir| |
107 |
| - output_path = File.join(dir, 'output.po') |
108 |
| - dummy_text = <<~PO |
109 |
| - msgctxt "key1" |
110 |
| - msgid "this value should change" |
111 |
| - msgstr "" |
112 |
| - PO |
113 |
| - File.write(output_path, dummy_text) |
114 |
| - |
115 |
| - # 2: Create source files with value to insert in the .po |
116 |
| - file_1_path = File.join(dir, '1.txt') |
117 |
| - File.write(file_1_path, 'value 1') |
118 |
| - file_2_path = File.join(dir, '2.txt') |
119 |
| - File.write(file_2_path, 'value 2') |
120 |
| - |
121 |
| - described_class.run( |
122 |
| - po_file_path: output_path, |
123 |
| - source_files: { |
124 |
| - key1: file_1_path, |
125 |
| - key2: file_2_path |
126 |
| - } |
127 |
| - ) |
128 |
| - |
129 |
| - expected = <<~PO |
130 |
| - msgctxt "key1" |
131 |
| - msgid "value 1" |
132 |
| - msgstr "" |
133 |
| -
|
134 |
| - msgctxt "key2" |
135 |
| - msgid "value 2" |
136 |
| - msgstr "" |
137 |
| -
|
138 |
| - PO |
139 |
| - expect(File.read(output_path)).to eq(expected) |
140 |
| - end |
141 |
| - end |
| 5 | + include_examples 'update_metadata_source_action', whats_new_fails: true |
142 | 6 | end
|
0 commit comments