knapsack_pro 8.3.2 → 8.4.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.
@@ -9,48 +9,46 @@ describe KnapsackPro::Config::Env do
9
9
  describe '.ci_node_total' do
10
10
  subject { described_class.ci_node_total }
11
11
 
12
- context 'when ENV exists' do
13
- context 'when KNAPSACK_PRO_CI_NODE_TOTAL has value' do
14
- before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => '5' }) }
15
- it { should eq 5 }
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)
16
20
  end
17
21
 
18
- context 'when CI environment has value' do
19
- before do
20
- expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(4)
21
- end
22
+ it { should eq 4 }
23
+ end
22
24
 
23
- it { should eq 4 }
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)
24
29
  end
25
30
 
26
- context 'when both KNAPSACK_PRO_CI_NODE_TOTAL and CI environment have value' do
27
- before do
28
- stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_TOTAL' => env_value })
29
- expect(described_class).to receive(:ci_env_for).with(:node_total).and_return(ci_value)
30
- end
31
-
32
- context 'when values are different' do
33
- let(:env_value) { '5' }
34
- let(:ci_value) { 4 }
31
+ context 'when values are different' do
32
+ let(:env_value) { '5' }
33
+ let(:ci_value) { 4 }
35
34
 
36
- it { should eq 5 }
35
+ it { should eq 5 }
37
36
 
38
- it 'logs a warning' do
39
- expect(described_class).to receive(:warn).with(
40
- 'You have set the environment variable KNAPSACK_PRO_CI_NODE_TOTAL to 5 which could be automatically determined from the CI environment as 4.'
41
- )
42
- subject
43
- end
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
44
42
  end
43
+ end
45
44
 
46
- context 'when values are the same' do
47
- let(:env_value) { '5' }
48
- let(:ci_value) { 5 }
45
+ context 'when values are the same' do
46
+ let(:env_value) { '5' }
47
+ let(:ci_value) { 5 }
49
48
 
50
- it 'does not log a warning' do
51
- expect(described_class).not_to receive(:warn)
52
- subject
53
- end
49
+ it 'does not log a warning' do
50
+ expect(described_class).not_to receive(:warn)
51
+ subject
54
52
  end
55
53
  end
56
54
  end
@@ -63,56 +61,54 @@ describe KnapsackPro::Config::Env do
63
61
  describe '.ci_node_index' do
64
62
  subject { described_class.ci_node_index }
65
63
 
66
- context 'when ENV exists' do
67
- context 'when KNAPSACK_PRO_CI_NODE_INDEX has value' do
68
- before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => '3' }) }
69
- it { should eq 3 }
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)
70
72
  end
71
73
 
72
- context 'when CI environment has value' do
73
- before do
74
- expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(2)
75
- end
74
+ it { should eq 2 }
75
+ end
76
76
 
77
- it { should eq 2 }
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)
78
81
  end
79
82
 
80
- context 'when both KNAPSACK_PRO_CI_NODE_INDEX and CI environment have value' do
81
- before do
82
- stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_INDEX' => env_value })
83
- expect(described_class).to receive(:ci_env_for).with(:node_index).and_return(ci_value)
84
- end
85
-
86
- context 'when values are different' do
87
- let(:env_value) { '3' }
88
- let(:ci_value) { 2 }
83
+ context 'when values are different' do
84
+ let(:env_value) { '3' }
85
+ let(:ci_value) { 2 }
89
86
 
90
- it { should eq 3 }
87
+ it { should eq 3 }
91
88
 
92
- it 'logs a warning' do
93
- expect(described_class).to receive(:warn).with(
94
- 'You have set the environment variable KNAPSACK_PRO_CI_NODE_INDEX to 3 which could be automatically determined from the CI environment as 2.'
95
- )
96
- subject
97
- end
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
98
94
  end
95
+ end
99
96
 
100
- context 'when values are the same' do
101
- let(:env_value) { '3' }
102
- let(:ci_value) { 3 }
97
+ context 'when values are the same' do
98
+ let(:env_value) { '3' }
99
+ let(:ci_value) { 3 }
103
100
 
