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,221 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Adapters::BaseAdapter do
|
|
2
|
-
it do
|
|
3
|
-
expect(described_class::TEST_DIR_PATTERN).to eq 'test/**{,/*/**}/*_test.rb'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
shared_examples '.slow_test_file? method' do
|
|
7
|
-
context 'when test_file_path is in slow test file paths' do
|
|
8
|
-
# add ./ before path to ensure KnapsackPro::TestFileCleaner.clean will clean it
|
|
9
|
-
let(:test_file_path) { './spec/models/user_spec.rb' }
|
|
10
|
-
|
|
11
|
-
it do
|
|
12
|
-
expect(subject).to be true
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'when test_file_path is not in slow test file paths' do
|
|
17
|
-
let(:test_file_path) { './spec/models/article_spec.rb' }
|
|
18
|
-
|
|
19
|
-
it do
|
|
20
|
-
expect(subject).to be false
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
describe '.adapter_bind_method_called_file' do
|
|
26
|
-
subject { described_class.adapter_bind_method_called_file }
|
|
27
|
-
|
|
28
|
-
before do
|
|
29
|
-
expect(KnapsackPro::Config::Env).to receive(:ci_node_index).and_return(ci_node_index)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'when CI node index 0' do
|
|
33
|
-
let(:ci_node_index) { 0 }
|
|
34
|
-
|
|
35
|
-
it { expect(subject).to eq '.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt' }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context 'when CI node index 1' do
|
|
39
|
-
let(:ci_node_index) { 1 }
|
|
40
|
-
|
|
41
|
-
it { expect(subject).to eq '.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_1.txt' }
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe '.split_by_test_cases_enabled?' do
|
|
46
|
-
subject { described_class.split_by_test_cases_enabled? }
|
|
47
|
-
|
|
48
|
-
it { expect(subject).to be false }
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
describe '.test_file_cases_for' do
|
|
52
|
-
subject { described_class.test_file_cases_for([]) }
|
|
53
|
-
|
|
54
|
-
it { expect { subject }.to raise_error NotImplementedError }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe '.slow_test_file?' do
|
|
58
|
-
let(:adapter_class) { double }
|
|
59
|
-
let(:slow_test_files) do
|
|
60
|
-
[
|
|
61
|
-
{ 'path' => 'spec/models/user_spec.rb' },
|
|
62
|
-
{ 'path' => 'spec/controllers/users_spec.rb' },
|
|
63
|
-
]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
subject { described_class.slow_test_file?(adapter_class, test_file_path) }
|
|
67
|
-
|
|
68
|
-
before do
|
|
69
|
-
# reset class variable
|
|
70
|
-
described_class.instance_variable_set(:@slow_test_file_paths, nil)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
context 'when slow test file pattern is present' do
|
|
74
|
-
before do
|
|
75
|
-
stub_const('ENV', {
|
|
76
|
-
'KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN' => '{spec/models/*_spec.rb}',
|
|
77
|
-
})
|
|
78
|
-
expect(KnapsackPro::TestFileFinder).to receive(:slow_test_files_by_pattern).with(adapter_class).and_return(slow_test_files)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it_behaves_like '.slow_test_file? method'
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
context 'when slow test file pattern is not present' do
|
|
85
|
-
before do
|
|
86
|
-
expect(KnapsackPro::SlowTestFileDeterminer).to receive(:read_from_json_report).and_return(slow_test_files)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it_behaves_like '.slow_test_file? method'
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
describe '.bind' do
|
|
94
|
-
let(:adapter) { instance_double(described_class) }
|
|
95
|
-
|
|
96
|
-
subject { described_class.bind }
|
|
97
|
-
|
|
98
|
-
before do
|
|
99
|
-
expect(described_class).to receive(:new).and_return(adapter)
|
|
100
|
-
expect(adapter).to receive(:bind)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it { should eql adapter }
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
describe '.verify_bind_method_called' do
|
|
107
|
-
let(:temp_directory_path) { '.knapsack_pro' }
|
|
108
|
-
|
|
109
|
-
subject { described_class.verify_bind_method_called }
|
|
110
|
-
|
|
111
|
-
before do
|
|
112
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
113
|
-
allow(File).to receive(:exist?)
|
|
114
|
-
expect(File).to receive(:exist?).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt').and_return(adapter_bind_method_called_file_exists)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
context 'when adapter bind method called' do
|
|
118
|
-
let(:adapter_bind_method_called_file_exists) { true }
|
|
119
|
-
|
|
120
|
-
it do
|
|
121
|
-
expect(File).to receive(:delete).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt')
|
|
122
|
-
subject
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
context 'when adapter bind method was not call' do
|
|
127
|
-
let(:adapter_bind_method_called_file_exists) { false }
|
|
128
|
-
|
|
129
|
-
it do
|
|
130
|
-
expect(Kernel).to receive(:exit).with(1)
|
|
131
|
-
subject
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
describe '#bind' do
|
|
137
|
-
let(:temp_directory_path) { '.knapsack_pro' }
|
|
138
|
-
let(:regular_mode?) { false }
|
|
139
|
-
let(:queue_mode?) { false }
|
|
140
|
-
|
|
141
|
-
before do
|
|
142
|
-
expect(KnapsackPro::Config::TempFiles).to receive(:ensure_temp_directory_exists!)
|
|
143
|
-
expect(File).to receive(:write).with('.knapsack_pro/KnapsackPro-Adapters-BaseAdapter-bind_method_called_for_node_0.txt', nil)
|
|
144
|
-
|
|
145
|
-
expect(KnapsackPro::Config::Env).to receive(:regular_mode?).and_return(regular_mode?)
|
|
146
|
-
expect(KnapsackPro::Config::Env).to receive(:queue_mode?).and_return(queue_mode?)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
after { subject.bind }
|
|
150
|
-
|
|
151
|
-
context 'when regular mode enabled' do
|
|
152
|
-
let(:regular_mode?) { true }
|
|
153
|
-
|
|
154
|
-
before do
|
|
155
|
-
allow(subject).to receive(:bind_time_tracker)
|
|
156
|
-
allow(subject).to receive(:bind_save_report)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
it do
|
|
160
|
-
logger = instance_double(Logger)
|
|
161
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
162
|
-
expect(logger).to receive(:debug).with('Regular Mode enabled.')
|
|
163
|
-
end
|
|
164
|
-
it { expect(subject).to receive(:bind_time_tracker) }
|
|
165
|
-
it { expect(subject).to receive(:bind_save_report) }
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context 'when queue mode enabled' do
|
|
169
|
-
let(:queue_mode?) { true }
|
|
170
|
-
|
|
171
|
-
it 'calls queue hooks in proper order before binding time tracker' do
|
|
172
|
-
logger = instance_double(Logger)
|
|
173
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
174
|
-
expect(logger).to receive(:debug).with('Queue Mode enabled.')
|
|
175
|
-
|
|
176
|
-
expect(subject).to receive(:bind_before_queue_hook).ordered
|
|
177
|
-
expect(subject).to receive(:bind_after_queue_hook).ordered
|
|
178
|
-
expect(subject).to receive(:bind_time_tracker).ordered
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
context 'when regular mode and queue mode disabled' do
|
|
183
|
-
it { expect(subject).not_to receive(:bind_save_report) }
|
|
184
|
-
it { expect(subject).not_to receive(:bind_before_queue_hook) }
|
|
185
|
-
it { expect(subject).not_to receive(:bind_after_queue_hook) }
|
|
186
|
-
it { expect(subject).not_to receive(:bind_time_tracker) }
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
describe '#bind_time_tracker' do
|
|
191
|
-
it do
|
|
192
|
-
expect {
|
|
193
|
-
subject.bind_time_tracker
|
|
194
|
-
}.to raise_error(NotImplementedError)
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
describe '#bind_save_report' do
|
|
199
|
-
it do
|
|
200
|
-
expect {
|
|
201
|
-
subject.bind_save_report
|
|
202
|
-
}.to raise_error(NotImplementedError)
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
describe '#bind_before_queue_hook' do
|
|
207
|
-
it do
|
|
208
|
-
expect {
|
|
209
|
-
subject.bind_before_queue_hook
|
|
210
|
-
}.to raise_error(NotImplementedError)
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
describe '#bind_after_queue_hook' do
|
|
215
|
-
it do
|
|
216
|
-
expect {
|
|
217
|
-
subject.bind_after_queue_hook
|
|
218
|
-
}.to raise_error(NotImplementedError)
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
end
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Adapters::CucumberAdapter do
|
|
2
|
-
it do
|
|
3
|
-
expect(described_class::TEST_DIR_PATTERN).to eq 'features/**{,/*/**}/*.feature'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
context do
|
|
7
|
-
context 'when Cucumber version 1' do
|
|
8
|
-
before do
|
|
9
|
-
stub_const('Cucumber::VERSION', '1.3.20')
|
|
10
|
-
allow(::Cucumber::RbSupport::RbDsl).to receive(:register_rb_hook)
|
|
11
|
-
allow(Kernel).to receive(:at_exit)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it_behaves_like 'adapter'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
context 'when Cucumber version 2' do
|
|
18
|
-
before do
|
|
19
|
-
stub_const('Cucumber::VERSION', '2')
|
|
20
|
-
allow(::Cucumber::RbSupport::RbDsl).to receive(:register_rb_hook)
|
|
21
|
-
allow(Kernel).to receive(:at_exit)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it_behaves_like 'adapter'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'when Cucumber version 3' do
|
|
28
|
-
before do
|
|
29
|
-
stub_const('Cucumber::VERSION', '3.0.0')
|
|
30
|
-
allow(::Cucumber::Glue::Dsl).to receive(:register_rb_hook)
|
|
31
|
-
allow(Kernel).to receive(:at_exit)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it_behaves_like 'adapter'
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '.test_path' do
|
|
39
|
-
context 'when Cucumber version 1' do
|
|
40
|
-
subject { described_class.test_path(scenario_or_outline_table) }
|
|
41
|
-
|
|
42
|
-
before { stub_const('Cucumber::VERSION', '1') }
|
|
43
|
-
|
|
44
|
-
context 'when cucumber >= 1.3' do
|
|
45
|
-
context 'when scenario' do
|
|
46
|
-
let(:scenario_file) { 'features/scenario.feature' }
|
|
47
|
-
let(:scenario_or_outline_table) { double(file: scenario_file) }
|
|
48
|
-
|
|
49
|
-
it { should eql scenario_file }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context 'when scenario outline' do
|
|
53
|
-
let(:scenario_outline_file) { 'features/scenario_outline.feature' }
|
|
54
|
-
let(:scenario_or_outline_table) do
|
|
55
|
-
double(scenario_outline: double(file: scenario_outline_file))
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it { should eql scenario_outline_file }
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context 'when cucumber < 1.3' do
|
|
63
|
-
context 'when scenario' do
|
|
64
|
-
let(:scenario_file) { 'features/scenario.feature' }
|
|
65
|
-
let(:scenario_or_outline_table) { double(feature: double(file: scenario_file)) }
|
|
66
|
-
|
|
67
|
-
it { should eql scenario_file }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context 'when scenario outline' do
|
|
71
|
-
let(:scenario_outline_file) { 'features/scenario_outline.feature' }
|
|
72
|
-
let(:scenario_or_outline_table) do
|
|
73
|
-
double(scenario_outline: double(feature: double(file: scenario_outline_file)))
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it { should eql scenario_outline_file }
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context 'when Cucumber version 2' do
|
|
82
|
-
let(:file) { 'features/a.feature' }
|
|
83
|
-
let(:test_case) { double(location: double(file: file)) } # Cucumber 2
|
|
84
|
-
|
|
85
|
-
subject { described_class.test_path(test_case) }
|
|
86
|
-
|
|
87
|
-
before { stub_const('Cucumber::VERSION', '2') }
|
|
88
|
-
|
|
89
|
-
it { should eql file }
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
describe 'bind methods' do
|
|
94
|
-
describe '#bind_time_tracker' do
|
|
95
|
-
let(:file) { 'features/a.feature' }
|
|
96
|
-
let(:block) { double }
|
|
97
|
-
let(:tracker) { instance_double(KnapsackPro::Tracker) }
|
|
98
|
-
let(:logger) { instance_double(Logger) }
|
|
99
|
-
let(:global_time) { 'Global time: 01m 05s' }
|
|
100
|
-
|
|
101
|
-
context 'when Cucumber version 1' do
|
|
102
|
-
let(:scenario) { double(file: file) }
|
|
103
|
-
|
|
104
|
-
before { stub_const('Cucumber::VERSION', '1.3.20') }
|
|
105
|
-
|
|
106
|
-
it do
|
|
107
|
-
expect(subject).to receive(:Around).and_yield(scenario, block)
|
|
108
|
-
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
|
109
|
-
expect(tracker).to receive(:current_test_path=).with(file)
|
|
110
|
-
expect(tracker).to receive(:start_timer)
|
|
111
|
-
expect(block).to receive(:call)
|
|
112
|
-
expect(tracker).to receive(:stop_timer)
|
|
113
|
-
|
|
114
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
115
|
-
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
|
116
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
117
|
-
expect(logger).to receive(:debug).with(global_time)
|
|
118
|
-
|
|
119
|
-
subject.bind_time_tracker
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context 'when Cucumber version 2' do
|
|
124
|
-
let(:test_case) { double(location: double(file: file)) }
|
|
125
|
-
|
|
126
|
-
# complex version name to ensure we can catch that too
|
|
127
|
-
before { stub_const('Cucumber::VERSION', '2.0.0.rc.5') }
|
|
128
|
-
|
|
129
|
-
it do
|
|
130
|
-
expect(subject).to receive(:Around).and_yield(test_case, block)
|
|
131
|
-
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
|
132
|
-
expect(tracker).to receive(:current_test_path=).with(file)
|
|
133
|
-
expect(tracker).to receive(:start_timer)
|
|
134
|
-
expect(block).to receive(:call)
|
|
135
|
-
expect(tracker).to receive(:stop_timer)
|
|
136
|
-
|
|
137
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
138
|
-
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
|
139
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
140
|
-
expect(logger).to receive(:debug).with(global_time)
|
|
141
|
-
|
|
142
|
-
subject.bind_time_tracker
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
describe '#bind_save_report' do
|
|
148
|
-
it do
|
|
149
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
150
|
-
|
|
151
|
-
expect(KnapsackPro::Report).to receive(:save)
|
|
152
|
-
|
|
153
|
-
subject.bind_save_report
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context 'when cucumber tests failed' do
|
|
157
|
-
let(:exit_status) { double }
|
|
158
|
-
let(:latest_error) { instance_double(SystemExit, status: exit_status) }
|
|
159
|
-
|
|
160
|
-
it 'preserves cucumber latest error message exit status' do
|
|
161
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
162
|
-
|
|
163
|
-
expect(latest_error).to receive(:is_a?).with(SystemExit).and_return(true)
|
|
164
|
-
expect(KnapsackPro::Report).to receive(:save)
|
|
165
|
-
expect(::Kernel).to receive(:exit).with(exit_status)
|
|
166
|
-
|
|
167
|
-
subject.bind_save_report(latest_error)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
describe '#bind_before_queue_hook' do
|
|
173
|
-
let(:block) { double }
|
|
174
|
-
let(:scenario) { double(:scenario) }
|
|
175
|
-
|
|
176
|
-
context 'when KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED is not set' do
|
|
177
|
-
before { stub_const("ENV", {}) }
|
|
178
|
-
|
|
179
|
-
it do
|
|
180
|
-
expect(subject).to receive(:Around).and_yield(scenario, block)
|
|
181
|
-
|
|
182
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_before_queue)
|
|
183
|
-
expect(ENV).to receive(:[]=).with('KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED', 'true')
|
|
184
|
-
|
|
185
|
-
expect(block).to receive(:call)
|
|
186
|
-
|
|
187
|
-
subject.bind_before_queue_hook
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
context 'when KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED is set' do
|
|
192
|
-
before { stub_const("ENV", { 'KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED' => 'true' }) }
|
|
193
|
-
|
|
194
|
-
it do
|
|
195
|
-
expect(subject).to receive(:Around).and_yield(scenario, block)
|
|
196
|
-
|
|
197
|
-
expect(KnapsackPro::Hooks::Queue).not_to receive(:call_before_queue)
|
|
198
|
-
|
|
199
|
-
expect(block).to receive(:call)
|
|
200
|
-
|
|
201
|
-
subject.bind_before_queue_hook
|
|
202
|
-
end
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
describe '#bind_after_queue_hook' do
|
|
207
|
-
it do
|
|
208
|
-
expect(::Kernel).to receive(:at_exit).and_yield
|
|
209
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
|
|
210
|
-
expect(KnapsackPro::Report).to receive(:save_subset_queue_to_file)
|
|
211
|
-
|
|
212
|
-
subject.bind_after_queue_hook
|
|
213
|
-
end
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
end
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
module FakeMinitest
|
|
2
|
-
class Test < ::Minitest::Test
|
|
3
|
-
include KnapsackPro::Adapters::MinitestAdapter::BindTimeTrackerMinitestPlugin
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
class TestQueueMode < ::Minitest::Test
|
|
7
|
-
include KnapsackPro::Adapters::MinitestAdapter::BindQueueModeMinitestPlugin
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe KnapsackPro::Adapters::MinitestAdapter do
|
|
12
|
-
it do
|
|
13
|
-
expect(described_class::TEST_DIR_PATTERN).to eq 'test/**{,/*/**}/*_test.rb'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
describe '.test_path' do
|
|
17
|
-
subject { described_class.test_path(obj) }
|
|
18
|
-
|
|
19
|
-
before do
|
|
20
|
-
parent_of_test_dir = File.expand_path('../../../', File.dirname(__FILE__))
|
|
21
|
-
parent_of_test_dir_regexp = Regexp.new("^#{parent_of_test_dir}")
|
|
22
|
-
described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir_regexp)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
context 'when regular test' do
|
|
26
|
-
class FakeUserTest
|
|
27
|
-
def test_user_age; end
|
|
28
|
-
|
|
29
|
-
# method provided by Minitest
|
|
30
|
-
# it returns test method name
|
|
31
|
-
def name
|
|
32
|
-
:test_user_age
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
let(:obj) { FakeUserTest.new }
|
|
37
|
-
|
|
38
|
-
it { should eq './spec/knapsack_pro/adapters/minitest_adapter_spec.rb' }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context 'when shared examples test' do
|
|
42
|
-
module FakeSharedExamples
|
|
43
|
-
def test_from_shared_example; end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class FakeSharedExamplesUserTest
|
|
47
|
-
include FakeSharedExamples
|
|
48
|
-
|
|
49
|
-
def location
|
|
50
|
-
"test that use FakeSharedExamples#test_from_shared_example"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
let(:obj) { FakeSharedExamplesUserTest.new }
|
|
55
|
-
|
|
56
|
-
it { should eq './spec/knapsack_pro/adapters/minitest_adapter_spec.rb' }
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe 'BindTimeTrackerMinitestPlugin' do
|
|
61
|
-
let(:tracker) { instance_double(KnapsackPro::Tracker) }
|
|
62
|
-
|
|
63
|
-
subject { ::FakeMinitest::Test.new }
|
|
64
|
-
|
|
65
|
-
before do
|
|
66
|
-
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe '#before_setup' do
|
|
70
|
-
let(:file) { 'test/models/user_test.rb' }
|
|
71
|
-
|
|
72
|
-
it do
|
|
73
|
-
expect(described_class).to receive(:test_path).with(subject).and_return(file)
|
|
74
|
-
expect(tracker).to receive(:current_test_path=).with(file)
|
|
75
|
-
expect(tracker).to receive(:start_timer)
|
|
76
|
-
|
|
77
|
-
subject.before_setup
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
describe '#after_teardown' do
|
|
82
|
-
it do
|
|
83
|
-
expect(tracker).to receive(:stop_timer)
|
|
84
|
-
|
|
85
|
-
subject.after_teardown
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
describe 'BindQueueModeMinitestPlugin' do
|
|
91
|
-
let(:tracker) { instance_double(KnapsackPro::Tracker) }
|
|
92
|
-
|
|
93
|
-
subject { ::FakeMinitest::TestQueueMode.new }
|
|
94
|
-
|
|
95
|
-
before do
|
|
96
|
-
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
describe '#before_setup' do
|
|
100
|
-
let(:file) { 'test/models/user_test.rb' }
|
|
101
|
-
|
|
102
|
-
before do
|
|
103
|
-
stub_const('ENV', {
|
|
104
|
-
'KNAPSACK_PRO_BEFORE_QUEUE_HOOK_CALLED' => nil,
|
|
105
|
-
})
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it do
|
|
109
|
-
expect(KnapsackPro::Hooks::Queue).to receive(:call_before_queue).once
|
|
110
|
-
|
|
111
|
-
expect(described_class).to receive(:test_path).with(subject).twice.and_return(file)
|
|
112
|
-
expect(tracker).to receive(:current_test_path=).with(file).twice
|
|
113
|
-
expect(tracker).to receive(:start_timer).twice
|
|
114
|
-
|
|
115
|
-
subject.before_setup
|
|
116
|
-
|
|
117
|
-
# second call should not trigger KnapsackPro::Hooks::Queue.call_before_queue
|
|
118
|
-
subject.before_setup
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
describe '#after_teardown' do
|
|
123
|
-
it do
|
|
124
|
-
expect(tracker).to receive(:stop_timer)
|
|
125
|
-
|
|
126
|
-
subject.after_teardown
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
describe 'bind methods' do
|
|
132
|
-
describe '#bind_time_tracker' do
|
|
133
|
-
let(:logger) { instance_double(Logger) }
|
|
134
|
-
let(:global_time) { 'Global time: 01m 05s' }
|
|
135
|
-
|
|
136
|
-
it do
|
|
137
|
-
expect(::Minitest::Test).to receive(:send).with(:include, KnapsackPro::Adapters::MinitestAdapter::BindTimeTrackerMinitestPlugin)
|
|
138
|
-
|
|
139
|
-
expect(::Minitest).to receive(:after_run).and_yield
|
|
140
|
-
|
|
141
|
-
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
|
142
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
143
|
-
expect(logger).to receive(:debug).with(global_time)
|
|
144
|
-
|
|
145
|
-
subject.bind_time_tracker
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
describe '#bind_save_report' do
|
|
150
|
-
it do
|
|
151
|
-
expect(::Minitest).to receive(:after_run).and_yield
|
|
152
|
-
|
|
153
|
-
expect(KnapsackPro::Report).to receive(:save)
|
|
154
|
-
|
|
155
|
-
subject.bind_save_report
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
describe '#bind_queue_mode' do
|
|
160
|
-
let(:logger) { instance_double(Logger) }
|
|
161
|
-
let(:global_time) { 'Global time: 01m 05s' }
|
|
162
|
-
|
|
163
|
-
it do
|
|
164
|
-
expect(::Minitest::Test).to receive(:send).with(:include, KnapsackPro::Adapters::MinitestAdapter::BindQueueModeMinitestPlugin)
|
|
165
|
-
|
|
166
|
-
expect(::Minitest).to receive(:after_run).and_yield
|
|
167
|
-
|
|
168
|
-
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
|
169
|
-
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
|
170
|
-
expect(logger).to receive(:debug).with(global_time)
|
|
171
|
-
|
|
172
|
-
subject.bind_queue_mode
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
describe '#set_test_helper_path' do
|
|
178
|
-
let(:adapter) { described_class.new }
|
|
179
|
-
let(:test_helper_path) { '/code/project/test/test_helper.rb' }
|
|
180
|
-
|
|
181
|
-
subject { adapter.set_test_helper_path(test_helper_path) }
|
|
182
|
-
|
|
183
|
-
after do
|
|
184
|
-
expect(described_class.class_variable_get(:@@parent_of_test_dir)).to eq '/code/project'
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it { should eql '/code/project' }
|
|
188
|
-
end
|
|
189
|
-
end
|