Skip to content

Commit 27c7c6e

Browse files
committed
Clarify expectation on XML indentation in AnLocalizeLibsAction spec
1 parent da405f2 commit 27c7c6e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

spec/an_localize_libs_action_spec.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,28 @@
2626
]
2727
)
2828

29-
# Notice the extra indentation in the library strings. The action doesn't
30-
# modify the app's strings content indentation, but it applies its own
31-
# standard to the values read from the given library strings
3229
expected = <<~XML
3330
<string name="a_string">test from app</string>
34-
<string name="a_lib1_string">test from lib 1</string>
35-
<string name="a_lib2_string">test from lib 2</string>
31+
<string name="a_lib1_string">test from lib 1</string>
32+
<string name="a_lib2_string">test from lib 2</string>
3633
XML
3734
expect(File.read(app_strings_path)).to eq(android_xml_with_content(expected))
3835
end
3936
end
4037
end
4138

4239
def android_xml_with_content(content)
40+
# Under the hood, the code hardcodes the generated XML indentation as 4
41+
# spaces. Let's "force" it to be the same in here for consistency.
42+
#
43+
# See
44+
# https://github.com/wordpress-mobile/release-toolkit/blob/da405f2c5ca90d696857ba2ad01da2753daa60dc/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb#L67
45+
default_indentation = ' ' * 4
46+
4347
# I couldn't find a way to interpolate a multiline string preserving its
4448
# indentation in the heredoc below, so I hacked the following transformation
4549
# of the input that adds the desired indentation to all lines.
46-
indented_content = content.chomp.lines.map { |l| " #{l}" }.join
50+
indented_content = content.chomp.lines.map { |l| "#{default_indentation}#{l}" }.join
4751

4852
return <<~XML
4953
<?xml version="1.0" encoding="UTF-8"?>

0 commit comments

Comments
 (0)