knapsack_pro 3.8.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +377 -23
  3. data/.github/dependabot.yml +11 -0
  4. data/.github/pull_request_template.md +22 -0
  5. data/.gitignore +4 -0
  6. data/CHANGELOG.md +325 -1
  7. data/Gemfile +9 -0
  8. data/README.md +3 -10
  9. data/bin/test +15 -0
  10. data/knapsack_pro.gemspec +7 -6
  11. data/lib/knapsack_pro/adapters/base_adapter.rb +17 -2
  12. data/lib/knapsack_pro/adapters/cucumber_adapter.rb +3 -3
  13. data/lib/knapsack_pro/adapters/minitest_adapter.rb +2 -0
  14. data/lib/knapsack_pro/adapters/rspec_adapter.rb +88 -49
  15. data/lib/knapsack_pro/adapters/spinach_adapter.rb +2 -0
  16. data/lib/knapsack_pro/adapters/test_unit_adapter.rb +2 -0
  17. data/lib/knapsack_pro/allocator.rb +2 -0
  18. data/lib/knapsack_pro/allocator_builder.rb +2 -0
  19. data/lib/knapsack_pro/base_allocator_builder.rb +8 -25
  20. data/lib/knapsack_pro/build_distribution_fetcher.rb +2 -0
  21. data/lib/knapsack_pro/client/api/action.rb +2 -0
  22. data/lib/knapsack_pro/client/api/v1/base.rb +2 -0
  23. data/lib/knapsack_pro/client/api/v1/build_distributions.rb +5 -0
  24. data/lib/knapsack_pro/client/api/v1/build_subsets.rb +2 -0
  25. data/lib/knapsack_pro/client/api/v1/queues.rb +6 -1
  26. data/lib/knapsack_pro/client/connection.rb +5 -6
  27. data/lib/knapsack_pro/config/ci/app_veyor.rb +18 -0
  28. data/lib/knapsack_pro/config/ci/base.rb +27 -0
  29. data/lib/knapsack_pro/config/ci/buildkite.rb +18 -0
  30. data/lib/knapsack_pro/config/ci/circle.rb +18 -0
  31. data/lib/knapsack_pro/config/ci/cirrus_ci.rb +18 -0
  32. data/lib/knapsack_pro/config/ci/codefresh.rb +18 -0
  33. data/lib/knapsack_pro/config/ci/codeship.rb +18 -0
  34. data/lib/knapsack_pro/config/ci/github_actions.rb +26 -0
  35. data/lib/knapsack_pro/config/ci/gitlab_ci.rb +20 -1
  36. data/lib/knapsack_pro/config/ci/heroku.rb +18 -0
  37. data/lib/knapsack_pro/config/ci/semaphore.rb +16 -0
  38. data/lib/knapsack_pro/config/ci/semaphore2.rb +19 -0
  39. data/lib/knapsack_pro/config/ci/travis.rb +18 -0
  40. data/lib/knapsack_pro/config/env.rb +46 -22
  41. data/lib/knapsack_pro/config/env_generator.rb +2 -0
  42. data/lib/knapsack_pro/config/temp_files.rb +8 -4
  43. data/lib/knapsack_pro/crypto/branch_encryptor.rb +2 -0
  44. data/lib/knapsack_pro/crypto/decryptor.rb +2 -0
  45. data/lib/knapsack_pro/crypto/digestor.rb +2 -0
  46. data/lib/knapsack_pro/crypto/encryptor.rb +2 -0
  47. data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
  48. data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +2 -0
  49. data/lib/knapsack_pro/formatters/time_tracker.rb +152 -0
  50. data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +20 -0
  51. data/lib/knapsack_pro/hooks/queue.rb +2 -0
  52. data/lib/knapsack_pro/logger_wrapper.rb +2 -0
  53. data/lib/knapsack_pro/mask_string.rb +9 -0
  54. data/lib/knapsack_pro/presenter.rb +6 -3
  55. data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
  56. data/lib/knapsack_pro/queue_allocator.rb +2 -0
  57. data/lib/knapsack_pro/queue_allocator_builder.rb +2 -0
  58. data/lib/knapsack_pro/railtie.rb +2 -0
  59. data/lib/knapsack_pro/report.rb +15 -9
  60. data/lib/knapsack_pro/repository_adapter_initiator.rb +2 -0
  61. data/lib/knapsack_pro/repository_adapters/base_adapter.rb +2 -0
  62. data/lib/knapsack_pro/repository_adapters/env_adapter.rb +2 -0
  63. data/lib/knapsack_pro/repository_adapters/git_adapter.rb +50 -0
  64. data/lib/knapsack_pro/runners/base_runner.rb +2 -0
  65. data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -0
  66. data/lib/knapsack_pro/runners/minitest_runner.rb +2 -0
  67. data/lib/knapsack_pro/runners/queue/base_runner.rb +29 -0
  68. data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +9 -6
  69. data/lib/knapsack_pro/runners/queue/minitest_runner.rb +13 -6
  70. data/lib/knapsack_pro/runners/queue/rspec_runner.rb +128 -135
  71. data/lib/knapsack_pro/runners/rspec_runner.rb +22 -3
  72. data/lib/knapsack_pro/runners/spinach_runner.rb +2 -0
  73. data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -0
  74. data/lib/knapsack_pro/slow_test_file_determiner.rb +2 -0
  75. data/lib/knapsack_pro/slow_test_file_finder.rb +2 -0
  76. data/lib/knapsack_pro/task_loader.rb +2 -0
  77. data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +2 -0
  78. data/lib/knapsack_pro/test_case_mergers/base_merger.rb +2 -0
  79. data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +2 -0
  80. data/lib/knapsack_pro/test_file_cleaner.rb +2 -0
  81. data/lib/knapsack_pro/test_file_finder.rb +2 -0
  82. data/lib/knapsack_pro/test_file_pattern.rb +2 -0
  83. data/lib/knapsack_pro/test_file_presenter.rb +2 -0
  84. data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +2 -0
  85. data/lib/knapsack_pro/test_flat_distributor.rb +2 -0
  86. data/lib/knapsack_pro/tracker.rb +3 -3
  87. data/lib/knapsack_pro/urls.rb +4 -0
  88. data/lib/knapsack_pro/utils.rb +2 -0
  89. data/lib/knapsack_pro/version.rb +3 -1
  90. data/lib/knapsack_pro.rb +5 -3
  91. data/lib/tasks/cucumber.rake +2 -0
  92. data/lib/tasks/encrypted_branch_names.rake +2 -0
  93. data/lib/tasks/encrypted_test_file_names.rake +2 -0
  94. data/lib/tasks/minitest.rake +2 -0
  95. data/lib/tasks/queue/cucumber.rake +13 -0
  96. data/lib/tasks/queue/minitest.rake +13 -0
  97. data/lib/tasks/queue/rspec.rake +13 -0
  98. data/lib/tasks/rspec.rake +5 -0
  99. data/lib/tasks/salt.rake +2 -0
  100. data/lib/tasks/spinach.rake +2 -0
  101. data/lib/tasks/test_unit.rake +2 -0
  102. data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
  103. data/spec/integration/runners/queue/rspec_runner.rb +80 -0
  104. data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
  105. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +30 -11
  106. data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
  107. data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +146 -174
  108. data/spec/knapsack_pro/base_allocator_builder_spec.rb +22 -48
  109. data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +19 -27
  110. data/spec/knapsack_pro/client/api/v1/queues_spec.rb +23 -43
  111. data/spec/knapsack_pro/client/connection_spec.rb +59 -7
  112. data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +22 -8
  113. data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
  114. data/spec/knapsack_pro/config/ci/buildkite_spec.rb +51 -16
  115. data/spec/knapsack_pro/config/ci/circle_spec.rb +48 -13
  116. data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +12 -12
  117. data/spec/knapsack_pro/config/ci/codefresh_spec.rb +21 -6
  118. data/spec/knapsack_pro/config/ci/codeship_spec.rb +20 -6
  119. data/spec/knapsack_pro/config/ci/github_actions_spec.rb +37 -10
  120. data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +48 -13
  121. data/spec/knapsack_pro/config/ci/heroku_spec.rb +12 -12
  122. data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +11 -11
  123. data/spec/knapsack_pro/config/ci/semaphore_spec.rb +12 -12
  124. data/spec/knapsack_pro/config/ci/travis_spec.rb +8 -8
  125. data/spec/knapsack_pro/config/env_spec.rb +204 -124
  126. data/spec/knapsack_pro/formatters/time_tracker_specs.rb +424 -0
  127. data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
  128. data/spec/knapsack_pro/presenter_spec.rb +1 -1
  129. data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
  130. data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +72 -0
  131. data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +18 -16
  132. data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +17 -14
  133. data/spec/knapsack_pro/runners/rspec_runner_spec.rb +40 -23
  134. data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
  135. data/spec/knapsack_pro/tracker_spec.rb +0 -4
  136. data/spec/knapsack_pro_spec.rb +3 -3
  137. data/spec/spec_helper.rb +0 -1
  138. metadata +26 -23
  139. data/lib/knapsack_pro/config/ci/snap_ci.rb +0 -35
  140. data/lib/knapsack_pro/config/ci/solano_ci.rb +0 -32
  141. data/lib/knapsack_pro/extensions/time.rb +0 -7
  142. data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -56
  143. data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -112
  144. data/spec/knapsack_pro/config/ci/snap_ci_spec.rb +0 -104
  145. data/spec/knapsack_pro/config/ci/solano_ci_spec.rb +0 -73
  146. data/spec/knapsack_pro/extensions/time_spec.rb +0 -5
  147. data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -342
