-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
increment_build_number_spec.rb
121 lines (97 loc) 路 4.67 KB
/
increment_build_number_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
describe Fastlane do
describe Fastlane::FastFile do
describe "Increment Build Number Integration" do
require 'shellwords'
describe "With agv enabled" do
before(:each) do
allow(Fastlane::Actions::IncrementBuildNumberAction).to receive(:system).with(/agvtool/).and_return(true)
end
it "increments the build number of the Xcode project" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool next[-]version [-]all && cd [-]/)
.once
.and_return("")
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool what[-]version/, log: false)
.once
.and_return("Current version of project Test is:\n40")
Fastlane::FastFile.new.parse("lane :test do
increment_build_number(xcodeproj: '.xcproject')
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('40')
end
it "pass a custom build number to the tool" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool new[-]version [-]all 24 && cd [-]/)
.once
.and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
increment_build_number(build_number: 24, xcodeproj: '.xcproject')
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('24')
end
it "skips info plist updating" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool new[-]version 24 && cd [-]/)
.once
.and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
increment_build_number(build_number: 24, xcodeproj: '.xcproject', skip_info_plist: true)
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('24')
end
it "displays error when $(SRCROOT) detected" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool new[-]version [-]all 24 && cd [-]/)
.and_return("Something\n$(SRCROOT)/Test/Info.plist")
expect(UI).to receive(:error).with('Cannot set build number with plist path containing $(SRCROOT)')
expect(UI).to receive(:error).with('Please remove $(SRCROOT) in your Xcode target build settings')
result = Fastlane::FastFile.new.parse("lane :test do
increment_build_number(build_number: 24, xcodeproj: '.xcproject')
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('24')
end
it "raises an exception when user passes workspace" do
expect do
Fastlane::FastFile.new.parse("lane :test do
increment_build_number(xcodeproj: 'project.xcworkspace')
end").runner.execute(:test)
end.to raise_error("Please pass the path to the project, not the workspace")
end
it "properly removes new lines of the build number" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool new[-]version [-]all 24 && cd [-]/)
.once
.and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
increment_build_number(build_number: '24\n', xcodeproj: '.xcproject')
end").runner.execute(:test)
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('24')
end
end
describe "With agv not enabled" do
before(:each) do
allow(Fastlane::Actions::IncrementBuildNumberAction).to receive(:system).and_return(nil)
end
it "raises an exception when agv not enabled" do
expect do
Fastlane::FastFile.new.parse("lane :test do
increment_build_number(xcodeproj: '.xcproject')
end").runner.execute(:test)
end.to raise_error(/Apple Generic Versioning is not enabled./)
end
it "pass a custom build number to the tool" do
expect(Fastlane::Actions).to receive(:sh)
.with(/agvtool new[-]version [-]all 21 && cd [-]/)
.once
.and_return("")
result = Fastlane::FastFile.new.parse("lane :test do
increment_build_number(build_number: 21, xcodeproj: '.xcproject')
end").runner.execute(:test)
expect(result).to eq('21')
expect(Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::BUILD_NUMBER]).to eq('21')
end
end
end
end
end