Skip to content

Commit 9add5bf

Browse files
committed
Add unit tests for the ios_get_app_version action
1 parent 476cf80 commit 9add5bf

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

spec/ios_get_app_version_spec.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require 'spec_helper'
2+
3+
describe Fastlane::Actions::IosGetAppVersionAction do
4+
describe 'getting the public app version from the provided .xcconfig file' do
5+
it 'parses the xcconfig file format correctly and gets the public version' do
6+
xcconfig_mock_content = <<~CONTENT
7+
// a comment
8+
VERSION_SHORT=6
9+
VERSION_LONG=6.30.0
10+
CONTENT
11+
12+
allow(File).to receive(:exist?).and_return(true)
13+
14+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30')
15+
end
16+
17+
it 'parses the xcconfig file format correctly and gets the public hotfix version' do
18+
xcconfig_mock_content = <<~CONTENT
19+
VERSION_SHORT=6
20+
// a comment
21+
VERSION_LONG=6.30.1
22+
CONTENT
23+
24+
allow(File).to receive(:exist?).and_return(true)
25+
26+
expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1')
27+
end
28+
29+
def expect_version(xcconfig_mock_content:, expected_version:)
30+
xcconfig_mock_file_path = File.join('mock', 'file', 'path')
31+
32+
allow(File).to receive(:open).with(xcconfig_mock_file_path, 'r').and_yield(StringIO.new(xcconfig_mock_content))
33+
34+
version_result = run_described_fastlane_action(
35+
public_version_xcconfig_file: xcconfig_mock_file_path
36+
)
37+
38+
expect(version_result).to eq(expected_version)
39+
end
40+
end
41+
end

0 commit comments

Comments
 (0)