104
- it 'does not log a warning' do
105
- expect(described_class).not_to receive(:warn)
106
- subject
107
- end
101
+ it 'does not log a warning' do
102
+ expect(described_class).not_to receive(:warn)
103
+ subject
108
104
  end
109
105
  end
106
+ end
110
107
 
111
- context 'when order of loading envs does matter' do
112
- context 'when GitLab CI' do
113
- before { stub_const("ENV", { 'CI_NODE_INDEX' => '2', 'GITLAB_CI' => 'true' }) }
114
- it { should eq 1 }
115
- end
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 }
116
112
  end
117
113
  end
118
114
 
@@ -124,48 +120,46 @@ describe KnapsackPro::Config::Env do
124
120
  describe '.ci_node_build_id' do
125
121
  subject { described_class.ci_node_build_id }
126
122
 
127
- context 'when ENV exists' do
128
- context 'when KNAPSACK_PRO_CI_NODE_BUILD_ID has value' do
129
- before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => '7' }) }
130
- it { should eq '7' }
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
131
  end
132
132
 
133
- context 'when CI environment has value' do
134
- before do
135
- expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return('8')
136
- end
133
+ it { should eq '8' }
134
+ end
137
135
 
138
- it { should eq '8' }
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)
139
140
  end
140
141
 
141
- context 'when both KNAPSACK_PRO_CI_NODE_BUILD_ID and CI environment have value' do
142
- before do
143
- stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_BUILD_ID' => env_value })
144
- expect(described_class).to receive(:ci_env_for).with(:node_build_id).and_return(ci_value)
145
- end
146
-
147
- context 'when values are different' do
148
- let(:env_value) { '7' }
149
- let(:ci_value) { '8' }
142
+ context 'when values are different' do
143
+ let(:env_value) { '7' }
144
+ let(:ci_value) { '8' }
150
145
 
151
- it { should eq '7' }
146
+ it { should eq '7' }
152
147
 
153
- it 'logs a warning' do
154
- expect(described_class).to receive(:warn).with(
155
- '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.'
156
- )
157
- subject
158
- end
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
159
153
  end
154
+ end
160
155
 
161
- context 'when values are the same' do
162
- let(:env_value) { '7' }
163
- let(:ci_value) { '7' }
156
+ context 'when values are the same' do
157
+ let(:env_value) { '7' }
158
+ let(:ci_value) { '7' }
164
159
 
165
- it 'does not log a warning' do
166
- expect(described_class).not_to receive(:warn)
167
- subject
168
- end
160
+ it 'does not log a warning' do
161
+ expect(described_class).not_to receive(:warn)
162
+ subject
169
163
  end
170
164
  end
171
165
  end
@@ -180,48 +174,46 @@ describe KnapsackPro::Config::Env do
180
174
  describe '.ci_node_retry_count' do
181
175
  subject { described_class.ci_node_retry_count }
182
176
 
183
- context 'when ENV exists' do
184
- context 'when KNAPSACK_PRO_CI_NODE_RETRY_COUNT has value' do
185
- before { stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => '1' }) }
186
- it { should eq 1 }
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')
187
185
  end
188
186
 
189
- context 'when CI environment has value' do
190
- before do
191
- expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return('2')
192
- end
187
+ it { should eq 2 }
188
+ end
193
189
 
194
- it { should eq 2 }
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)
195
194
  end
196
195
 
197
- context 'when both KNAPSACK_PRO_CI_NODE_RETRY_COUNT and CI environment have value' do
198
- before do
199
- stub_const("ENV", { 'KNAPSACK_PRO_CI_NODE_RETRY_COUNT' => env_value })
200
- expect(described_class).to receive(:ci_env_for).with(:node_retry_count).and_return(ci_value)
201
- end
202
-
203
- context 'when values are different' do
204
- let(:env_value) { '1' }
205
- let(:ci_value) { 2 }
196
+ context 'when values are different' do
197
+ let(:env_value) { '1' }
198
+ let(:ci_value) { 2 }
206
199
 
207
- it { should eq 1 }
200
+ it { should eq 1 }
208
201
 
