knapsack_pro 9.0.0 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +8 -13
- data/lib/knapsack_pro/client/connection.rb +1 -1
- data/lib/knapsack_pro/config/env.rb +1 -24
- data/lib/knapsack_pro/version.rb +1 -1
- metadata +2 -196
- data/.circleci/config.yml +0 -468
- data/.github/assets/install-button.png +0 -0
- data/.github/assets/knapsack-diamonds.png +0 -0
- data/.github/dependabot.yml +0 -11
- data/.github/pull_request_template.md +0 -11
- data/.gitignore +0 -39
- data/.rspec +0 -5
- data/CHANGELOG.md +0 -1995
- data/Gemfile +0 -13
- data/LICENSE +0 -22
- data/README.md +0 -90
- data/Rakefile +0 -2
- data/knapsack_pro.gemspec +0 -43
- data/spec/fixtures/test_file_list_source_file.txt +0 -6
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml +0 -59
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml +0 -61
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml +0 -50
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml +0 -50
- data/spec/integration/api/build_distributions_subset_spec.rb +0 -77
- data/spec/integration/api/build_subsets_create_spec.rb +0 -77
- data/spec/integration/runners/fallback_spec.rb +0 -131
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/rspec_runner.rb +0 -80
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +0 -137
- data/spec/integration/runners/queue/rspec_runner_spec.rb +0 -2672
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +0 -221
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +0 -216
- data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +0 -189
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +0 -427
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +0 -61
- data/spec/knapsack_pro/adapters/test_unit_adapter_spec.rb +0 -86
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +0 -102
- data/spec/knapsack_pro/build_distribution_fetcher_spec.rb +0 -89
- data/spec/knapsack_pro/client/api/action_spec.rb +0 -17
- data/spec/knapsack_pro/client/api/v1/base_spec.rb +0 -2
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +0 -95
- data/spec/knapsack_pro/client/api/v1/build_subsets_spec.rb +0 -35
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +0 -83
- data/spec/knapsack_pro/client/connection_spec.rb +0 -581
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/base_spec.rb +0 -10
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +0 -135
- data/spec/knapsack_pro/config/ci/circle_spec.rb +0 -122
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +0 -81
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +0 -80
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +0 -140
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +0 -137
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +0 -133
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/travis_spec.rb +0 -73
- data/spec/knapsack_pro/config/env_generator_spec.rb +0 -52
- data/spec/knapsack_pro/config/env_spec.rb +0 -1291
- data/spec/knapsack_pro/config/temp_files_spec.rb +0 -25
- data/spec/knapsack_pro/crypto/branch_encryptor_spec.rb +0 -53
- data/spec/knapsack_pro/crypto/decryptor_spec.rb +0 -83
- data/spec/knapsack_pro/crypto/digestor_spec.rb +0 -13
- data/spec/knapsack_pro/crypto/encryptor_spec.rb +0 -58
- data/spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb +0 -27
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +0 -448
- data/spec/knapsack_pro/hooks/queue_spec.rb +0 -199
- data/spec/knapsack_pro/presenter_spec.rb +0 -57
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +0 -248
- data/spec/knapsack_pro/queue_spec.rb +0 -35
- data/spec/knapsack_pro/report_spec.rb +0 -232
- data/spec/knapsack_pro/repository_adapter_initiator_spec.rb +0 -21
- data/spec/knapsack_pro/repository_adapters/base_adapter_spec.rb +0 -13
- data/spec/knapsack_pro/repository_adapters/env_adapter_spec.rb +0 -27
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +0 -106
- data/spec/knapsack_pro/runners/base_runner_spec.rb +0 -87
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +0 -92
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +0 -57
- data/spec/knapsack_pro/runners/queue/base_runner_spec.rb +0 -73
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +0 -209
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +0 -203
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +0 -111
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +0 -56
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +0 -62
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +0 -119
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +0 -42
- data/spec/knapsack_pro/task_loader_spec.rb +0 -14
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +0 -217
- data/spec/knapsack_pro/test_case_mergers/base_merger_spec.rb +0 -27
- data/spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb +0 -81
- data/spec/knapsack_pro/test_file_cleaner_spec.rb +0 -11
- data/spec/knapsack_pro/test_file_finder_spec.rb +0 -176
- data/spec/knapsack_pro/test_file_pattern_spec.rb +0 -49
- data/spec/knapsack_pro/test_file_presenter_spec.rb +0 -22
- data/spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb +0 -41
- data/spec/knapsack_pro/test_flat_distributor_spec.rb +0 -60
- data/spec/knapsack_pro/tracker_spec.rb +0 -184
- data/spec/knapsack_pro/utils_spec.rb +0 -55
- data/spec/knapsack_pro_spec.rb +0 -116
- data/spec/spec_helper.rb +0 -47
- data/spec/support/.gitkeep +0 -0
- data/spec/support/fakes/cucumber.rb +0 -25
- data/spec/support/fakes/minitest.rb +0 -18
- data/spec/support/shared_examples/adapter.rb +0 -17
- data/spec_fake/controllers/users_controller_spec.rb +0 -0
- data/spec_fake/models/admin_spec.rb +0 -0
- data/spec_fake/models/user_spec.rb +0 -0
- data/spec_fake/spec_helper.rb +0 -0
- data/spec_time_tracker/spec_helper.rb +0 -29
- data/test_fake/a_test.rb +0 -0
- data/test_fake/b_test.rb +0 -0
|
@@ -1,1291 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::Env do
|
|
2
|
-
before { stub_const("ENV", {}) }
|
|
3
|
-
|
|
4
|
-
before(:each) do
|
|
5
|
-
described_class.remove_instance_variable(:@ci_node_index) if described_class.instance_variable_defined?(:@ci_node_index)
|
|
6
|
-
described_class.remove_instance_variable(:@ci_node_total) if described_class.instance_variable_defined?(:@ci_node_total)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe '.ci_node_total' do
|
|
10
|
-
subject { described_class.ci_node_total }
|
|
11
|
-
|
|
12
|
-
context 'when KNAPSACK_PRO_CI_NODE_TOTAL has value' do
|
|
13
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => '5' }) }
|
|
14
|
-
it { should eq 5 }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context 'when CI environment has value' do
|
|
18
|
-
before do
|
|
19
|
-
expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(4)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it { should eq 4 }
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'when both KNAPSACK_PRO_CI_NODE_TOTAL and CI environment have value' do
|
|
26
|
-
before do
|
|
27
|
-
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => env_value })
|
|
28
|
-
expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(ci_value)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'when values are different' do
|
|
32
|
-
let(:env_value) { '5' }
|
|
33
|
-
let(:ci_value) { 4 }
|
|
34
|
-
|
|
35
|
-
it { should eq 5 }
|
|
36
|
-
|
|
37
|
-
it 'logs a warning' do
|
|
38
|
-
expect(described_class).to receive(:warn).with(
|
|
39
|
-
'You have set the environment variable KNAPSACK_PRO_CI_NODE_TOTAL to 5 which could be automatically determined from the CI environment as 4.'
|
|
40
|
-
)
|
|
41
|
-
subject
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'when values are the same' do
|
|
46
|
-
let(:env_value) { '5' }
|
|
47
|
-
let(:ci_value) { 5 }
|
|
48
|
-
|
|
49
|
-
it 'does not log a warning' do
|
|
50
|
-
expect(described_class).not_to receive(:warn)
|
|
51
|
-
subject
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when ENV doesn't exist" do
|
|
57
|
-
it { should eq 1 }
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe '.ci_node_index' do
|
|
62
|
-
subject { described_class.ci_node_index }
|
|
63
|
-
|
|
64
|
-
context 'when KNAPSACK_PRO_CI_NODE_INDEX has value' do
|
|
65
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => '3' }) }
|
|
66
|
-
it { should eq 3 }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context 'when CI environment has value' do
|
|
70
|
-
before do
|
|
71
|
-
expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(2)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it { should eq 2 }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context 'when both KNAPSACK_PRO_CI_NODE_INDEX and CI environment have value' do
|
|
78
|
-
before do
|
|
79
|
-
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => env_value })
|
|
80
|
-
expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(ci_value)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context 'when values are different' do
|
|
84
|
-
let(:env_value) { '3' }
|
|
85
|
-
let(:ci_value) { 2 }
|
|
86
|
-
|
|
87
|
-
it { should eq 3 }
|
|
88
|
-
|
|
89
|
-
it 'logs a warning' do
|
|
90
|
-
expect(described_class).to receive(:warn).with(
|
|
91
|
-
'You have set the environment variable KNAPSACK_PRO_CI_NODE_INDEX to 3 which could be automatically determined from the CI environment as 2.'
|
|
92
|
-
)
|
|
93
|
-
subject
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context 'when values are the same' do
|
|
98
|
-
let(:env_value) { '3' }
|
|
99
|
-
let(:ci_value) { 3 }
|
|
100
|
-
|
|
101
|
-
it 'does not log a warning' do
|
|
102
|
-
expect(described_class).not_to receive(:warn)
|
|
103
|
-
subject
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context 'when order of loading envs does matter' do
|
|
109
|
-
context 'when GitLab CI' do
|
|
110
|
-
before { stub_const("ENV", { 'CI_NODE_INDEX' => '2', 'GITLAB_CI' => 'true' }) }
|
|
111
|
-
it { should eq 1 }
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
context "when ENV doesn't exist" do
|
|
116
|
-
it { should eq 0 }
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
describe '.ci_node_build_id' do
|
|
121
|
-
subject { described_class.ci_node_build_id }
|
|
122
|
-
|
|
123
|
-
context 'when KNAPSACK_PRO_CI_NODE_BUILD_ID has value' do
|
|
124
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => '7' }) }
|
|
125
|
-
it { should eq '7' }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context 'when CI environment has value' do
|
|
129
|
-
before do
|
|
130
|
-
expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return('8')
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
it { should eq '8' }
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
context 'when both KNAPSACK_PRO_CI_NODE_BUILD_ID and CI environment have value' do
|
|
137
|
-
before do
|
|
138
|
-
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => env_value })
|
|
139
|
-
expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return(ci_value)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context 'when values are different' do
|
|
143
|
-
let(:env_value) { '7' }
|
|
144
|
-
let(:ci_value) { '8' }
|
|
145
|
-
|
|
146
|
-
it { should eq '7' }
|
|
147
|
-
|
|
148
|
-
it 'logs a warning' do
|
|
149
|
-
expect(described_class).to receive(:warn).with(
|
|
150
|
-
'You have set the environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID to 7 which could be automatically determined from the CI environment as 8.'
|
|
151
|
-
)
|
|
152
|
-
subject
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context 'when values are the same' do
|
|
157
|
-
let(:env_value) { '7' }
|
|
158
|
-
let(:ci_value) { '7' }
|
|
159
|
-
|
|
160
|
-
it 'does not log a warning' do
|
|
161
|
-
expect(described_class).not_to receive(:warn)
|
|
162
|
-
subject
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
context "when ENV does not exist" do
|
|
168
|
-
it 'raises' do
|
|
169
|
-
expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_BUILD_ID/)
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
describe '.ci_node_retry_count' do
|
|
175
|
-
subject { described_class.ci_node_retry_count }
|
|
176
|
-
|
|
177
|
-
context 'when KNAPSACK_PRO_CI_NODE_RETRY_COUNT has value' do
|
|
178
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => '1' }) }
|
|
179
|
-
it { should eq 1 }
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
context 'when CI environment has value' do
|
|
183
|
-
before do
|
|
184
|
-
expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return('2')
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it { should eq 2 }
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
context 'when both KNAPSACK_PRO_CI_NODE_RETRY_COUNT and CI environment have value' do
|
|
191
|
-
before do
|
|
192
|
-
stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => env_value })
|
|
193
|
-
expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return(ci_value)
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
context 'when values are different' do
|
|
197
|
-
let(:env_value) { '1' }
|
|
198
|
-
let(:ci_value) { 2 }
|
|
199
|
-
|
|
200
|
-
it { should eq 1 }
|
|
201
|
-
|
|
202
|
-
it 'logs a warning' do
|
|
203
|
-
expect(described_class).to receive(:warn).with(
|
|
204
|
-
'You have set the environment variable KNAPSACK_PRO_CI_NODE_RETRY_COUNT to 1 which could be automatically determined from the CI environment as 2.'
|
|
205
|
-
)
|
|
206
|
-
subject
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
context 'when values are the same' do
|
|
211
|
-
let(:env_value) { '7' }
|
|
212
|
-
let(:ci_value) { '7' }
|
|
213
|
-
|
|
214
|
-
it 'does not log a warning' do
|
|
215
|
-
expect(described_class).not_to receive(:warn)
|
|
216
|
-
subject
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
context "when ENV doesn't exist" do
|
|
222
|
-
it { should eq 0 }
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
describe '.max_request_retries' do
|
|
227
|
-
subject { described_class.max_request_retries }
|
|
228
|
-
|
|
229
|
-
context 'when ENV exists' do
|
|
230
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MAX_REQUEST_RETRIES' => '2' }) }
|
|
231
|
-
it { should eq 2 }
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
context "when ENV doesn't exist" do
|
|
235
|
-
it { should be_nil }
|
|
236
|
-
end
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
describe '.commit_hash' do
|
|
240
|
-
subject { described_class.commit_hash }
|
|
241
|
-
|
|
242
|
-
context 'when KNAPSACK_PRO_COMMIT_HASH has value' do
|
|
243
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => '3fa64859337f6e56409d49f865d13fd7' }) }
|
|
244
|
-
it { should eq '3fa64859337f6e56409d49f865d13fd7' }
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
context 'when CI environment has value' do
|
|
248
|
-
before do
|
|
249
|
-
expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return('fe61a08118d0d52e97c38666eba1eaf3')
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
it { should eq 'fe61a08118d0d52e97c38666eba1eaf3' }
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
context 'when both KNAPSACK_PRO_COMMIT_HASH and CI environment have value' do
|
|
256
|
-
before do
|
|
257
|
-
stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => env_value })
|
|
258
|
-
expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return(ci_value)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
context 'when values are different' do
|
|
262
|
-
let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
|
|
263
|
-
let(:ci_value) { 'fe61a08118d0d52e97c38666eba1eaf3' }
|
|
264
|
-
|
|
265
|
-
it { should eq '3fa64859337f6e56409d49f865d13fd7' }
|
|
266
|
-
|
|
267
|
-
it 'logs a warning' do
|
|
268
|
-
expect(described_class).to receive(:warn).with(
|
|
269
|
-
'You have set the environment variable KNAPSACK_PRO_COMMIT_HASH to 3fa64859337f6e56409d49f865d13fd7 which could be automatically determined from the CI environment as fe61a08118d0d52e97c38666eba1eaf3.'
|
|
270
|
-
)
|
|
271
|
-
subject
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
context 'when values are the same' do
|
|
276
|
-
let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
|
|
277
|
-
let(:ci_value) { '3fa64859337f6e56409d49f865d13fd7' }
|
|
278
|
-
|
|
279
|
-
it 'does not log a warning' do
|
|
280
|
-
expect(described_class).not_to receive(:warn)
|
|
281
|
-
subject
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
context "when ENV doesn't exist" do
|
|
287
|
-
it { should be nil }
|
|
288
|
-
end
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
describe '.branch' do
|
|
292
|
-
subject { described_class.branch }
|
|
293
|
-
|
|
294
|
-
context 'when KNAPSACK_PRO_BRANCH has value' do
|
|
295
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => 'main' }) }
|
|
296
|
-
it { should eq 'main' }
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
context 'when CI environment has value' do
|
|
300
|
-
before do
|
|
301
|
-
expect(described_class).to receive(:ci_env_for).with(:branch).and_return('feature-branch')
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
it { should eq 'feature-branch' }
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
context 'when both KNAPSACK_PRO_BRANCH and CI environment have value' do
|
|
308
|
-
before do
|
|
309
|
-
stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => env_value })
|
|
310
|
-
expect(described_class).to receive(:ci_env_for).with(:branch).and_return(ci_value)
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
context 'when values are different' do
|
|
314
|
-
let(:env_value) { 'main' }
|
|
315
|
-
let(:ci_value) { 'feature-branch' }
|
|
316
|
-
|
|
317
|
-
it { should eq 'main' }
|
|
318
|
-
|
|
319
|
-
it 'logs a warning' do
|
|
320
|
-
expect(described_class).to receive(:warn).with(
|
|
321
|
-
'You have set the environment variable KNAPSACK_PRO_BRANCH to main which could be automatically determined from the CI environment as feature-branch.'
|
|
322
|
-
)
|
|
323
|
-
subject
|
|
324
|
-
end
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
context 'when values are the same' do
|
|
328
|
-
let(:env_value) { 'main' }
|
|
329
|
-
let(:ci_value) { 'main' }
|
|
330
|
-
|
|
331
|
-
it 'does not log a warning' do
|
|
332
|
-
expect(described_class).not_to receive(:warn)
|
|
333
|
-
subject
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
|
|
338
|
-
context "when ENV doesn't exist" do
|
|
339
|
-
it { should be nil }
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
describe '.project_dir' do
|
|
344
|
-
subject { described_class.project_dir }
|
|
345
|
-
|
|
346
|
-
context 'when KNAPSACK_PRO_PROJECT_DIR has value' do
|
|
347
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => '/home/user/myapp' }) }
|
|
348
|
-
it { should eq '/home/user/myapp' }
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
context 'when CI environment has value' do
|
|
352
|
-
before do
|
|
353
|
-
expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return('/home/runner/myapp')
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
it { should eq '/home/runner/myapp' }
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
context 'when both KNAPSACK_PRO_PROJECT_DIR and CI environment have value' do
|
|
360
|
-
before do
|
|
361
|
-
stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => env_value })
|
|
362
|
-
expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return(ci_value)
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
context 'when values are different' do
|
|
366
|
-
let(:env_value) { '/home/user/myapp' }
|
|
367
|
-
let(:ci_value) { '/home/runner/myapp' }
|
|
368
|
-
|
|
369
|
-
it { should eq '/home/user/myapp' }
|
|
370
|
-
|
|
371
|
-
it 'logs a warning' do
|
|
372
|
-
expect(described_class).to receive(:warn).with(
|
|
373
|
-
'You have set the environment variable KNAPSACK_PRO_PROJECT_DIR to /home/user/myapp which could be automatically determined from the CI environment as /home/runner/myapp.'
|
|
374
|
-
)
|
|
375
|
-
subject
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
context 'when values are the same' do
|
|
380
|
-
let(:env_value) { '/home/user/myapp' }
|
|
381
|
-
let(:ci_value) { '/home/user/myapp' }
|
|
382
|
-
|
|
383
|
-
it 'does not log a warning' do
|
|
384
|
-
expect(described_class).not_to receive(:warn)
|
|
385
|
-
subject
|
|
386
|
-
end
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
context "when ENV doesn't exist" do
|
|
391
|
-
it { should be nil }
|
|
392
|
-
end
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
describe '.user_seat' do
|
|
396
|
-
subject { described_class.user_seat }
|
|
397
|
-
|
|
398
|
-
context 'when KNAPSACK_PRO_USER_SEAT has value' do
|
|
399
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => 'John Doe' }) }
|
|
400
|
-
it { should eq 'John Doe' }
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
context 'when CI environment has value' do
|
|
404
|
-
before do
|
|
405
|
-
expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return('Jane Doe')
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
it { should eq 'Jane Doe' }
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
context 'when both KNAPSACK_PRO_USER_SEAT and CI environment have value' do
|
|
412
|
-
before do
|
|
413
|
-
stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => env_value })
|
|
414
|
-
expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return(ci_value)
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
context 'when values are different' do
|
|
418
|
-
let(:env_value) { 'John Doe' }
|
|
419
|
-
let(:ci_value) { 'Jane Doe' }
|
|
420
|
-
|
|
421
|
-
it { should eq 'John Doe' }
|
|
422
|
-
|
|
423
|
-
it 'logs a warning' do
|
|
424
|
-
expect(described_class).to receive(:warn).with(
|
|
425
|
-
'You have set the environment variable KNAPSACK_PRO_USER_SEAT to John Doe which could be automatically determined from the CI environment as Jane Doe.'
|
|
426
|
-
)
|
|
427
|
-
subject
|
|
428
|
-
end
|
|
429
|
-
end
|
|
430
|
-
|
|
431
|
-
context 'when values are the same' do
|
|
432
|
-
let(:env_value) { 'John Doe' }
|
|
433
|
-
let(:ci_value) { 'John Doe' }
|
|
434
|
-
|
|
435
|
-
it 'does not log a warning' do
|
|
436
|
-
expect(described_class).not_to receive(:warn)
|
|
437
|
-
subject
|
|
438
|
-
end
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
context "when ENV doesn't exist" do
|
|
443
|
-
it { should be nil }
|
|
444
|
-
end
|
|
445
|
-
end
|
|
446
|
-
|
|
447
|
-
describe '.masked_seat_hash' do
|
|
448
|
-
subject { described_class.masked_user_seat }
|
|
449
|
-
|
|
450
|
-
before do
|
|
451
|
-
expect(described_class).to receive(:user_seat).at_least(1).and_return(user_seat)
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
context 'when the user seat is a name' do
|
|
455
|
-
let(:user_seat) { 'John Doe' }
|
|
456
|
-
|
|
457
|
-
it { expect(subject).to eq 'Jo** Do*' }
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
context 'when the user seat is an e-mail' do
|
|
461
|
-
let(:user_seat) { 'john.doe@example.com' }
|
|
462
|
-
|
|
463
|
-
it { expect(subject).to eq 'jo**.do*@ex*****.co*' }
|
|
464
|
-
end
|
|
465
|
-
|
|
466
|
-
context 'when the user seat is nil' do
|
|
467
|
-
let(:user_seat) { nil }
|
|
468
|
-
|
|
469
|
-
it { expect(subject).to be_nil }
|
|
470
|
-
end
|
|
471
|
-
end
|
|
472
|
-
|
|
473
|
-
describe '.test_file_pattern' do
|
|
474
|
-
subject { described_class.test_file_pattern }
|
|
475
|
-
|
|
476
|
-
context 'when ENV exists' do
|
|
477
|
-
let(:test_file_pattern) { 'custom_spec/**{,/*/**}/*_spec.rb' }
|
|
478
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_PATTERN' => test_file_pattern }) }
|
|
479
|
-
it { should eq test_file_pattern }
|
|
480
|
-
end
|
|
481
|
-
|
|
482
|
-
context "when ENV doesn't exist" do
|
|
483
|
-
it { should be_nil }
|
|
484
|
-
end
|
|
485
|
-
end
|
|
486
|
-
|
|
487
|
-
describe '.slow_test_file_pattern' do
|
|
488
|
-
subject { described_class.slow_test_file_pattern }
|
|
489
|
-
|
|
490
|
-
context 'when ENV exists' do
|
|
491
|
-
let(:slow_test_file_pattern) { 'spec/features/*_spec.rb' }
|
|
492
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN' => slow_test_file_pattern }) }
|
|
493
|
-
it { should eq slow_test_file_pattern }
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
context "when ENV doesn't exist" do
|
|
497
|
-
it { should be_nil }
|
|
498
|
-
end
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
describe '.test_file_exclude_pattern' do
|
|
502
|
-
subject { described_class.test_file_exclude_pattern }
|
|
503
|
-
|
|
504
|
-
context 'when ENV exists' do
|
|
505
|
-
let(:test_file_exclude_pattern) { 'spec/features/*_spec.rb' }
|
|
506
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN' => test_file_exclude_pattern }) }
|
|
507
|
-
it { should eq test_file_exclude_pattern }
|
|
508
|
-
end
|
|
509
|
-
|
|
510
|
-
context "when ENV doesn't exist" do
|
|
511
|
-
it { should be_nil }
|
|
512
|
-
end
|
|
513
|
-
end
|
|
514
|
-
|
|
515
|
-
describe '.test_file_list' do
|
|
516
|
-
subject { described_class.test_file_list }
|
|
517
|
-
|
|
518
|
-
context 'when ENV exists' do
|
|
519
|
-
let(:test_file_list) { 'spec/features/dashboard_spec.rb,spec/models/user.rb:10,spec/models/user.rb:29' }
|
|
520
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_LIST' => test_file_list }) }
|
|
521
|
-
it { should eq test_file_list }
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
context "when ENV doesn't exist" do
|
|
525
|
-
it { should be_nil }
|
|
526
|
-
end
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
describe '.test_file_list_source_file' do
|
|
530
|
-
subject { described_class.test_file_list_source_file }
|
|
531
|
-
|
|
532
|
-
context 'when ENV exists' do
|
|
533
|
-
let(:test_file_list_source_file) { 'spec/fixtures/test_file_list_source_file.txt' }
|
|
534
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE' => test_file_list_source_file }) }
|
|
535
|
-
it { should eq test_file_list_source_file }
|
|
536
|
-
end
|
|
537
|
-
|
|
538
|
-
context "when ENV doesn't exist" do
|
|
539
|
-
it { should be_nil }
|
|
540
|
-
end
|
|
541
|
-
end
|
|
542
|
-
|
|
543
|
-
describe '.test_dir' do
|
|
544
|
-
subject { described_class.test_dir }
|
|
545
|
-
|
|
546
|
-
context 'when ENV exists' do
|
|
547
|
-
let(:test_dir) { 'spec' }
|
|
548
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_DIR' => test_dir }) }
|
|
549
|
-
it { should eql test_dir }
|
|
550
|
-
end
|
|
551
|
-
|
|
552
|
-
context "when ENV doesn't exist" do
|
|
553
|
-
it { should be_nil }
|
|
554
|
-
end
|
|
555
|
-
end
|
|
556
|
-
|
|
557
|
-
describe '.repository_adapter' do
|
|
558
|
-
subject { described_class.repository_adapter }
|
|
559
|
-
|
|
560
|
-
context 'when ENV exists' do
|
|
561
|
-
let(:repository_adapter) { 'git' }
|
|
562
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_REPOSITORY_ADAPTER' => repository_adapter }) }
|
|
563
|
-
it { should eq repository_adapter }
|
|
564
|
-
end
|
|
565
|
-
|
|
566
|
-
context "when ENV doesn't exist" do
|
|
567
|
-
it { should be_nil }
|
|
568
|
-
end
|
|
569
|
-
end
|
|
570
|
-
|
|
571
|
-
describe '.regular_mode?' do
|
|
572
|
-
subject { described_class.regular_mode? }
|
|
573
|
-
|
|
574
|
-
context 'when regular mode is enabled' do
|
|
575
|
-
let(:regular_mode_enabled) { 'true' }
|
|
576
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_REGULAR_MODE_ENABLED' => regular_mode_enabled }) }
|
|
577
|
-
it { should eq true }
|
|
578
|
-
end
|
|
579
|
-
|
|
580
|
-
context 'when regular mode is disabled' do
|
|
581
|
-
let(:regular_mode_enabled) { 'false' }
|
|
582
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_REGULAR_MODE_ENABLED' => regular_mode_enabled }) }
|
|
583
|
-
it { should eq false }
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
context "when ENV doesn't exist" do
|
|
587
|
-
it { should false }
|
|
588
|
-
end
|
|
589
|
-
end
|
|
590
|
-
|
|
591
|
-
describe '.queue_mode?' do
|
|
592
|
-
subject { described_class.queue_mode? }
|
|
593
|
-
|
|
594
|
-
context 'when queue mode is enabled' do
|
|
595
|
-
let(:queue_mode_enabled) { 'true' }
|
|
596
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_QUEUE_MODE_ENABLED' => queue_mode_enabled }) }
|
|
597
|
-
it { should eq true }
|
|
598
|
-
end
|
|
599
|
-
|
|
600
|
-
context 'when queue mode is disabled' do
|
|
601
|
-
let(:queue_mode_enabled) { 'false' }
|
|
602
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_QUEUE_MODE_ENABLED' => queue_mode_enabled }) }
|
|
603
|
-
it { should eq false }
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
context "when ENV doesn't exist" do
|
|
607
|
-
it { should false }
|
|
608
|
-
end
|
|
609
|
-
end
|
|
610
|
-
|
|
611
|
-
describe '.queue_id' do
|
|
612
|
-
subject { described_class.queue_id }
|
|
613
|
-
|
|
614
|
-
context 'when ENV exists' do
|
|
615
|
-
let(:queue_id) { 'fake-queue-id' }
|
|
616
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_QUEUE_ID' => queue_id }) }
|
|
617
|
-
it { should eq queue_id }
|
|
618
|
-
end
|
|
619
|
-
|
|
620
|
-
context "when ENV doesn't exist" do
|
|
621
|
-
before { stub_const("ENV", {}) }
|
|
622
|
-
it do
|
|
623
|
-
expect { subject }.to raise_error('Missing Queue ID')
|
|
624
|
-
end
|
|
625
|
-
end
|
|
626
|
-
end
|
|
627
|
-
|
|
628
|
-
describe '.subset_queue_id' do
|
|
629
|
-
subject { described_class.subset_queue_id }
|
|
630
|
-
|
|
631
|
-
context 'when ENV exists' do
|
|
632
|
-
let(:subset_queue_id) { 'fake-subset-queue-id' }
|
|
633
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_SUBSET_QUEUE_ID' => subset_queue_id }) }
|
|
634
|
-
it { should eq subset_queue_id }
|
|
635
|
-
end
|
|
636
|
-
|
|
637
|
-
context "when ENV doesn't exist" do
|
|
638
|
-
it do
|
|
639
|
-
expect { subject }.to raise_error('Missing Subset Queue ID')
|
|
640
|
-
end
|
|
641
|
-
end
|
|
642
|
-
end
|
|
643
|
-
|
|
644
|
-
describe '.fallback_mode_enabled' do
|
|
645
|
-
subject { described_class.fallback_mode_enabled }
|
|
646
|
-
|
|
647
|
-
context 'when ENV exists' do
|
|
648
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FALLBACK_MODE_ENABLED' => 'false' }) }
|
|
649
|
-
it { should eq 'false' }
|
|
650
|
-
end
|
|
651
|
-
|
|
652
|
-
context "when ENV doesn't exist" do
|
|
653
|
-
it { should be true }
|
|
654
|
-
end
|
|
655
|
-
end
|
|
656
|
-
|
|
657
|
-
describe '.fallback_mode_enabled?' do
|
|
658
|
-
subject { described_class.fallback_mode_enabled? }
|
|
659
|
-
|
|
660
|
-
context 'when ENV exists' do
|
|
661
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FALLBACK_MODE_ENABLED' => 'false' }) }
|
|
662
|
-
it { should be false }
|
|
663
|
-
end
|
|
664
|
-
|
|
665
|
-
context "when ENV doesn't exist" do
|
|
666
|
-
it { should be true }
|
|
667
|
-
end
|
|
668
|
-
end
|
|
669
|
-
|
|
670
|
-
describe '.test_files_encrypted' do
|
|
671
|
-
subject { described_class.test_files_encrypted }
|
|
672
|
-
|
|
673
|
-
context 'when ENV exists' do
|
|
674
|
-
let(:test_files_encrypted) { 'true' }
|
|
675
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_FILES_ENCRYPTED' => test_files_encrypted }) }
|
|
676
|
-
it { should eq test_files_encrypted }
|
|
677
|
-
end
|
|
678
|
-
|
|
679
|
-
context "when ENV doesn't exist" do
|
|
680
|
-
it { should be_nil }
|
|
681
|
-
end
|
|
682
|
-
end
|
|
683
|
-
|
|
684
|
-
describe '.test_files_encrypted?' do
|
|
685
|
-
subject { described_class.test_files_encrypted? }
|
|
686
|
-
|
|
687
|
-
before do
|
|
688
|
-
expect(described_class).to receive(:test_files_encrypted).and_return(test_files_encrypted)
|
|
689
|
-
end
|
|
690
|
-
|
|
691
|
-
context 'when enabled' do
|
|
692
|
-
let(:test_files_encrypted) { 'true' }
|
|
693
|
-
|
|
694
|
-
it { should be true }
|
|
695
|
-
end
|
|
696
|
-
|
|
697
|
-
context 'when disabled' do
|
|
698
|
-
let(:test_files_encrypted) { nil }
|
|
699
|
-
|
|
700
|
-
it { should be false }
|
|
701
|
-
end
|
|
702
|
-
end
|
|
703
|
-
|
|
704
|
-
describe '.branch_encrypted' do
|
|
705
|
-
subject { described_class.branch_encrypted }
|
|
706
|
-
|
|
707
|
-
context 'when ENV exists' do
|
|
708
|
-
let(:branch_encrypted) { 'true' }
|
|
709
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_BRANCH_ENCRYPTED' => branch_encrypted }) }
|
|
710
|
-
it { should eq branch_encrypted }
|
|
711
|
-
end
|
|
712
|
-
|
|
713
|
-
context "when ENV doesn't exist" do
|
|
714
|
-
it { should be_nil }
|
|
715
|
-
end
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
describe '.branch_encrypted?' do
|
|
719
|
-
subject { described_class.branch_encrypted? }
|
|
720
|
-
|
|
721
|
-
before do
|
|
722
|
-
expect(described_class).to receive(:branch_encrypted).and_return(branch_encrypted)
|
|
723
|
-
end
|
|
724
|
-
|
|
725
|
-
context 'when enabled' do
|
|
726
|
-
let(:branch_encrypted) { 'true' }
|
|
727
|
-
|
|
728
|
-
it { should be true }
|
|
729
|
-
end
|
|
730
|
-
|
|
731
|
-
context 'when disabled' do
|
|
732
|
-
let(:branch_encrypted) { nil }
|
|
733
|
-
|
|
734
|
-
it { should be false }
|
|
735
|
-
end
|
|
736
|
-
end
|
|
737
|
-
|
|
738
|
-
describe '.salt' do
|
|
739
|
-
subject { described_class.salt }
|
|
740
|
-
|
|
741
|
-
context 'when ENV exists' do
|
|
742
|
-
let(:salt) { '123' }
|
|
743
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_SALT' => salt }) }
|
|
744
|
-
it { should eq salt }
|
|
745
|
-
end
|
|
746
|
-
|
|
747
|
-
context "when ENV doesn't exist" do
|
|
748
|
-
it do
|
|
749
|
-
expect { subject }.to raise_error('Missing environment variable KNAPSACK_PRO_SALT')
|
|
750
|
-
end
|
|
751
|
-
end
|
|
752
|
-
end
|
|
753
|
-
|
|
754
|
-
describe '.endpoint' do
|
|
755
|
-
subject { described_class.endpoint }
|
|
756
|
-
|
|
757
|
-
context 'when ENV exists' do
|
|
758
|
-
let(:endpoint) { 'http://api-custom-url.knapsackpro.com' }
|
|
759
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_ENDPOINT' => endpoint }) }
|
|
760
|
-
it { should eq endpoint }
|
|
761
|
-
end
|
|
762
|
-
|
|
763
|
-
context "when ENV doesn't exist" do
|
|
764
|
-
context 'when default mode' do
|
|
765
|
-
it { should eq 'https://api.knapsackpro.com' }
|
|
766
|
-
end
|
|
767
|
-
|
|
768
|
-
context 'when development mode' do
|
|
769
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'development' }) }
|
|
770
|
-
it { should eq 'http://api.knapsackpro.test:3000' }
|
|
771
|
-
end
|
|
772
|
-
|
|
773
|
-
context 'when test mode' do
|
|
774
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'test' }) }
|
|
775
|
-
it { should eq 'https://api-staging.knapsackpro.com' }
|
|
776
|
-
end
|
|
777
|
-
|
|
778
|
-
context 'when production mode' do
|
|
779
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'production' }) }
|
|
780
|
-
it { should eq 'https://api.knapsackpro.com' }
|
|
781
|
-
end
|
|
782
|
-
|
|
783
|
-
context 'when unknown mode' do
|
|
784
|
-
before do
|
|
785
|
-
expect(described_class).to receive(:mode).and_return(:fake)
|
|
786
|
-
end
|
|
787
|
-
|
|
788
|
-
it do
|
|
789
|
-
expect { subject }.to raise_error('Missing environment variable KNAPSACK_PRO_ENDPOINT')
|
|
790
|
-
end
|
|
791
|
-
end
|
|
792
|
-
end
|
|
793
|
-
end
|
|
794
|
-
|
|
795
|
-
describe '.fixed_test_suite_split?' do
|
|
796
|
-
subject { described_class.fixed_test_suite_split? }
|
|
797
|
-
|
|
798
|
-
context 'when KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true' do
|
|
799
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT' => 'true' }) }
|
|
800
|
-
it { should be true }
|
|
801
|
-
end
|
|
802
|
-
|
|
803
|
-
context 'when KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=false' do
|
|
804
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT' => 'false' }) }
|
|
805
|
-
it { should be false }
|
|
806
|
-
end
|
|
807
|
-
|
|
808
|
-
context "when ENV doesn't exist" do
|
|
809
|
-
before { stub_const("ENV", {}) }
|
|
810
|
-
it { should be true }
|
|
811
|
-
end
|
|
812
|
-
end
|
|
813
|
-
|
|
814
|
-
describe '.fixed_queue_split?' do
|
|
815
|
-
subject { described_class.fixed_queue_split? }
|
|
816
|
-
after(:each) { described_class.remove_instance_variable(:@fixed_queue_split) }
|
|
817
|
-
|
|
818
|
-
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=false' do
|
|
819
|
-
[
|
|
820
|
-
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
821
|
-
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
822
|
-
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
823
|
-
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
824
|
-
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
825
|
-
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
826
|
-
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
827
|
-
['GitLab CI', { 'GITLAB_CI' => 'true' }],
|
|
828
|
-
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
829
|
-
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
830
|
-
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
831
|
-
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
832
|
-
['Unsupported CI', {}],
|
|
833
|
-
].each do |ci, env|
|
|
834
|
-
it "on #{ci} it is false" do
|
|
835
|
-
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'false' }))
|
|
836
|
-
|
|
837
|
-
ci_env = described_class.detected_ci.new.fixed_queue_split
|
|
838
|
-
if ci_env == false
|
|
839
|
-
expect(described_class).not_to receive(:warn)
|
|
840
|
-
else
|
|
841
|
-
expect(described_class).to receive(:warn).with(
|
|
842
|
-
'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to false which could be automatically determined from the CI environment as true.'
|
|
843
|
-
)
|
|
844
|
-
end
|
|
845
|
-
|
|
846
|
-
expect(subject).to eq(false)
|
|
847
|
-
end
|
|
848
|
-
end
|
|
849
|
-
end
|
|
850
|
-
|
|
851
|
-
context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true' do
|
|
852
|
-
[
|
|
853
|
-
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
854
|
-
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
855
|
-
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
856
|
-
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
857
|
-
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
858
|
-
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
859
|
-
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
860
|
-
['GitLab CI', { 'GITLAB_CI' => 'true' }],
|
|
861
|
-
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
862
|
-
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
863
|
-
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
864
|
-
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
865
|
-
['Unsupported CI', {}],
|
|
866
|
-
].each do |ci, env|
|
|
867
|
-
it "on #{ci} it is true" do
|
|
868
|
-
stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'true' }))
|
|
869
|
-
|
|
870
|
-
ci_env = described_class.detected_ci.new.fixed_queue_split
|
|
871
|
-
if ci_env == true
|
|
872
|
-
expect(described_class).not_to receive(:warn)
|
|
873
|
-
else
|
|
874
|
-
expect(described_class).to receive(:warn).with(
|
|
875
|
-
'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to true which could be automatically determined from the CI environment as false.'
|
|
876
|
-
)
|
|
877
|
-
end
|
|
878
|
-
|
|
879
|
-
expect(subject).to eq(true)
|
|
880
|
-
end
|
|
881
|
-
end
|
|
882
|
-
end
|
|
883
|
-
|
|
884
|
-
context "when ENV doesn't exist" do
|
|
885
|
-
[
|
|
886
|
-
['AppVeyor', { 'APPVEYOR' => '123' }, false],
|
|
887
|
-
['Buildkite', { 'BUILDKITE' => 'true' }, true],
|
|
888
|
-
['CircleCI', { 'CIRCLECI' => 'true' }, false],
|
|
889
|
-
['Cirrus CI', { 'CIRRUS_CI' => 'true' }, false],
|
|
890
|
-
['Codefresh', { 'CF_BUILD_ID' => '123' }, false],
|
|
891
|
-
['Codeship', { 'CI_NAME' => 'codeship' }, true],
|
|
892
|
-
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }, true],
|
|
893
|
-
['GitLab CI', { 'GITLAB_CI' => 'true' }, true],
|
|
894
|
-
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }, false],
|
|
895
|
-
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }, false],
|
|
896
|
-
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }, false],
|
|
897
|
-
['Travis CI', { 'TRAVIS' => 'true' }, true],
|
|
898
|
-
['Unsupported CI', {}, true],
|
|
899
|
-
].each do |ci, env, expected|
|
|
900
|
-
it "on #{ci} it is #{expected}" do
|
|
901
|
-
stub_const("ENV", env)
|
|
902
|
-
|
|
903
|
-
logger = instance_double(Logger)
|
|
904
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
905
|
-
expect(logger).to receive(:info).with("KNAPSACK_PRO_FIXED_QUEUE_SPLIT is not set. Using default value: #{expected}. Learn more at #{KnapsackPro::Urls::FIXED_QUEUE_SPLIT}")
|
|
906
|
-
|
|
907
|
-
expect(subject).to eq(expected)
|
|
908
|
-
end
|
|
909
|
-
end
|
|
910
|
-
end
|
|
911
|
-
end
|
|
912
|
-
|
|
913
|
-
describe '.cucumber_queue_prefix' do
|
|
914
|
-
subject { described_class.cucumber_queue_prefix }
|
|
915
|
-
|
|
916
|
-
context 'when ENV exists' do
|
|
917
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX' => 'bundle exec spring' }) }
|
|
918
|
-
it { should eq 'bundle exec spring' }
|
|
919
|
-
end
|
|
920
|
-
|
|
921
|
-
context "when ENV doesn't exist" do
|
|
922
|
-
before { stub_const("ENV", {}) }
|
|
923
|
-
it { should eq 'bundle exec' }
|
|
924
|
-
end
|
|
925
|
-
end
|
|
926
|
-
|
|
927
|
-
describe '.rspec_split_by_test_examples?' do
|
|
928
|
-
subject { described_class.rspec_split_by_test_examples? }
|
|
929
|
-
|
|
930
|
-
before do
|
|
931
|
-
described_class.remove_instance_variable(:@rspec_split_by_test_examples) if described_class.instance_variable_defined?(:@rspec_split_by_test_examples)
|
|
932
|
-
end
|
|
933
|
-
after do
|
|
934
|
-
described_class.remove_instance_variable(:@rspec_split_by_test_examples)
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
[
|
|
938
|
-
['false', '2', nil, false],
|
|
939
|
-
['true', '2', nil, true],
|
|
940
|
-
[nil, '2', nil, true],
|
|
941
|
-
['false', '1', nil, false],
|
|
942
|
-
['true', '1', nil, false, :debug, 'Skipping split by test examples because tests are running on a single CI node (no parallelism)'],
|
|
943
|
-
[nil, '1', nil, false, :debug, 'Skipping split by test examples because tests are running on a single CI node (no parallelism)'],
|
|
944
|
-
['false', '2', 'true', false],
|
|
945
|
-
['true', '2', 'true', true],
|
|
946
|
-
[nil, '2', 'true', false, :warn, "Skipping split by test examples because test file names encryption is enabled:\nhttps://knapsackpro.com/perma/ruby/encryption\nhttps://knapsackpro.com/perma/ruby/split-by-test-examples"],
|
|
947
|
-
['false', '1', 'true', false],
|
|
948
|
-
['true', '1', 'true', false, :debug, 'Skipping split by test examples because tests are running on a single CI node (no parallelism)'],
|
|
949
|
-
[nil, '1', 'true', false, :warn, "Skipping split by test examples because test file names encryption is enabled:\nhttps://knapsackpro.com/perma/ruby/encryption\nhttps://knapsackpro.com/perma/ruby/split-by-test-examples"],
|
|
950
|
-
].each do |sbte, node_total, encrypted, expected, log_level, log_message|
|
|
951
|
-
context "KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=#{sbte.inspect} AND KNAPSACK_PRO_CI_NODE_TOTAL=#{node_total.inspect} AND KNAPSACK_PRO_TEST_FILES_ENCRYPTED=#{encrypted.inspect}" do
|
|
952
|
-
before do
|
|
953
|
-
stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES' => sbte, 'KNAPSACK_PRO_CI_NODE_TOTAL' => node_total, 'KNAPSACK_PRO_TEST_FILES_ENCRYPTED' => encrypted }.compact)
|
|
954
|
-
|
|
955
|
-
if log_level && log_message
|
|
956
|
-
logger = instance_double(Logger)
|
|
957
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
958
|
-
expect(logger).to receive(log_level).once.with(log_message)
|
|
959
|
-
end
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
it do
|
|
963
|
-
expect(described_class.rspec_split_by_test_examples?).to eq(expected)
|
|
964
|
-
expect(described_class.rspec_split_by_test_examples?).to eq(expected)
|
|
965
|
-
end
|
|
966
|
-
end
|
|
967
|
-
end
|
|
968
|
-
end
|
|
969
|
-
|
|
970
|
-
describe '.rspec_test_example_detector_prefix' do
|
|
971
|
-
subject { described_class.rspec_test_example_detector_prefix }
|
|
972
|
-
|
|
973
|
-
context 'when ENV exists' do
|
|
974
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX' => '' }) }
|
|
975
|
-
it { should eq '' }
|
|
976
|
-
end
|
|
977
|
-
|
|
978
|
-
context "when ENV doesn't exist" do
|
|
979
|
-
before { stub_const("ENV", {}) }
|
|
980
|
-
it { should eq 'bundle exec' }
|
|
981
|
-
end
|
|
982
|
-
end
|
|
983
|
-
|
|
984
|
-
describe '.slow_test_file_threshold' do
|
|
985
|
-
subject { described_class.slow_test_file_threshold }
|
|
986
|
-
|
|
987
|
-
context 'when ENV exists' do
|
|
988
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_SLOW_TEST_FILE_THRESHOLD' => '2' }) }
|
|
989
|
-
it 'returns seconds' do
|
|
990
|
-
expect(subject).to eq 2.0
|
|
991
|
-
expect(subject).to be_a Float
|
|
992
|
-
end
|
|
993
|
-
end
|
|
994
|
-
|
|
995
|
-
context "when ENV doesn't exist" do
|
|
996
|
-
before { stub_const("ENV", {}) }
|
|
997
|
-
it { should be_nil }
|
|
998
|
-
end
|
|
999
|
-
end
|
|
1000
|
-
|
|
1001
|
-
describe '.slow_test_file_threshold?' do
|
|
1002
|
-
subject { described_class.slow_test_file_threshold? }
|
|
1003
|
-
|
|
1004
|
-
context 'when ENV exists' do
|
|
1005
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_SLOW_TEST_FILE_THRESHOLD' => '2' }) }
|
|
1006
|
-
it { should be true }
|
|
1007
|
-
end
|
|
1008
|
-
|
|
1009
|
-
context "when ENV doesn't exist" do
|
|
1010
|
-
before { stub_const("ENV", {}) }
|
|
1011
|
-
it { should be false }
|
|
1012
|
-
end
|
|
1013
|
-
end
|
|
1014
|
-
|
|
1015
|
-
describe '.test_suite_token' do
|
|
1016
|
-
subject { described_class.test_suite_token }
|
|
1017
|
-
|
|
1018
|
-
context 'when ENV exists' do
|
|
1019
|
-
let(:token) { 'xyz' }
|
|
1020
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN' => 'xyz' }) }
|
|
1021
|
-
it { should eq token }
|
|
1022
|
-
end
|
|
1023
|
-
|
|
1024
|
-
context "when ENV doesn't exist" do
|
|
1025
|
-
it do
|
|
1026
|
-
expect { subject }.to raise_error('Missing environment variable KNAPSACK_PRO_TEST_SUITE_TOKEN. You should set environment variable like KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC (note there is suffix _RSPEC at the end). knapsack_pro gem will set KNAPSACK_PRO_TEST_SUITE_TOKEN based on KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC value. If you use other test runner than RSpec then use proper suffix.')
|
|
1027
|
-
end
|
|
1028
|
-
end
|
|
1029
|
-
end
|
|
1030
|
-
|
|
1031
|
-
describe '.test_suite_token_rspec' do
|
|
1032
|
-
subject { described_class.test_suite_token_rspec }
|
|
1033
|
-
|
|
1034
|
-
context 'when ENV exists' do
|
|
1035
|
-
let(:test_suite_token_rspec) { 'rspec-token' }
|
|
1036
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC' => test_suite_token_rspec }) }
|
|
1037
|
-
it { should eq test_suite_token_rspec }
|
|
1038
|
-
end
|
|
1039
|
-
|
|
1040
|
-
context "when ENV doesn't exist" do
|
|
1041
|
-
it { should be_nil }
|
|
1042
|
-
end
|
|
1043
|
-
end
|
|
1044
|
-
|
|
1045
|
-
describe '.test_suite_token_minitest' do
|
|
1046
|
-
subject { described_class.test_suite_token_minitest }
|
|
1047
|
-
|
|
1048
|
-
context 'when ENV exists' do
|
|
1049
|
-
let(:test_suite_token_minitest) { 'minitest-token' }
|
|
1050
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST' => test_suite_token_minitest }) }
|
|
1051
|
-
it { should eq test_suite_token_minitest }
|
|
1052
|
-
end
|
|
1053
|
-
|
|
1054
|
-
context "when ENV doesn't exist" do
|
|
1055
|
-
it { should be_nil }
|
|
1056
|
-
end
|
|
1057
|
-
end
|
|
1058
|
-
|
|
1059
|
-
describe '.test_suite_token_test_unit' do
|
|
1060
|
-
subject { described_class.test_suite_token_test_unit }
|
|
1061
|
-
|
|
1062
|
-
context 'when ENV exists' do
|
|
1063
|
-
let(:test_suite_token_test_unit) { 'test-unit-token' }
|
|
1064
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_TEST_UNIT' => test_suite_token_test_unit }) }
|
|
1065
|
-
it { should eq test_suite_token_test_unit }
|
|
1066
|
-
end
|
|
1067
|
-
|
|
1068
|
-
context "when ENV doesn't exist" do
|
|
1069
|
-
it { should be_nil }
|
|
1070
|
-
end
|
|
1071
|
-
end
|
|
1072
|
-
|
|
1073
|
-
describe '.test_suite_token_cucumber' do
|
|
1074
|
-
subject { described_class.test_suite_token_cucumber }
|
|
1075
|
-
|
|
1076
|
-
context 'when ENV exists' do
|
|
1077
|
-
let(:test_suite_token_cucumber) { 'cucumber-token' }
|
|
1078
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER' => test_suite_token_cucumber }) }
|
|
1079
|
-
it { should eq test_suite_token_cucumber }
|
|
1080
|
-
end
|
|
1081
|
-
|
|
1082
|
-
context "when ENV doesn't exist" do
|
|
1083
|
-
it { should be_nil }
|
|
1084
|
-
end
|
|
1085
|
-
end
|
|
1086
|
-
|
|
1087
|
-
describe '.test_suite_token_spinach' do
|
|
1088
|
-
subject { described_class.test_suite_token_spinach }
|
|
1089
|
-
|
|
1090
|
-
context 'when ENV exists' do
|
|
1091
|
-
let(:test_suite_token_spinach) { 'spinach-token' }
|
|
1092
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH' => test_suite_token_spinach }) }
|
|
1093
|
-
it { should eq test_suite_token_spinach }
|
|
1094
|
-
end
|
|
1095
|
-
|
|
1096
|
-
context "when ENV doesn't exist" do
|
|
1097
|
-
it { should be_nil }
|
|
1098
|
-
end
|
|
1099
|
-
end
|
|
1100
|
-
|
|
1101
|
-
describe '.mode' do
|
|
1102
|
-
subject { described_class.mode }
|
|
1103
|
-
|
|
1104
|
-
context 'when development mode' do
|
|
1105
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'development' }) }
|
|
1106
|
-
|
|
1107
|
-
it { should eq :development }
|
|
1108
|
-
end
|
|
1109
|
-
|
|
1110
|
-
context 'when test mode' do
|
|
1111
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'test' }) }
|
|
1112
|
-
|
|
1113
|
-
it { should eq :test }
|
|
1114
|
-
end
|
|
1115
|
-
|
|
1116
|
-
context 'when production mode' do
|
|
1117
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'production' }) }
|
|
1118
|
-
|
|
1119
|
-
it { should eq :production }
|
|
1120
|
-
end
|
|
1121
|
-
|
|
1122
|
-
context 'when fake mode' do
|
|
1123
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'fake' }) }
|
|
1124
|
-
|
|
1125
|
-
it do
|
|
1126
|
-
expect { subject }.to raise_error(ArgumentError)
|
|
1127
|
-
end
|
|
1128
|
-
end
|
|
1129
|
-
|
|
1130
|
-
context 'when blank mode' do
|
|
1131
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => '' }) }
|
|
1132
|
-
|
|
1133
|
-
it do
|
|
1134
|
-
expect { subject }.to raise_error(ArgumentError)
|
|
1135
|
-
end
|
|
1136
|
-
end
|
|
1137
|
-
|
|
1138
|
-
context "when ENV doesn't exist" do
|
|
1139
|
-
it { should eq :production }
|
|
1140
|
-
end
|
|
1141
|
-
end
|
|
1142
|
-
|
|
1143
|
-
describe '.log_level' do
|
|
1144
|
-
subject { described_class.log_level }
|
|
1145
|
-
|
|
1146
|
-
context 'when ENV set to fatal' do
|
|
1147
|
-
let(:log_level) { 'fatal' }
|
|
1148
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
|
1149
|
-
it { should eql ::Logger::FATAL }
|
|
1150
|
-
end
|
|
1151
|
-
|
|
1152
|
-
context 'when ENV set to error' do
|
|
1153
|
-
let(:log_level) { 'error' }
|
|
1154
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
|
1155
|
-
it { should eql ::Logger::ERROR }
|
|
1156
|
-
end
|
|
1157
|
-
|
|
1158
|
-
context 'when ENV set to warn' do
|
|
1159
|
-
let(:log_level) { 'warn' }
|
|
1160
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
|
1161
|
-
it { should eql ::Logger::WARN }
|
|
1162
|
-
end
|
|
1163
|
-
|
|
1164
|
-
context 'when ENV set to info' do
|
|
1165
|
-
let(:log_level) { 'info' }
|
|
1166
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
|
1167
|
-
it { should eql ::Logger::INFO }
|
|
1168
|
-
end
|
|
1169
|
-
|
|
1170
|
-
context 'when ENV set with capital letters' do
|
|
1171
|
-
let(:log_level) { 'WARN' }
|
|
1172
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_LEVEL' => log_level }) }
|
|
1173
|
-
it { should eql ::Logger::WARN }
|
|
1174
|
-
end
|
|
1175
|
-
|
|
1176
|
-
context "when ENV doesn't exist" do
|
|
1177
|
-
it { should eql ::Logger::INFO }
|
|
1178
|
-
end
|
|
1179
|
-
end
|
|
1180
|
-
|
|
1181
|
-
describe '.log_dir' do
|
|
1182
|
-
subject { described_class.log_dir }
|
|
1183
|
-
|
|
1184
|
-
context 'when ENV set to directory path' do
|
|
1185
|
-
let(:log_dir) { 'log' }
|
|
1186
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_LOG_DIR' => log_dir }) }
|
|
1187
|
-
it { should eql 'log' }
|
|
1188
|
-
end
|
|
1189
|
-
|
|
1190
|
-
context "when ENV doesn't exist" do
|
|
1191
|
-
it { should be_nil }
|
|
1192
|
-
end
|
|
1193
|
-
end
|
|
1194
|
-
|
|
1195
|
-
describe '.test_runner_adapter' do
|
|
1196
|
-
subject { described_class.test_runner_adapter }
|
|
1197
|
-
|
|
1198
|
-
context 'when ENV exists' do
|
|
1199
|
-
let(:test_runner_adapter) { 'RSpecAdapter' }
|
|
1200
|
-
before { stub_const('ENV', { 'KNAPSACK_PRO_TEST_RUNNER_ADAPTER' => test_runner_adapter }) }
|
|
1201
|
-
it { should eql 'RSpecAdapter' }
|
|
1202
|
-
end
|
|
1203
|
-
|
|
1204
|
-
context "when ENV doesn't exist" do
|
|
1205
|
-
it { should be_nil }
|
|
1206
|
-
end
|
|
1207
|
-
end
|
|
1208
|
-
|
|
1209
|
-
describe '.set_test_runner_adapter' do
|
|
1210
|
-
let(:adapter_class) { KnapsackPro::Adapters::RSpecAdapter }
|
|
1211
|
-
|
|
1212
|
-
subject { described_class.set_test_runner_adapter(adapter_class) }
|
|
1213
|
-
|
|
1214
|
-
it 'sets test runner adapter' do
|
|
1215
|
-
subject
|
|
1216
|
-
expect(described_class.test_runner_adapter).to eql 'RSpecAdapter'
|
|
1217
|
-
end
|
|
1218
|
-
end
|
|
1219
|
-
|
|
1220
|
-
describe '.detected_ci' do
|
|
1221
|
-
[
|
|
1222
|
-
['AppVeyor', { 'APPVEYOR' => '123' }, KnapsackPro::Config::CI::AppVeyor],
|
|
1223
|
-
['Buildkite', { 'BUILDKITE' => 'true' }, KnapsackPro::Config::CI::Buildkite],
|
|
1224
|
-
['CircleCI', { 'CIRCLECI' => 'true' }, KnapsackPro::Config::CI::Circle],
|
|
1225
|
-
['Cirrus CI', { 'CIRRUS_CI' => 'true' }, KnapsackPro::Config::CI::CirrusCI],
|
|
1226
|
-
['Codefresh', { 'CF_BUILD_ID' => '123' }, KnapsackPro::Config::CI::Codefresh],
|
|
1227
|
-
['Codeship', { 'CI_NAME' => 'codeship' }, KnapsackPro::Config::CI::Codeship],
|
|
1228
|
-
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }, KnapsackPro::Config::CI::GithubActions],
|
|
1229
|
-
['GitLab CI', { 'GITLAB_CI' => 'true' }, KnapsackPro::Config::CI::GitlabCI],
|
|
1230
|
-
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }, KnapsackPro::Config::CI::Heroku],
|
|
1231
|
-
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }, KnapsackPro::Config::CI::Semaphore],
|
|
1232
|
-
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }, KnapsackPro::Config::CI::Semaphore2],
|
|
1233
|
-
['Travis CI', { 'TRAVIS' => 'true' }, KnapsackPro::Config::CI::Travis],
|
|
1234
|
-
['Unsupported CI', {}, KnapsackPro::Config::CI::Base],
|
|
1235
|
-
].each do |ci, env, expected|
|
|
1236
|
-
it "detects #{ci}" do
|
|
1237
|
-
stub_const("ENV", env)
|
|
1238
|
-
|
|
1239
|
-
expect(described_class.detected_ci).to eq(expected)
|
|
1240
|
-
end
|
|
1241
|
-
end
|
|
1242
|
-
end
|
|
1243
|
-
|
|
1244
|
-
describe '.ci?' do
|
|
1245
|
-
[
|
|
1246
|
-
['CI from env', { 'CI' => 'True' }, true],
|
|
1247
|
-
['Travis CI', { 'TRAVIS' => 'true' }, true],
|
|
1248
|
-
['missing CI from ENV or development', {}, false],
|
|
1249
|
-
].each do |ci, env, expected|
|
|
1250
|
-
it "detects #{ci}" do
|
|
1251
|
-
stub_const("ENV", env)
|
|
1252
|
-
|
|
1253
|
-
expect(described_class.ci?).to eq(expected)
|
|
1254
|
-
end
|
|
1255
|
-
end
|
|
1256
|
-
end
|
|
1257
|
-
|
|
1258
|
-
describe '.ci_provider' do
|
|
1259
|
-
[
|
|
1260
|
-
['AppVeyor', { 'APPVEYOR' => '123' }],
|
|
1261
|
-
['Azure Pipelines', { 'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI' => '123' }],
|
|
1262
|
-
['AWS CodeBuild', { 'CODEBUILD_BUILD_ARN' => '123' }],
|
|
1263
|
-
['Bamboo', { 'bamboo_planKey' => '123' }],
|
|
1264
|
-
['Bitbucket Pipelines', { 'BITBUCKET_COMMIT' => '123' }],
|
|
1265
|
-
['Buddy.works', { 'BUDDY' => 'true' }],
|
|
1266
|
-
['Buildkite', { 'BUILDKITE' => 'true' }],
|
|
1267
|
-
['CircleCI', { 'CIRCLECI' => 'true' }],
|
|
1268
|
-
['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
|
|
1269
|
-
['Codefresh', { 'CF_BUILD_ID' => '123' }],
|
|
1270
|
-
['Codeship', { 'CI_NAME' => 'codeship' }],
|
|
1271
|
-
['Drone.io', { 'DRONE' => 'true' }],
|
|
1272
|
-
['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
|
|
1273
|
-
['Gitlab CI', { 'GITLAB_CI' => 'true' }],
|
|
1274
|
-
['Google Cloud Build', { 'BUILDER_OUTPUT' => '123' }],
|
|
1275
|
-
['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
|
|
1276
|
-
['Jenkins', { 'JENKINS_URL' => '123' }],
|
|
1277
|
-
['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
|
|
1278
|
-
['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
|
|
1279
|
-
['TeamCity', { 'TEAMCITY_VERSION' => '123' }],
|
|
1280
|
-
['Travis CI', { 'TRAVIS' => 'true' }],
|
|
1281
|
-
['Other', { 'CI' => 'true'}],
|
|
1282
|
-
[nil, {}],
|
|
1283
|
-
].each do |ci, env|
|
|
1284
|
-
it "detects #{ci || 'missing CI from env or development'}" do
|
|
1285
|
-
stub_const("ENV", env)
|
|
1286
|
-
|
|
1287
|
-
expect(described_class.ci_provider).to eq(ci)
|
|
1288
|
-
end
|
|
1289
|
-
end
|
|
1290
|
-
end
|
|
1291
|
-
end
|