@@ -22,12 +22,12 @@ describe KnapsackPro::Config::CI::Codefresh do
22
22
  describe '#node_build_id' do
23
23
  subject { described_class.new.node_build_id }
24
24
 
25
- context 'when environment exists' do
25
+ context 'when the environment exists' do
26
26
  let(:env) { { 'CF_BUILD_ID' => '1005' } }
27
27
  it { should eql '1005' }
28
28
  end
29
29
 
30
- context "when environment doesn't exist" do
30
+ context "when the environment doesn't exist" do
31
31
  it { should be nil }
32
32
  end
33
33
  end
@@ -35,12 +35,12 @@ describe KnapsackPro::Config::CI::Codefresh do
35
35
  describe '#commit_hash' do
36
36
  subject { described_class.new.commit_hash }
37
37
 
38
- context 'when environment exists' do
38
+ context 'when the environment exists' do
39
39
  let(:env) { { 'CF_REVISION' => 'b624067a61d2134df1db74ebdabb1d8d' } }
40
40
  it { should eql 'b624067a61d2134df1db74ebdabb1d8d' }
41
41
  end
42
42
 
43
- context "when environment doesn't exist" do
43
+ context "when the environment doesn't exist" do
44
44
  it { should be nil }
45
45
  end
46
46
  end