209
- it 'logs a warning' do
210
- expect(described_class).to receive(:warn).with(
211
- '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.'
212
- )
213
- subject
214
- end
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
215
207
  end
208
+ end
216
209
 
217
- context 'when values are the same' do
218
- let(:env_value) { '7' }
219
- let(:ci_value) { '7' }
210
+ context 'when values are the same' do
211
+ let(:env_value) { '7' }
212
+ let(:ci_value) { '7' }
220
213
 
221
- it 'does not log a warning' do
222
- expect(described_class).not_to receive(:warn)
223
- subject
224
- end
214
+ it 'does not log a warning' do
215
+ expect(described_class).not_to receive(:warn)
216
+ subject
225
217
  end
226
218
  end
227
219
  end
@@ -247,48 +239,46 @@ describe KnapsackPro::Config::Env do
247
239
  describe '.commit_hash' do
248
240
  subject { described_class.commit_hash }
249
241
 
250
- context 'when ENV exists' do
251
- context 'when KNAPSACK_PRO_COMMIT_HASH has value' do
252
- before { stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => '3fa64859337f6e56409d49f865d13fd7' }) }
253
- it { should eq '3fa64859337f6e56409d49f865d13fd7' }
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')
254
250
  end
255
251
 
256
- context 'when CI environment has value' do
257
- before do
258
- expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return('fe61a08118d0d52e97c38666eba1eaf3')
259
- end
252
+ it { should eq 'fe61a08118d0d52e97c38666eba1eaf3' }
253
+ end
260
254
 
261
- it { should eq 'fe61a08118d0d52e97c38666eba1eaf3' }
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)
262
259
  end
263
260
 
264
- context 'when both KNAPSACK_PRO_COMMIT_HASH and CI environment have value' do
265
- before do
266
- stub_const("ENV", { 'KNAPSACK_PRO_COMMIT_HASH' => env_value })
267
- expect(described_class).to receive(:ci_env_for).with(:commit_hash).and_return(ci_value)
268
- end
269
-
270
- context 'when values are different' do
271
- let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
272
- let(:ci_value) { 'fe61a08118d0d52e97c38666eba1eaf3' }
261
+ context 'when values are different' do
262
+ let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
263
+ let(:ci_value) { 'fe61a08118d0d52e97c38666eba1eaf3' }
273
264
 
274
- it { should eq '3fa64859337f6e56409d49f865d13fd7' }
265
+ it { should eq '3fa64859337f6e56409d49f865d13fd7' }
275
266
 
276
- it 'logs a warning' do
277
- expect(described_class).to receive(:warn).with(
278
- 'You have set the environment variable KNAPSACK_PRO_COMMIT_HASH to 3fa64859337f6e56409d49f865d13fd7 which could be automatically determined from the CI environment as fe61a08118d0d52e97c38666eba1eaf3.'
279
- )
280
- subject
281
- end
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
282
272
  end
273
+ end
283
274
 
284
- context 'when values are the same' do
285
- let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
286
- let(:ci_value) { '3fa64859337f6e56409d49f865d13fd7' }
275
+ context 'when values are the same' do
276
+ let(:env_value) { '3fa64859337f6e56409d49f865d13fd7' }
277
+ let(:ci_value) { '3fa64859337f6e56409d49f865d13fd7' }
287
278
 
288
- it 'does not log a warning' do
289
- expect(described_class).not_to receive(:warn)
290
- subject
291
- end
279
+ it 'does not log a warning' do
280
+ expect(described_class).not_to receive(:warn)
281
+ subject
292
282
  end
293
283
  end
294
284
  end
@@ -301,48 +291,46 @@ describe KnapsackPro::Config::Env do
301
291
  describe '.branch' do
302
292
  subject { described_class.branch }
303
293
 
304
- context 'when ENV exists' do
305
- context 'when KNAPSACK_PRO_BRANCH has value' do
306
- before { stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => 'main' }) }
307
- it { should eq 'main' }
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')
308
302
  end
309
303
 
310
- context 'when CI environment has value' do
311
- before do
312
- expect(described_class).to receive(:ci_env_for).with(:branch).and_return('feature-branch')
313
- end
304
+ it { should eq 'feature-branch' }
305
+ end
314
306
 
