Skip to content

Commit 1eb1a2b

Browse files
committed
Add unit tests for Ios::GitHelper.commit_version_bump()
1 parent 0eb3da4 commit 1eb1a2b

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

spec/ios_git_helper_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,47 @@
1818
expect(described_class.get_from_env!(key: key)).to eq('abc123')
1919
end
2020
end
21+
22+
describe '#commit_version_bump' do
23+
before do
24+
allow(described_class).to receive(:get_from_env!).and_return('')
25+
end
26+
27+
it 'commits and pushes the app version bump with deliver file and metadata' do
28+
expect(Fastlane::Helper::GitHelper).to receive(:commit) do |arg|
29+
expect_commited_files(files: arg[:files], names: %w[config Deliverfile Resources download_metadata.swift])
30+
end
31+
32+
described_class.commit_version_bump()
33+
end
34+
35+
it 'commits and pushes the app version bump with deliver file only' do
36+
expect(Fastlane::Helper::GitHelper).to receive(:commit) do |arg|
37+
expect_commited_files(files: arg[:files], names: %w[config Deliverfile])
38+
end
39+
40+
described_class.commit_version_bump(include_metadata: false)
41+
end
42+
43+
it 'commits and pushes the app version bump with metadata only' do
44+
expect(Fastlane::Helper::GitHelper).to receive(:commit) do |arg|
45+
expect_commited_files(files: arg[:files], names: %w[config Resources download_metadata.swift])
46+
end
47+
48+
described_class.commit_version_bump(include_deliverfile: false)
49+
end
50+
51+
it 'commits and pushes the app version bump config files only, no deliver file or metadata' do
52+
expect(Fastlane::Helper::GitHelper).to receive(:commit) do |arg|
53+
expect_commited_files(files: arg[:files], names: %w[config])
54+
end
55+
56+
described_class.commit_version_bump(include_metadata: false, include_deliverfile: false)
57+
end
58+
59+
def expect_commited_files(files:, names:)
60+
expect(files.size).to be names.size
61+
expect(files.all? { |file| names.any? { |name| file.include? name } }).to be true
62+
end
63+
end
2164
end

0 commit comments

Comments
 (0)