@@ -48,12 +48,12 @@ describe KnapsackPro::Config::CI::Codefresh do
48
48
  describe '#branch' do
49
49
  subject { described_class.new.branch }
50
50
 
51
- context 'when environment exists' do
51
+ context 'when the environment exists' do
52
52
  let(:env) { { 'CF_BRANCH' => 'codefresh-branch' } }
53
53
  it { should eql 'codefresh-branch' }
54
54
  end
55
55
 
56
- context "when environment doesn't exist" do
56
+ context "when the environment doesn't exist" do
57
57
  it { should be nil }
58
58
  end
59
59
  end
@@ -63,4 +63,19 @@ describe KnapsackPro::Config::CI::Codefresh do
63
63
 
64
64
  it { should be nil }
65
65
  end
66
+
67
+
68
+ describe '#user_seat' do
69
+ subject { described_class.new.user_seat }
70
+
71
+ context 'when the CF_BUILD_INITIATOR environment variable exists' do
72
+ let(:env) { { 'CF_BUILD_INITIATOR' => 'jane_doe' } }
73
+
74
+ it { should eql 'jane_doe' }
75
+ end
76
+
77
+ context "when the CF_BUILD_INITIATOR environment variable doesn't exist" do
78
+ it { should be nil }
79
+ end
80
+ end
66
81
  end
@@ -22,12 +22,12 @@ describe KnapsackPro::Config::CI::Codeship do
22
22
  describe '#node_build_id' do
23
23
  subject { described_class.new.node_build_id }
24
24
 
25
- context 'when environment exists' do
25
+ context 'when the environment exists' do
26
26
  let(:env) { { 'CI_BUILD_NUMBER' => 2013 } }
27
27
  it { should eql 2013 }
28
28
  end
29
29
 
30
- context "when environment doesn't exist" do
30
+ context "when the environment doesn't exist" do
31
31
  it { should be nil }
32
32
  end
33
33
  end
@@ -35,12 +35,12 @@ describe KnapsackPro::Config::CI::Codeship do
35
35
  describe '#commit_hash' do
36
36
  subject { described_class.new.commit_hash }
37
37
 
38
- context 'when environment exists' do
38
+ context 'when the environment exists' do
39
39
  let(:env) { { 'CI_COMMIT_ID' => 'a22aec3ee5d334fd658da35646b42bc5' } }
40
40
  it { should eql 'a22aec3ee5d334fd658da35646b42bc5' }
41
41
  end
42
42
 