315
- it { should eq 'feature-branch' }
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)
316
311
  end
317
312
 
318
- context 'when both KNAPSACK_PRO_BRANCH and CI environment have value' do
319
- before do
320
- stub_const("ENV", { 'KNAPSACK_PRO_BRANCH' => env_value })
321
- expect(described_class).to receive(:ci_env_for).with(:branch).and_return(ci_value)
322
- end
323
-
324
- context 'when values are different' do
325
- let(:env_value) { 'main' }
326
- let(:ci_value) { 'feature-branch' }
313
+ context 'when values are different' do
314
+ let(:env_value) { 'main' }
315
+ let(:ci_value) { 'feature-branch' }
327
316
 
328
- it { should eq 'main' }
317
+ it { should eq 'main' }
329
318
 
330
- it 'logs a warning' do
331
- expect(described_class).to receive(:warn).with(
332
- 'You have set the environment variable KNAPSACK_PRO_BRANCH to main which could be automatically determined from the CI environment as feature-branch.'
333
- )
334
- subject
335
- end
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
336
324
  end
325
+ end
337
326
 
338
- context 'when values are the same' do
339
- let(:env_value) { 'main' }
340
- let(:ci_value) { 'main' }
327
+ context 'when values are the same' do
328
+ let(:env_value) { 'main' }
329
+ let(:ci_value) { 'main' }
341
330
 
342
- it 'does not log a warning' do
343
- expect(described_class).not_to receive(:warn)
344
- subject
345
- end
331
+ it 'does not log a warning' do
332
+ expect(described_class).not_to receive(:warn)
333
+ subject
346
334
  end
347
335
  end
348
336
  end
@@ -355,48 +343,46 @@ describe KnapsackPro::Config::Env do
355
343
  describe '.project_dir' do
356
344
  subject { described_class.project_dir }
357
345
 
358
- context 'when ENV exists' do
359
- context 'when KNAPSACK_PRO_PROJECT_DIR has value' do
360
- before { stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => '/home/user/myapp' }) }
361
- it { should eq '/home/user/myapp' }
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')
362
354
  end
363
355
 
364
- context 'when CI environment has value' do
365
- before do
366
- expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return('/home/runner/myapp')
367
- end
356
+ it { should eq '/home/runner/myapp' }
357
+ end
368
358
 
369
- it { should eq '/home/runner/myapp' }
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)
370
363
  end
371
364
 
372
- context 'when both KNAPSACK_PRO_PROJECT_DIR and CI environment have value' do
373
- before do
374
- stub_const("ENV", { 'KNAPSACK_PRO_PROJECT_DIR' => env_value })
375
- expect(described_class).to receive(:ci_env_for).with(:project_dir).and_return(ci_value)
376
- end
377
-
378
- context 'when values are different' do
379
- let(:env_value) { '/home/user/myapp' }
380
- let(:ci_value) { '/home/runner/myapp' }
365
+ context 'when values are different' do
366
+ let(:env_value) { '/home/user/myapp' }
367
+ let(:ci_value) { '/home/runner/myapp' }
381
368
 
382
- it { should eq '/home/user/myapp' }
369
+ it { should eq '/home/user/myapp' }
383
370
 
384
- it 'logs a warning' do
385
- expect(described_class).to receive(:warn).with(
386
- '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.'
387
- )
388
- subject
389
- end
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
390
376
  end
377
+ end
391
378
 
392
- context 'when values are the same' do
393
- let(:env_value) { '/home/user/myapp' }
394
- let(:ci_value) { '/home/user/myapp' }
379
+ context 'when values are the same' do
380
+ let(:env_value) { '/home/user/myapp' }
381
+ let(:ci_value) { '/home/user/myapp' }
395
382
 
396
- it 'does not log a warning' do
397
- expect(described_class).not_to receive(:warn)
398
- subject
399
- end
383
+ it 'does not log a warning' do
384
+ expect(described_class).not_to receive(:warn)
385
+ subject
400
386
  end
401
387
  end
402
388
  end
@@ -409,48 +395,46 @@ describe KnapsackPro::Config::Env do
409
395
  describe '.user_seat' do
