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,199 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Hooks::Queue do
|
|
2
|
-
describe '.call_before_queue' do
|
|
3
|
-
subject { described_class.call_before_queue }
|
|
4
|
-
|
|
5
|
-
before do
|
|
6
|
-
described_class.reset_before_queue
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
context 'when no callback is set' do
|
|
10
|
-
it { should be_nil }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
context 'when multiple callbacks are set' do
|
|
14
|
-
let(:queue_id) { double }
|
|
15
|
-
|
|
16
|
-
it 'calls each block' do
|
|
17
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).twice.and_return(queue_id)
|
|
18
|
-
|
|
19
|
-
expected_called_blocks = []
|
|
20
|
-
|
|
21
|
-
described_class.before_queue do |q_id|
|
|
22
|
-
expected_called_blocks << [:block_1_called, q_id]
|
|
23
|
-
end
|
|
24
|
-
described_class.before_queue do |q_id|
|
|
25
|
-
expected_called_blocks << [:block_2_called, q_id]
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
subject
|
|
29
|
-
|
|
30
|
-
expect(expected_called_blocks).to eq([
|
|
31
|
-
[:block_1_called, queue_id],
|
|
32
|
-
[:block_2_called, queue_id],
|
|
33
|
-
])
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '.call_before_subset_queue' do
|
|
39
|
-
subject { described_class.call_before_subset_queue }
|
|
40
|
-
|
|
41
|
-
before do
|
|
42
|
-
described_class.reset_before_subset_queue
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'when no callback is set' do
|
|
46
|
-
it { should be_nil }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'when multiple callbacks are set' do
|
|
50
|
-
let(:queue_id) { double }
|
|
51
|
-
let(:subset_queue_id) { double }
|
|
52
|
-
|
|
53
|
-
it 'calls each block' do
|
|
54
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).twice.and_return(queue_id)
|
|
55
|
-
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).twice.and_return(subset_queue_id)
|
|
56
|
-
|
|
57
|
-
expected_called_blocks = []
|
|
58
|
-
|
|
59
|
-
described_class.before_subset_queue do |q_id, subset_q_id|
|
|
60
|
-
expected_called_blocks << [:block_1_called, q_id, subset_q_id]
|
|
61
|
-
end
|
|
62
|
-
described_class.before_subset_queue do |q_id, subset_q_id|
|
|
63
|
-
expected_called_blocks << [:block_2_called, q_id, subset_q_id]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
subject
|
|
67
|
-
|
|
68
|
-
expect(expected_called_blocks).to eq([
|
|
69
|
-
[:block_1_called, queue_id, subset_queue_id],
|
|
70
|
-
[:block_2_called, queue_id, subset_queue_id],
|
|
71
|
-
])
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'when a callback is set AND the queue is passed' do
|
|
76
|
-
let(:queue_id) { double }
|
|
77
|
-
let(:subset_queue_id) { double }
|
|
78
|
-
let(:queue) { instance_double(KnapsackPro::Queue) }
|
|
79
|
-
|
|
80
|
-
subject { described_class.call_before_subset_queue(queue) }
|
|
81
|
-
|
|
82
|
-
it 'calls each block' do
|
|
83
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
|
|
84
|
-
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)
|
|
85
|
-
|
|
86
|
-
expected_called_blocks = []
|
|
87
|
-
|
|
88
|
-
described_class.before_subset_queue do |q_id, subset_q_id, queue|
|
|
89
|
-
expected_called_blocks << [:block_1_called, q_id, subset_q_id, queue]
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
subject
|
|
93
|
-
|
|
94
|
-
expect(expected_called_blocks).to eq([
|
|
95
|
-
[:block_1_called, queue_id, subset_queue_id, queue],
|
|
96
|
-
])
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
describe '.call_after_subset_queue' do
|
|
102
|
-
subject { described_class.call_after_subset_queue }
|
|
103
|
-
|
|
104
|
-
before do
|
|
105
|
-
described_class.reset_after_subset_queue
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context 'when no callback is set' do
|
|
109
|
-
it { should be_nil }
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
context 'when multiple callbacks are set' do
|
|
113
|
-
let(:queue_id) { double }
|
|
114
|
-
let(:subset_queue_id) { double }
|
|
115
|
-
|
|
116
|
-
it 'calls each block' do
|
|
117
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).at_least(:once).and_return(queue_id)
|
|
118
|
-
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).at_least(:once).and_return(subset_queue_id)
|
|
119
|
-
|
|
120
|
-
expected_called_blocks = []
|
|
121
|
-
|
|
122
|
-
described_class.after_subset_queue do |q_id, subset_q_id|
|
|
123
|
-
expected_called_blocks << [:block_1_called, q_id, subset_q_id]
|
|
124
|
-
end
|
|
125
|
-
described_class.after_subset_queue do |q_id, subset_q_id|
|
|
126
|
-
expected_called_blocks << [:block_2_called, q_id, subset_q_id]
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
subject
|
|
130
|
-
|
|
131
|
-
expect(expected_called_blocks).to eq([
|
|
132
|
-
[:block_1_called, queue_id, subset_queue_id],
|
|
133
|
-
[:block_2_called, queue_id, subset_queue_id],
|
|
134
|
-
])
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
context 'when a callback is set AND the queue is passed' do
|
|
139
|
-
let(:queue_id) { double }
|
|
140
|
-
let(:subset_queue_id) { double }
|
|
141
|
-
let(:queue) { instance_double(KnapsackPro::Queue) }
|
|
142
|
-
|
|
143
|
-
subject { described_class.call_after_subset_queue(queue) }
|
|
144
|
-
|
|
145
|
-
it 'calls each block' do
|
|
146
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
|
|
147
|
-
expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)
|
|
148
|
-
|
|
149
|
-
expected_called_blocks = []
|
|
150
|
-
|
|
151
|
-
described_class.after_subset_queue do |q_id, subset_q_id, queue|
|
|
152
|
-
expected_called_blocks << [:block_1_called, q_id, subset_q_id, queue]
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
subject
|
|
156
|
-
|
|
157
|
-
expect(expected_called_blocks).to eq([
|
|
158
|
-
[:block_1_called, queue_id, subset_queue_id, queue],
|
|
159
|
-
])
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe '.call_after_queue' do
|
|
165
|
-
subject { described_class.call_after_queue }
|
|
166
|
-
|
|
167
|
-
before do
|
|
168
|
-
described_class.reset_after_queue
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
context 'when no callback is set' do
|
|
172
|
-
it { should be_nil }
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
context 'when multiple callbacks are set' do
|
|
176
|
-
let(:queue_id) { double }
|
|
177
|
-
|
|
178
|
-
it 'calls each block' do
|
|
179
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_id).twice.and_return(queue_id)
|
|
180
|
-
|
|
181
|
-
expected_called_blocks = []
|
|
182
|
-
|
|
183
|
-
described_class.after_queue do |q_id|
|
|
184
|
-
expected_called_blocks << [:block_1_called, q_id]
|
|
185
|
-
end
|
|
186
|
-
described_class.after_queue do |q_id|
|
|
187
|
-
expected_called_blocks << [:block_2_called, q_id]
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
subject
|
|
191
|
-
|
|
192
|
-
expect(expected_called_blocks).to eq([
|
|
193
|
-
[:block_1_called, queue_id],
|
|
194
|
-
[:block_2_called, queue_id],
|
|
195
|
-
])
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Presenter do
|
|
2
|
-
describe '.global_time' do
|
|
3
|
-
let(:tracker) { instance_double(KnapsackPro::Tracker, global_time: 60*62+3) }
|
|
4
|
-
|
|
5
|
-
subject { described_class.global_time }
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it { should eql "Global test execution duration: 01h 02m 03s" }
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe '.pretty_seconds' do
|
|
15
|
-
subject { described_class.pretty_seconds(seconds) }
|
|
16
|
-
|
|
17
|
-
context 'when less then one second' do
|
|
18
|
-
let(:seconds) { 0.987 }
|
|
19
|
-
it { should eql '0.987s' }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context 'when one second' do
|
|
23
|
-
let(:seconds) { 1 }
|
|
24
|
-
it { should eql '01s' }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'when only seconds' do
|
|
28
|
-
let(:seconds) { 5 }
|
|
29
|
-
it { should eql '05s' }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'when only minutes' do
|
|
33
|
-
let(:seconds) { 120 }
|
|
34
|
-
it { should eql '02m' }
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
context 'when only hours' do
|
|
38
|
-
let(:seconds) { 60*60*3 }
|
|
39
|
-
it { should eql '03h' }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'when minutes and seconds' do
|
|
43
|
-
let(:seconds) { 180+9 }
|
|
44
|
-
it { should eql '03m 09s' }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
context 'when all' do
|
|
48
|
-
let(:seconds) { 60*60*4+120+7 }
|
|
49
|
-
it { should eql '04h 02m 07s' }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context 'when negative seconds' do
|
|
53
|
-
let(:seconds) { -67 }
|
|
54
|
-
it { should eql '-01m 07s' }
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
require(KnapsackPro.root + '/lib/knapsack_pro/formatters/time_tracker')
|
|
2
|
-
require(KnapsackPro.root + '/lib/knapsack_pro/extensions/rspec_extension')
|
|
3
|
-
|
|
4
|
-
describe KnapsackPro::Pure::Queue::RSpecPure do
|
|
5
|
-
let(:rspec_pure) { described_class.new }
|
|
6
|
-
|
|
7
|
-
describe '#add_knapsack_pro_formatters_to' do
|
|
8
|
-
subject { rspec_pure.add_knapsack_pro_formatters_to(spec_opts) }
|
|
9
|
-
|
|
10
|
-
context 'when no spec_opts' do
|
|
11
|
-
let(:spec_opts) { nil }
|
|
12
|
-
|
|
13
|
-
it 'returns no spec_opts' do
|
|
14
|
-
expect(subject).to be nil
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'when spec_opts have Knapsack Pro formatters' do
|
|
19
|
-
let(:spec_opts) { '--color --format d --format KnapsackPro::Formatters::TimeTracker' }
|
|
20
|
-
|
|
21
|
-
it 'returns spec_opts' do
|
|
22
|
-
expect(subject).to eq spec_opts
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'when spec_opts have no Knapsack Pro formatters' do
|
|
27
|
-
let(:spec_opts) { '--color --format d' }
|
|
28
|
-
|
|
29
|
-
it 'returns spec_opts with added Knapsack Pro formatters' do
|
|
30
|
-
expect(subject).to eq '--color --format d --format KnapsackPro::Formatters::TimeTracker'
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
describe '#error_exit_code' do
|
|
36
|
-
subject { rspec_pure.error_exit_code(rspec_error_exit_code) }
|
|
37
|
-
|
|
38
|
-
context 'when RSpec has no defined error exit code' do
|
|
39
|
-
let(:rspec_error_exit_code) { nil }
|
|
40
|
-
|
|
41
|
-
it 'returns 1 as the default exit code' do
|
|
42
|
-
expect(subject).to eq 1
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context 'when RSpec has a defined error exit code' do
|
|
47
|
-
let(:rspec_error_exit_code) { 2 }
|
|
48
|
-
|
|
49
|
-
it 'returns the custom exit code' do
|
|
50
|
-
expect(subject).to eq rspec_error_exit_code
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe '#args_with_seed_option_added_when_viable' do
|
|
56
|
-
let(:order_option) { KnapsackPro::Adapters::RSpecAdapter.order_option(args) }
|
|
57
|
-
|
|
58
|
-
subject { rspec_pure.args_with_seed_option_added_when_viable(order_option, seed, args) }
|
|
59
|
-
|
|
60
|
-
context 'when the order option is not random' do
|
|
61
|
-
let(:args) { ['--order', 'defined'] }
|
|
62
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(nil, false) }
|
|
63
|
-
|
|
64
|
-
it 'does not add the seed option to args' do
|
|
65
|
-
expect(subject).to eq ['--order', 'defined']
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
['random', 'rand'].each do |random_option_value|
|
|
70
|
-
context "when the order option is `#{random_option_value}`" do
|
|
71
|
-
let(:args) { ['--order', random_option_value] }
|
|
72
|
-
|
|
73
|
-
context 'when the seed is not used' do
|
|
74
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new('123', false) }
|
|
75
|
-
|
|
76
|
-
it 'does not add the seed option to args' do
|
|
77
|
-
expect(subject).to eq ['--order', random_option_value]
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context 'when the seed is used' do
|
|
82
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new('123', true) }
|
|
83
|
-
|
|
84
|
-
it 'adds the seed option to args' do
|
|
85
|
-
expect(subject).to eq ['--order', random_option_value, '--seed', '123']
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
context 'when the order option is `rand:123`' do
|
|
92
|
-
let(:args) { ['--order', 'rand:123'] }
|
|
93
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new('123', true) }
|
|
94
|
-
|
|
95
|
-
it 'does not add the seed option to args' do
|
|
96
|
-
expect(subject).to eq ['--order', 'rand:123']
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context 'when the order option is not set in args AND seed is used' do
|
|
101
|
-
let(:args) { ['--format', 'documentation'] }
|
|
102
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new('123', true) }
|
|
103
|
-
|
|
104
|
-
it 'adds the seed option to args' do
|
|
105
|
-
expect(subject).to eq ['--format', 'documentation', '--seed', '123']
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
context 'when the order option is not set in args AND seed is not used' do
|
|
110
|
-
let(:args) { ['--format', 'documentation'] }
|
|
111
|
-
let(:seed) { KnapsackPro::Extensions::RSpecExtension::Seed.new(value: '123', used?: false) }
|
|
112
|
-
|
|
113
|
-
it 'does not add the seed option to args' do
|
|
114
|
-
expect(subject).to eq ['--format', 'documentation']
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe '#prepare_cli_args' do
|
|
120
|
-
subject { rspec_pure.prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir) }
|
|
121
|
-
|
|
122
|
-
context 'when no args' do
|
|
123
|
-
let(:args) { nil }
|
|
124
|
-
let(:has_format_option) { false }
|
|
125
|
-
let(:has_require_rails_helper_option) { false }
|
|
126
|
-
let(:test_dir) { 'spec' }
|
|
127
|
-
|
|
128
|
-
context 'when rails_helper does not exist' do
|
|
129
|
-
let(:rails_helper_exists) { false }
|
|
130
|
-
|
|
131
|
-
it 'adds the default progress formatter, the default path and the time tracker formatter, does not add require rails_helper' do
|
|
132
|
-
expect(subject).to eq [
|
|
133
|
-
'--format', 'progress',
|
|
134
|
-
'--default-path', 'spec',
|
|
135
|
-
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
136
|
-
]
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
context 'when rails_helper exists' do
|
|
141
|
-
let(:rails_helper_exists) { true }
|
|
142
|
-
|
|
143
|
-
it 'adds the default progress formatter, require rails_helper, the default path and the time tracker formatter' do
|
|
144
|
-
expect(subject).to eq [
|
|
145
|
-
'--format', 'progress',
|
|
146
|
-
'--require', 'rails_helper',
|
|
147
|
-
'--default-path', 'spec',
|
|
148
|
-
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
149
|
-
]
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
context 'when args are present and a custom test directory is set' do
|
|
155
|
-
let(:args) { '--color --profile --require rails_helper' }
|
|
156
|
-
let(:has_format_option) { false }
|
|
157
|
-
let(:has_require_rails_helper_option) { true }
|
|
158
|
-
let(:rails_helper_exists) { true }
|
|
159
|
-
let(:test_dir) { 'custom_spec_dir' }
|
|
160
|
-
|
|
161
|
-
it do
|
|
162
|
-
expect(subject).to eq [
|
|
163
|
-
'--color',
|
|
164
|
-
'--profile',
|
|
165
|
-
'--require', 'rails_helper',
|
|
166
|
-
'--format', 'progress',
|
|
167
|
-
'--default-path', 'custom_spec_dir',
|
|
168
|
-
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
169
|
-
]
|
|
170
|
-
end
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
context 'when args are present and has format option' do
|
|
174
|
-
let(:args) { '--color --profile --format d --require rails_helper' }
|
|
175
|
-
let(:has_format_option) { true }
|
|
176
|
-
let(:has_require_rails_helper_option) { true }
|
|
177
|
-
let(:rails_helper_exists) { true }
|
|
178
|
-
let(:test_dir) { 'spec' }
|
|
179
|
-
|
|
180
|
-
it 'uses the format option from args instead of the default formatter' do
|
|
181
|
-
expect(subject).to eq [
|
|
182
|
-
'--color',
|
|
183
|
-
'--profile',
|
|
184
|
-
'--format', 'd',
|
|
185
|
-
'--require', 'rails_helper',
|
|
186
|
-
'--default-path', 'spec',
|
|
187
|
-
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
188
|
-
]
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
describe '#rspec_command' do
|
|
194
|
-
let(:args) { ['--format', 'documentation'] }
|
|
195
|
-
let(:test_file_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
|
196
|
-
|
|
197
|
-
subject { rspec_pure.rspec_command(args, test_file_paths, scope) }
|
|
198
|
-
|
|
199
|
-
context 'when there are no test file paths' do
|
|
200
|
-
let(:scope) { :queue_finished }
|
|
201
|
-
let(:test_file_paths) { [] }
|
|
202
|
-
|
|
203
|
-
it 'returns no messages' do
|
|
204
|
-
expect(subject).to eq []
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
context 'when a subset of queue (a batch of tests fetched from the Queue API)' do
|
|
209
|
-
let(:scope) { :batch_finished }
|
|
210
|
-
|
|
211
|
-
it 'returns messages with the RSpec command' do
|
|
212
|
-
expect(subject).to eq([
|
|
213
|
-
'To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:',
|
|
214
|
-
'bundle exec rspec --format documentation "a_spec.rb" "b_spec.rb"',
|
|
215
|
-
])
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
context 'when all tests fetched from the Queue API' do
|
|
220
|
-
let(:scope) { :queue_finished }
|
|
221
|
-
|
|
222
|
-
it 'returns messages with the RSpec command' do
|
|
223
|
-
expect(subject).to eq([
|
|
224
|
-
'To retry all the tests assigned to this CI node, please run the following command on your machine:',
|
|
225
|
-
'bundle exec rspec --format documentation "a_spec.rb" "b_spec.rb"',
|
|
226
|
-
])
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
describe '#exit_summary' do
|
|
231
|
-
subject { rspec_pure.exit_summary(unexecuted_test_files) }
|
|
232
|
-
|
|
233
|
-
context 'when there are no unexecuted test files' do
|
|
234
|
-
let(:unexecuted_test_files) { [] }
|
|
235
|
-
|
|
236
|
-
it { expect(subject).to be_nil }
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
context 'when there are unexecuted test files' do
|
|
240
|
-
let(:unexecuted_test_files) { ['b_spec.rb', 'c_spec.rb'] }
|
|
241
|
-
|
|
242
|
-
it 'returns a warning message' do
|
|
243
|
-
expect(subject).to eq 'Unexecuted tests on this CI node (including pending tests): b_spec.rb c_spec.rb'
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
end
|
|
248
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Queue do
|
|
2
|
-
it 'simulates a Queue Mode build' do
|
|
3
|
-
queue = described_class.new
|
|
4
|
-
|
|
5
|
-
expect(queue.current_batch).to be_nil
|
|
6
|
-
|
|
7
|
-
# 1st batch
|
|
8
|
-
test_files_paths_1 = ['a_spec.rb', 'b_spec.rb']
|
|
9
|
-
queue.add_batch_for(test_files_paths_1)
|
|
10
|
-
|
|
11
|
-
expect(queue.current_batch.test_file_paths).to eq(['a_spec.rb', 'b_spec.rb'])
|
|
12
|
-
expect(queue.current_batch.status).to eq :not_executed
|
|
13
|
-
queue.mark_batch_passed
|
|
14
|
-
expect(queue.current_batch.status).to eq :passed
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# 2nd batch
|
|
18
|
-
test_files_paths_2 = ['c_spec.rb', 'd_spec.rb']
|
|
19
|
-
queue.add_batch_for(test_files_paths_2)
|
|
20
|
-
|
|
21
|
-
expect(queue.current_batch.test_file_paths).to eq(['c_spec.rb', 'd_spec.rb'])
|
|
22
|
-
expect(queue.current_batch.status).to eq :not_executed
|
|
23
|
-
queue.mark_batch_failed
|
|
24
|
-
expect(queue.current_batch.status).to eq :failed
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# last batch from the Queue API is always empty
|
|
28
|
-
test_files_paths_3 = []
|
|
29
|
-
queue.add_batch_for(test_files_paths_3)
|
|
30
|
-
|
|
31
|
-
expect(queue.size).to eq 2
|
|
32
|
-
expect(queue[0].status).to eq :passed
|
|
33
|
-
expect(queue[1].status).to eq :failed
|
|
34
|
-
end
|
|
35
|
-
end
|