43
- context "when environment doesn't exist" do
43
+ context "when the environment doesn't exist" do
44
44
  it { should be nil }
45
45
  end
46
46
  end
@@ -48,12 +48,12 @@ describe KnapsackPro::Config::CI::Codeship do
48
48
  describe '#branch' do
49
49
  subject { described_class.new.branch }
50
50
 
51
- context 'when environment exists' do
51
+ context 'when the environment exists' do
52
52
  let(:env) { { 'CI_BRANCH' => 'master' } }
53
53
  it { should eql 'master' }
54
54
  end
55
55
 
56
- context "when environment doesn't exist" do
56
+ context "when the environment doesn't exist" do
57
57
  it { should be nil }
58
58
  end
59
59
  end
@@ -63,4 +63,18 @@ describe KnapsackPro::Config::CI::Codeship do
63
63
 
64
64
  it { should be nil }
65
65
  end
66
+
67
+ describe '#user_seat' do
68
+ subject { described_class.new.user_seat }
69
+
70
+ context 'when the CI_COMMITTER_NAME environment variable exists' do
71
+ let(:env) { { 'CI_COMMITTER_NAME' => 'jane_doe' } }
72
+
73
+ it { should eql 'jane_doe' }
74
+ end
75
+
76
+ context "when the CI_COMMITTER_NAME environment variable doesn't exist" do
77
+ it { should be nil }
78
+ end
79
+ end
66
80
  end
@@ -22,12 +22,25 @@ describe KnapsackPro::Config::CI::GithubActions do
22
22
  describe '#node_build_id' do
23
23
  subject { described_class.new.node_build_id }
24
24
 
25
- context 'when environment exists' do
25
+ context 'when the environment exists' do
26
26
  let(:env) { { 'GITHUB_RUN_ID' => 2706 } }
27
27
  it { should eql 2706 }
28
28
  end
29
29
 
30
- context "when environment doesn't exist" do
30
+ context "when the environment doesn't exist" do
31
+ it { should be nil }
32
+ end
33
+ end
34
+
35
+ describe '#node_retry_count' do
36
+ subject { described_class.new.node_retry_count }
37
+
38
+ context 'when the environment exists' do
39
+ let(:env) { { 'GITHUB_RUN_ATTEMPT' => 2 } }
40
+ it { should eql 1 }
41
+ end
42
+
43
+ context "when the environment doesn't exist" do
31
44
  it { should be nil }
32
45
  end
33
46
  end
@@ -35,12 +48,12 @@ describe KnapsackPro::Config::CI::GithubActions do
35
48
  describe '#commit_hash' do
36
49
  subject { described_class.new.commit_hash }
37
50
 
38
- context 'when environment exists' do
51
+ context 'when the environment exists' do
39
52
  let(:env) { { 'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d' } }
40
53
  it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
41
54
  end
42
55
 
43
- context "when environment doesn't exist" do
56
+ context "when the environment doesn't exist" do
44
57
  it { should be nil }
45
58
  end
46
59
  end
@@ -48,16 +61,16 @@ describe KnapsackPro::Config::CI::GithubActions do
48
61
  describe '#branch' do
49
62
  subject { described_class.new.branch }
50
63
 
51
- context 'when environment exists' do
64
+ context 'when the environment exists' do
52
65
  context 'when GITHUB_REF has value' do
53
66
  let(:env) do
54
67
  {
55
- 'GITHUB_REF' => 'master',
68
+ 'GITHUB_REF' => 'main',
56
69
  'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
57
70
  }
58
71
  end
59
72
 
60
- it { should eql 'master' }
73
+ it { should eql 'main' }
61
74
  end
62
75
 
63
76
  context 'when GITHUB_REF is not set' do
@@ -71,7 +84,7 @@ describe KnapsackPro::Config::CI::GithubActions do
71
84
  end
72
85
  end
73
86
 
74
- context "when environment doesn't exist" do
87
+ context "when the environment doesn't exist" do
75
88
  it { should be nil }
76
89
  end
77
90
  end
@@ -79,12 +92,26 @@ describe KnapsackPro::Config::CI::GithubActions do
79
92
  describe '#project_dir' do
80
93
  subject { described_class.new.project_dir }
81
94
 
82
- context 'when environment exists' do
95
+ context 'when the environment exists' do
83
96
  let(:env) { { 'GITHUB_WORKSPACE' => '/home/runner/work/my-repo-name/my-repo-name' } }
84
97
  it { should eql '/home/runner/work/my-repo-name/my-repo-name' }
85
98
  end
86
99
 
