Skip to content

Commit ff58e3d

Browse files
committed
Add more test cases for different .xcconfig file formats
1 parent e920a74 commit ff58e3d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

spec/ios_get_app_version_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@
2222
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1')
2323
end
2424

25+
it 'parses the xcconfig with keys without spacing and gets the public version' do
26+
xcconfig_mock_content = <<~CONTENT
27+
// a comment
28+
VERSION_SHORT=6
29+
VERSION_LONG=6.30.0
30+
CONTENT
31+
32+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30')
33+
end
34+
35+
it 'parses the xcconfig with keys without spacing and gets the public hotfix version' do
36+
xcconfig_mock_content = <<~CONTENT
37+
VERSION_SHORT=6
38+
// a comment
39+
VERSION_LONG=6.30.1
40+
CONTENT
41+
42+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1')
43+
end
44+
45+
it 'fails to extract the version from an xcconfig file with an invalid format' do
46+
xcconfig_mock_content = <<~CONTENT
47+
VERSION_SHORT = 6
48+
VERSION_LONG 6.30.1
49+
CONTENT
50+
51+
expect do
52+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: 'n/a')
53+
end.to raise_error(FastlaneCore::Interface::FastlaneError)
54+
end
55+
2556
it 'throws an error when the file is not found' do
2657
file_path = 'file/not/found'
2758

0 commit comments

Comments
 (0)