410
396
  subject { described_class.user_seat }
411
397
 
412
- context 'when ENV exists' do
413
- context 'when KNAPSACK_PRO_USER_SEAT has value' do
414
- before { stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => 'John Doe' }) }
415
- it { should eq 'John Doe' }
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')
416
406
  end
417
407
 
418
- context 'when CI environment has value' do
419
- before do
420
- expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return('Jane Doe')
421
- end
408
+ it { should eq 'Jane Doe' }
409
+ end
422
410
 
423
- it { should eq 'Jane Doe' }
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)
424
415
  end
425
416
 
426
- context 'when both KNAPSACK_PRO_USER_SEAT and CI environment have value' do
427
- before do
428
- stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => env_value })
429
- expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return(ci_value)
430
- end
417
+ context 'when values are different' do
418
+ let(:env_value) { 'John Doe' }
419
+ let(:ci_value) { 'Jane Doe' }
431
420
 
432
- context 'when values are different' do
433
- let(:env_value) { 'John Doe' }
434
- let(:ci_value) { 'Jane Doe' }
435
-
436
- it { should eq 'John Doe' }
421
+ it { should eq 'John Doe' }
437
422
 
438
- it 'logs a warning' do
439
- expect(described_class).to receive(:warn).with(
440
- '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.'
441
- )
442
- subject
443
- end
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
444
428
  end
429
+ end
445
430
 
446
- context 'when values are the same' do
447
- let(:env_value) { 'John Doe' }
448
- let(:ci_value) { 'John Doe' }
431
+ context 'when values are the same' do
432
+ let(:env_value) { 'John Doe' }
433
+ let(:ci_value) { 'John Doe' }
449
434
 
450
- it 'does not log a warning' do
451
- expect(described_class).not_to receive(:warn)
452
- subject
453
- end
435
+ it 'does not log a warning' do
436
+ expect(described_class).not_to receive(:warn)
437
+ subject
454
438
  end
455
439
  end
456
440
  end
@@ -811,16 +795,14 @@ describe KnapsackPro::Config::Env do
811
795
  describe '.fixed_test_suite_split?' do
812
796
  subject { described_class.fixed_test_suite_split? }
813
797
 
814
- context 'when ENV exists' do
815
- context 'when KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true' do
816
- before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT' => 'true' }) }
817
- it { should be true }
818
- end
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
819
802
 
820
- context 'when KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=false' do
821
- before { stub_const("ENV", { 'KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT' => 'false' }) }
822
- it { should be false }
823
- end
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 }
824
806
  end
825
807
 
826
808
  context "when ENV doesn't exist" do
@@ -833,70 +815,68 @@ describe KnapsackPro::Config::Env do
833
815
  subject { described_class.fixed_queue_split? }
834
816
  after(:each) { described_class.remove_instance_variable(:@fixed_queue_split) }
835
817
 