87
- context "when environment doesn't exist" do
100
+ context "when the environment doesn't exist" do
101
+ it { should be nil }
102
+ end
103
+ end
104
+
105
+ describe '#user_seat' do
106
+ subject { described_class.new.user_seat }
107
+
108
+ context 'when the GITHUB_ACTOR environment variable exists' do
109
+ let(:env) { { 'GITHUB_ACTOR' => 'jane_doe' } }
110
+
111
+ it { should eql 'jane_doe' }
112
+ end
113
+
114
+ context "when the GITHUB_ACTOR environment variable doesn't exist" do
88
115
  it { should be nil }
89
116
  end
90
117
  end
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::GitlabCI do
10
10
  describe '#node_total' do
11
11
  subject { described_class.new.node_total }
12
12
 
13
- context 'when environment exists' do
13
+ context 'when the environment exists' do
14
14
  let(:env) { { 'CI_NODE_TOTAL' => 4 } }
15
15
  it { should eql 4 }
16
16
  end
17
17
 
18
- context "when environment doesn't exist" do
18
+ context "when the environment doesn't exist" do
19
19
  it { should be nil }
20
20
  end
21
21
  end
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::GitlabCI do
23
23
  describe '#node_index' do
24
24
  subject { described_class.new.node_index }
25
25
 
26
- context 'when environment exists and is in GitLab CI' do
26
+ context 'when the environment exists and is in GitLab CI' do
27
27
  let(:env) { { 'CI_NODE_INDEX' => 4, 'GITLAB_CI' => 'true' } }
28
28
  it { should eql 3 }
29
29
  end
30
30
 
31
- context "when environment doesn't exist" do
31
+ context "when the environment doesn't exist" do
32
32
  it { should be nil }
33
33
  end
34
34
  end
@@ -46,7 +46,7 @@ describe KnapsackPro::Config::CI::GitlabCI do
46
46
  it { should eql 7046508 }
47
47
  end
48
48
 
49
- context "when environment doesn't exist" do
49
+ context "when the environment doesn't exist" do
50
50
  it { should be nil }
51
51
  end
52
52
  end
@@ -64,7 +64,7 @@ describe KnapsackPro::Config::CI::GitlabCI do
64
64
  it { should eql 'f76c468e3e1d570f71f5822b1e48bb04' }
65
65
  end
66
66
 
67
- context "when environment doesn't exist" do
67
+ context "when the environment doesn't exist" do
68
68
  it { should be nil }
69
69
  end
70
70
  end
@@ -73,16 +73,16 @@ describe KnapsackPro::Config::CI::GitlabCI do
73
73
  subject { described_class.new.branch }
74
74
 
75
75
  context 'when Gitlab Release 9.0+ and environment exists' do
76
- let(:env) { { 'CI_COMMIT_REF_NAME' => 'master' } }
77
- it { should eql 'master' }
76
+ let(:env) { { 'CI_COMMIT_REF_NAME' => 'main' } }
77
+ it { should eql 'main' }
78
78
  end
79
79
 
80
80
  context 'when Gitlab Release 8.x and environment exists' do
81
- let(:env) { { 'CI_BUILD_REF_NAME' => 'master' } }
82
- it { should eql 'master' }
81
+ let(:env) { { 'CI_BUILD_REF_NAME' => 'main' } }
82
+ it { should eql 'main' }
83
83
  end
84
84
 
85
- context "when environment doesn't exist" do
85
+ context "when the environment doesn't exist" do
86
86
  it { should be nil }
87
87
  end
88
88
  end
@@ -90,12 +90,47 @@ describe KnapsackPro::Config::CI::GitlabCI do
90
90
  describe '#project_dir' do
91
91
  subject { described_class.new.project_dir }
92
92
 
93
- context 'when environment exists' do
93
+ context 'when the environment exists' do
94
94
  let(:env) { { 'CI_PROJECT_DIR' => '/home/user/knapsack_pro-ruby' } }
95
95
  it { should eql '/home/user/knapsack_pro-ruby' }
96
96
  end
97
97
 
98
- context "when environment doesn't exist" do
98
+ context "when the environment doesn't exist" do
99
+ it { should be nil }
100
+ end
101
+ end
102
+
103
+ describe '#user_seat' do
104
+ subject { described_class.new.user_seat }
105
+
106
+ context 'when the GITLAB_USER_NAME env var exists' do
107
+ let(:env) do
108
+ { 'GITLAB_USER_NAME' => 'Jane Doe',
109
+ 'GITLAB_USER_EMAIL' => nil }
110
+ end
111
+
112
+ it { should eql 'Jane Doe' }
113
+ end
114
+
115
+ context 'when the GITLAB_USER_EMAIL env var exists' do
116
+ let(:env) do
117
+ { 'GITLAB_USER_NAME' => nil,
118
+ 'GITLAB_USER_EMAIL' => 'janed@example.com' }
119
+ end
120
+
121
+ it { should eql 'janed@example.com' }
122
+ end
123
+
124
+ context 'when both GITLAB_USER_NAME and GITLAB_USER_EMAIL env vars exist' do
125
+ let(:env) do
126
+ { 'GITLAB_USER_NAME' => 'Jane Doe',
127
+ 'GITLAB_USER_EMAIL' => 'janed@example.com' }
128
+ end
129
+
130
+ it { should eql 'Jane Doe' }
131
+ end
132
+
133
+ context "when neither env var exists" do
99
134
  it { should be nil }
100
135
  end
101
136
  end
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::Heroku do
10
10
  describe '#node_total' do
11
11
  subject { described_class.new.node_total }
12
12
 
13
- context 'when environment exists' do
13
+ context 'when the environment exists' do
14
14
  let(:env) { { 'CI_NODE_TOTAL' => 4 } }
15
15
  it { should eql 4 }
16
16
  end
17
17
 
18
- context "when environment doesn't exist" do
18
+ context "when the environment doesn't exist" do
19
19
  it { should be nil }
20
20
  end
21
21
  end
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::Heroku do
23
23
  describe '#node_index' do
24
24
  subject { described_class.new.node_index }
25
25
 
26
- context 'when environment exists' do
26
+ context 'when the environment exists' do
27
27
  let(:env) { { 'CI_NODE_INDEX' => 3 } }
28
28
  it { should eql 3 }
29
29
  end
30
30
 
31
- context "when environment doesn't exist" do
31
+ context "when the environment doesn't exist" do
32
32
  it { should be nil }
33
33
  end
34
34
  end
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::Heroku do
36
36
  describe '#node_build_id' do
37
37
  subject { described_class.new.node_build_id }
38
38
 
39
- context 'when environment exists' do
39
+ context 'when the environment exists' do
40
40
  let(:env) { { 'HEROKU_TEST_RUN_ID' => 1234 } }
41
41
  it { should eql 1234 }
42
42
  end
43
43
 
44
- context "when environment doesn't exist" do
44
+ context "when the environment doesn't exist" do
45
45
  it { should be nil }
46
46
  end
47
47
  end
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::Heroku do
49
49
  describe '#commit_hash' do
50
50
  subject { described_class.new.commit_hash }
51
51
 
52
- context 'when environment exists' do
52
+ context 'when the environment exists' do
53
53
  let(:env) { { 'HEROKU_TEST_RUN_COMMIT_VERSION' => 'abbaec3ee5d334fd658da35646b42bc5' } }
54
54
  it { should eql 'abbaec3ee5d334fd658da35646b42bc5' }
55
55
  end
56
56
 
57
- context "when environment doesn't exist" do
57
+ context "when the environment doesn't exist" do
58
58
  it { should be nil }
59
59
  end
60
60
  end
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::Heroku do
62
62
  describe '#branch' do
63
63
  subject { described_class.new.branch }
64
64
 
65
- context 'when environment exists' do
65
+ context 'when the environment exists' do
66
66
  let(:env) { { 'HEROKU_TEST_RUN_BRANCH' => 'master' } }
67
67
  it { should eql 'master' }
68
68
  end
69
69
 
70
- context "when environment doesn't exist" do
70
+ context "when the environment doesn't exist" do
71
71
  it { should be nil }
72
72
  end
73
73
  end
@@ -75,12 +75,12 @@ describe KnapsackPro::Config::CI::Heroku do
75
75
  describe '#project_dir' do
76
76
  subject { described_class.new.project_dir }
77
77
 
78
- context 'when environment exists' do
78
+ context 'when the environment exists' do
79
79
  let(:env) { { 'HEROKU_TEST_RUN_ID' => 1234 } }
80
80
  it { should eq '/app' }
81
81
  end
82
82
 
83
- context "when environment doesn't exist" do
83
+ context "when the environment doesn't exist" do
84
84
  it { should be nil }
85
85
  end
86
86
  end
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::Semaphore2 do
10
10
  describe '#node_total' do
11
11
  subject { described_class.new.node_total }
12
12
 
13
- context 'when environment exists' do
13
+ context 'when the environment exists' do
14
14
  let(:env) { { 'SEMAPHORE_JOB_COUNT' => 4 } }