836
- context 'when ENV exists' do
837
- context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=false' do
838
- [
839
- ['AppVeyor', { 'APPVEYOR' => '123' }],
840
- ['Buildkite', { 'BUILDKITE' => 'true' }],
841
- ['CircleCI', { 'CIRCLECI' => 'true' }],
842
- ['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
843
- ['Codefresh', { 'CF_BUILD_ID' => '123' }],
844
- ['Codeship', { 'CI_NAME' => 'codeship' }],
845
- ['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
846
- ['GitLab CI', { 'GITLAB_CI' => 'true' }],
847
- ['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
848
- ['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
849
- ['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
850
- ['Travis CI', { 'TRAVIS' => 'true' }],
851
- ['Unsupported CI', {}],
852
- ].each do |ci, env|
853
- it "on #{ci} it is false" do
854
- stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'false' }))
855
-
856
- ci_env = described_class.detected_ci.new.fixed_queue_split
857
- if ci_env == false
858
- expect(described_class).not_to receive(:warn)
859
- else
860
- expect(described_class).to receive(:warn).with(
861
- 'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to false which could be automatically determined from the CI environment as true.'
862
- )
863
- end
864
-
865
- expect(subject).to eq(false)
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
+ )
866
844
  end
845
+
846
+ expect(subject).to eq(false)
867
847
  end
868
848
  end
849
+ end
869
850
 
870
- context 'when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true' do
871
- [
872
- ['AppVeyor', { 'APPVEYOR' => '123' }],
873
- ['Buildkite', { 'BUILDKITE' => 'true' }],
874
- ['CircleCI', { 'CIRCLECI' => 'true' }],
875
- ['Cirrus CI', { 'CIRRUS_CI' => 'true' }],
876
- ['Codefresh', { 'CF_BUILD_ID' => '123' }],
877
- ['Codeship', { 'CI_NAME' => 'codeship' }],
878
- ['GitHub Actions', { 'GITHUB_ACTIONS' => 'true' }],
879
- ['GitLab CI', { 'GITLAB_CI' => 'true' }],
880
- ['Heroku CI', { 'HEROKU_TEST_RUN_ID' => '123' }],
881
- ['Semaphore CI 1.0', { 'SEMAPHORE_BUILD_NUMBER' => '123' }],
882
- ['Semaphore CI 2.0', { 'SEMAPHORE' => 'true', 'SEMAPHORE_WORKFLOW_ID' => '123' }],
883
- ['Travis CI', { 'TRAVIS' => 'true' }],
884
- ['Unsupported CI', {}],
885
- ].each do |ci, env|
886
- it "on #{ci} it is true" do
887
- stub_const("ENV", env.merge({ 'KNAPSACK_PRO_FIXED_QUEUE_SPLIT' => 'true' }))
888
-
889
- ci_env = described_class.detected_ci.new.fixed_queue_split
890
- if ci_env == true
891
- expect(described_class).not_to receive(:warn)
892
- else
893
- expect(described_class).to receive(:warn).with(
894
- 'You have set the environment variable KNAPSACK_PRO_FIXED_QUEUE_SPLIT to true which could be automatically determined from the CI environment as false.'
895
- )
896
- end
897
-
898
- expect(subject).to eq(true)
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
+ )
899
877
  end
878
+
879
+ expect(subject).to eq(true)
900
880
  end
901
881
  end
902
882
  end
@@ -1121,39 +1101,37 @@ describe KnapsackPro::Config::Env do
1121
1101
  describe '.mode' do
1122
1102
  subject { described_class.mode }
1123
1103
 
1124
- context 'when ENV exists' do
1125
- context 'when development mode' do
1126
- before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'development' }) }
1104
+ context 'when development mode' do
1105
+ before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'development' }) }
1127
1106
 
1128
- it { should eq :development }
1129
- end
1107
+ it { should eq :development }
1108
+ end
1130
1109
 
1131
- context 'when test mode' do
1132
- before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'test' }) }
1110
+ context 'when test mode' do
1111
+ before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'test' }) }
1133
1112
 
1134
- it { should eq :test }
1135
- end
1113
+ it { should eq :test }
1114
+ end
1136
1115
 
1137
- context 'when production mode' do
1138
- before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'production' }) }
1116
+ context 'when production mode' do
1117
+ before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'production' }) }
1139
1118
 
1140
- it { should eq :production }
1141
- end
1119
+ it { should eq :production }
1120
+ end
1142
1121
 
1143
- context 'when fake mode' do
1144
- before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'fake' }) }
1122
+ context 'when fake mode' do
1123
+ before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => 'fake' }) }
1145
1124
 
1146
- it do
1147
- expect { subject }.to raise_error(ArgumentError)
1148
- end
1125
+ it do
1126
+ expect { subject }.to raise_error(ArgumentError)
1149
1127
  end
1128
+ end
1150
1129
 
1151
- context 'when blank mode' do
1152
- before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => '' }) }
1130
+ context 'when blank mode' do
1131
+ before { stub_const("ENV", { 'KNAPSACK_PRO_MODE' => '' }) }
1153
1132
 
1154
- it do
1155
- expect { subject }.to raise_error(ArgumentError)
1156
- end
1133
+ it do
1134
+ expect { subject }.to raise_error(ArgumentError)
1157
1135
  end
1158
1136
  end
1159
1137