15
15
  it { should eql 4 }
16
16
  end
17
17
 
18
- context "when environment doesn't exist" do
18
+ context "when the environment doesn't exist" do
19
19
  it { should be nil }
20
20
  end
21
21
  end
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::Semaphore2 do
23
23
  describe '#node_index' do
24
24
  subject { described_class.new.node_index }
25
25
 
26
- context 'when environment exists' do
26
+ context 'when the environment exists' do
27
27
  let(:env) { { 'SEMAPHORE_JOB_INDEX' => 4 } }
28
28
  it { should eql 3 }
29
29
  end
30
30
 
31
- context "when environment doesn't exist" do
31
+ context "when the environment doesn't exist" do
32
32
  it { should be nil }
33
33
  end
34
34
  end
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::Semaphore2 do
36
36
  describe '#node_build_id' do
37
37
  subject { described_class.new.node_build_id }
38
38
 
39
- context 'when environment exists' do
39
+ context 'when the environment exists' do
40
40
  let(:env) { { 'SEMAPHORE_WORKFLOW_ID' => 123 } }
41
41
  it { should eql 123 }
42
42
  end
43
43
 
44
- context "when environment doesn't exist" do
44
+ context "when the environment doesn't exist" do
45
45
  it { should be nil }
46
46
  end
47
47
  end
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::Semaphore2 do
49
49
  describe '#commit_hash' do
50
50
  subject { described_class.new.commit_hash }
51
51
 
52
- context 'when environment exists' do
52
+ context 'when the environment exists' do
53
53
  let(:env) { { 'SEMAPHORE_GIT_SHA' => '4323320992a21b1169e3ac5b7789d379597738e6' } }
54
54
  it { should eql '4323320992a21b1169e3ac5b7789d379597738e6' }
55
55
  end
56
56
 
57
- context "when environment doesn't exist" do
57
+ context "when the environment doesn't exist" do
58
58
  it { should be nil }
59
59
  end
60
60
  end
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::Semaphore2 do
62
62
  describe '#branch' do
63
63
  subject { described_class.new.branch }
64
64
 
65
- context 'when environment exists' do
65
+ context 'when the environment exists' do
66
66
  let(:env) { { 'SEMAPHORE_GIT_BRANCH' => 'master' } }
67
67
  it { should eql 'master' }
68
68
  end
69
69
 
70
- context "when environment doesn't exist" do
70
+ context "when the environment doesn't exist" do
71
71
  it { should be nil }
72
72
  end
73
73
  end
@@ -103,7 +103,7 @@ describe KnapsackPro::Config::CI::Semaphore2 do
103
103
  it { should be nil }
104
104
  end
105
105
 
106
- context "when environments don't exist" do
106
+ context "when the environments don't exist" do
107
107
  it { should be nil }
108
108
  end
109
109
  end
@@ -10,12 +10,12 @@ describe KnapsackPro::Config::CI::Semaphore do
10
10
  describe '#node_total' do
11
11
  subject { described_class.new.node_total }
12
12
 
13
- context 'when environment exists' do
13
+ context 'when the environment exists' do
14
14
  let(:env) { { 'SEMAPHORE_THREAD_COUNT' => 4 } }
15
15
  it { should eql 4 }
16
16
  end
17
17
 
18
- context "when environment doesn't exist" do
18
+ context "when the environment doesn't exist" do
19
19
  it { should be nil }
20
20
  end
21
21
  end
@@ -23,12 +23,12 @@ describe KnapsackPro::Config::CI::Semaphore do
23
23
  describe '#node_index' do
24
24
  subject { described_class.new.node_index }
25
25
 
26
- context 'when environment exists' do
26
+ context 'when the environment exists' do
27
27
  let(:env) { { 'SEMAPHORE_CURRENT_THREAD' => 4 } }
28
28
  it { should eql 3 }
29
29
  end
30
30
 
31
- context "when environment doesn't exist" do
31
+ context "when the environment doesn't exist" do
32
32
  it { should be nil }
33
33
  end
34
34
  end
@@ -36,12 +36,12 @@ describe KnapsackPro::Config::CI::Semaphore do
36
36
  describe '#node_build_id' do
37
37
  subject { described_class.new.node_build_id }
38
38
 
39
- context 'when environment exists' do
39
+ context 'when the environment exists' do
40
40
  let(:env) { { 'SEMAPHORE_BUILD_NUMBER' => 23 } }
41
41
  it { should eql 23 }
42
42
  end
43
43
 
44
- context "when environment doesn't exist" do
44
+ context "when the environment doesn't exist" do
45
45
  it { should be nil }
46
46
  end
47
47
  end
@@ -49,12 +49,12 @@ describe KnapsackPro::Config::CI::Semaphore do
49
49
  describe '#commit_hash' do
50
50
  subject { described_class.new.commit_hash }
51
51
 
52
- context 'when environment exists' do
52
+ context 'when the environment exists' do
53
53
  let(:env) { { 'REVISION' => '3fa64859337f6e56409d49f865d13fd7' } }
54
54
  it { should eql '3fa64859337f6e56409d49f865d13fd7' }
55
55
  end
56
56
 
57
- context "when environment doesn't exist" do
57
+ context "when the environment doesn't exist" do
58
58
  it { should be nil }
59
59
  end
60
60
  end
@@ -62,12 +62,12 @@ describe KnapsackPro::Config::CI::Semaphore do
62
62
  describe '#branch' do
63
63
  subject { described_class.new.branch }
64
64
 
65
- context 'when environment exists' do
65
+ context 'when the environment exists' do
66
66
  let(:env) { { 'BRANCH_NAME' => 'master' } }
67
67
  it { should eql 'master' }
68
68
  end
69
69
 
70
- context "when environment doesn't exist" do
70
+ context "when the environment doesn't exist" do
71
71
  it { should be nil }
72
72
  end
73
73
  end
@@ -75,12 +75,12 @@ describe KnapsackPro::Config::CI::Semaphore do
75
75
  describe '#project_dir' do
76
76
  subject { described_class.new.project_dir }
77
77
 
78
- context 'when environment exists' do
78
+ context 'when the environment exists' do
79
79
  let(:env) { { 'SEMAPHORE_PROJECT_DIR' => '/home/runner/knapsack_pro-ruby' } }
80
80
  it { should eql '/home/runner/knapsack_pro-ruby' }
81
81
  end
82
82
 
83
- context "when environment doesn't exist" do
83
+ context "when the environment doesn't exist" do
84
84
  it { should be nil }
85
85
  end
86
86
  end
@@ -22,12 +22,12 @@ describe KnapsackPro::Config::CI::Travis do
22
22
  describe '#node_build_id' do
23
23
  subject { described_class.new.node_build_id }
24
24
 
25
- context 'when environment exists' do
25
+ context 'when the environment exists' do
26
26
  let(:env) { { 'TRAVIS_BUILD_NUMBER' => 4 } }
27
27
  it { should eql 4 }
28
28
  end
29
29
 
30
- context "when environment doesn't exist" do
30
+ context "when the environment doesn't exist" do
31
31
  it { should be nil }
32
32
  end
33
33
  end
@@ -35,12 +35,12 @@ describe KnapsackPro::Config::CI::Travis do
35
35
  describe '#commit_hash' do
36
36
  subject { described_class.new.commit_hash }
37
37
 
38
- context 'when environment exists' do
38
+ context 'when the environment exists' do
39
39
  let(:env) { { 'TRAVIS_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
40
40
  it { should eql '3fa64859337f6e56409d49f865d13fd7' }
41
41
  end
42
42
 
43
- context "when environment doesn't exist" do
43
+ context "when the environment doesn't exist" do
44
44
  it { should be nil }
45
45
  end
46
46
  end
@@ -48,12 +48,12 @@ describe KnapsackPro::Config::CI::Travis do
48
48
  describe '#branch' do
49
49
  subject { described_class.new.branch }
50
50
 
51
- context 'when environment exists' do
51
+ context 'when the environment exists' do
52
52
  let(:env) { { 'TRAVIS_BRANCH' => 'master' } }
53
53
  it { should eql 'master' }
54
54
  end
55
55
 
56
- context "when environment doesn't exist" do
56
+ context "when the environment doesn't exist" do
57
57
  it { should be nil }
58
58
  end
59
59
  end
@@ -61,12 +61,12 @@ describe KnapsackPro::Config::CI::Travis do
61
61
  describe '#project_dir' do
62
62
  subject { described_class.new.project_dir }
63
63
 
64
- context 'when environment exists' do
64
+ context 'when the environment exists' do
65
65
  let(:env) { { 'TRAVIS_BUILD_DIR' => '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' } }
66
66
  it { should eql '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' }
67
67
  end
68
68
 
69
- context "when environment doesn't exist" do
69
+ context "when the environment doesn't exist" do
70
70
  it { should be nil }
71
71
  end
72
72
  end