knapsack_pro 7.0.0 → 7.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/.gitignore +1 -1
- data/CHANGELOG.md +16 -0
- data/README.md +7 -5
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +8 -0
- data/lib/knapsack_pro/pure/queue/rspec_pure.rb +9 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +7 -2
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/integration/runners/queue/rspec_runner.rb +3 -3
- data/spec/integration/runners/queue/rspec_runner_spec.rb +186 -11
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +54 -0
- data/spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb +30 -0
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +1 -1
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +33 -9
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 832322e0370ece75c8c2e53870b526e6bc4cd3f43214d4ee893a48cef6b209af
|
|
4
|
+
data.tar.gz: a3847464969d15278d84d00d9638c9e6e2cecea0190be5f773c70da0117c0d44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3648e3a7f77b8acfac104dc32a6f99cca7d86456cadd2127ff3b8e6d0a874df452398b5a266a887d54c9c239bf28727501a524cc3351adbb676b8887e272014
|
|
7
|
+
data.tar.gz: c7212ef6b958a7bb7aec2add6e6dc9d02e753936401f8d7705b4799c4ef1bb2b20c3456d1ad165b9e8ece86873b7393ee7afe1aa260c798b8644e6ace039fb17
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### 7.1.0
|
|
4
|
+
|
|
5
|
+
* [RSpec] [Queue Mode] Log error message and backtrace when unexpected failure is raised
|
|
6
|
+
|
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/249
|
|
8
|
+
|
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.0.1...v7.1.0
|
|
10
|
+
|
|
11
|
+
### 7.0.1
|
|
12
|
+
|
|
13
|
+
* fix(RSpec): conditionally adds `--require rails_helper` to cli arguments of `KnapsackPro::Runners::Queue::RSpecRunner`. Version 7.0.0 introduced some fundamental changes, namely fetching, loading and running batches of specs **after** executing suite hooks, so that such hooks are only ran once, not before every batch. As a result, if `rails_helper` is only required in spec files, which is the RSpec default, instead of e.g. in `.rspec`, then some `before(:suite)` hooks, e.g. defined by gems, are registered after suite hooks had already been executed by the test suite. By comparison, RSpec loads all the spec files **before** executing `before(:suite)` hooks.
|
|
14
|
+
|
|
15
|
+
PR with the above changes: https://github.com/KnapsackPro/knapsack_pro-ruby/pull/243
|
|
16
|
+
|
|
17
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.0.0...v7.0.1
|
|
18
|
+
|
|
3
19
|
### 7.0.0
|
|
4
20
|
|
|
5
21
|
* __(breaking change)__ RSpec in Queue Mode:
|
data/README.md
CHANGED
|
@@ -74,30 +74,32 @@ Scripted tests can be found in the [Rails App With Knapsack Pro repository](http
|
|
|
74
74
|
|
|
75
75
|
### Publishing
|
|
76
76
|
|
|
77
|
-
Update the
|
|
77
|
+
1. Update the `CHANGELOG.md` as part of your PR.
|
|
78
|
+
|
|
79
|
+
2. After your PR has been merged, update the gem version in `lib/knapsack_pro/version.rb` directly on the `master` branch:
|
|
78
80
|
|
|
79
81
|
```bash
|
|
80
82
|
git commit -m "Bump version X.X.X"
|
|
81
83
|
git push origin master
|
|
82
84
|
```
|
|
83
85
|
|
|
84
|
-
Create a git tag for the release:
|
|
86
|
+
3. Create a git tag for the release:
|
|
85
87
|
|
|
86
88
|
```bash
|
|
87
89
|
git tag -a vX.X.X -m "Release vX.X.X"
|
|
88
90
|
git push --tags
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-
Build the gem and publish it to RubyGems:
|
|
93
|
+
4. Build the gem and publish it to RubyGems:
|
|
92
94
|
|
|
93
95
|
```bash
|
|
94
96
|
gem build knapsack_pro.gemspec
|
|
95
97
|
gem push knapsack_pro-X.X.X.gem
|
|
96
98
|
```
|
|
97
99
|
|
|
98
|
-
Update the latest available gem version in `TestSuiteClientVersionChecker` for the Knapsack Pro API repository.
|
|
100
|
+
5. Update the latest available gem version in `TestSuiteClientVersionChecker` for the Knapsack Pro API repository.
|
|
99
101
|
|
|
100
|
-
Update the `knapsack_pro` gem version in:
|
|
102
|
+
6. Update the `knapsack_pro` gem version in:
|
|
101
103
|
|
|
102
104
|
- [Rails App With Knapsack Pro repository](https://github.com/KnapsackPro/rails-app-with-knapsack_pro)
|
|
103
105
|
- Knapsack Pro API internal repository
|
|
@@ -52,6 +52,10 @@ module KnapsackPro
|
|
|
52
52
|
!!parsed_options(cli_args)&.[](:formatters)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
def self.has_require_rails_helper_option?(cli_args)
|
|
56
|
+
(parsed_options(cli_args)&.[](:requires) || []).include?("rails_helper")
|
|
57
|
+
end
|
|
58
|
+
|
|
55
59
|
def self.order_option(cli_args)
|
|
56
60
|
parsed_options(cli_args)&.[](:order)
|
|
57
61
|
end
|
|
@@ -76,6 +80,10 @@ module KnapsackPro
|
|
|
76
80
|
id.match(/\A(.*?)(?:\[([\d\s:,]+)\])?\z/).captures.first
|
|
77
81
|
end
|
|
78
82
|
|
|
83
|
+
def self.rails_helper_exists?(test_dir)
|
|
84
|
+
File.exist?("#{test_dir}/rails_helper.rb")
|
|
85
|
+
end
|
|
86
|
+
|
|
79
87
|
# private
|
|
80
88
|
def self.top_level_group(example)
|
|
81
89
|
group = example.metadata[:example_group]
|
|
@@ -34,9 +34,10 @@ module KnapsackPro
|
|
|
34
34
|
args + ['--seed', seed.value]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def prepare_cli_args(args, has_format_option, test_dir)
|
|
37
|
+
def prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir)
|
|
38
38
|
(args || '').split
|
|
39
39
|
.yield_self { args_with_at_least_one_formatter(_1, has_format_option) }
|
|
40
|
+
.yield_self { args_with_require_rails_helper_if_needed(_1, has_require_rails_helper_option, rails_helper_exists) }
|
|
40
41
|
.yield_self { args_with_default_options(_1, test_dir) }
|
|
41
42
|
end
|
|
42
43
|
|
|
@@ -75,6 +76,13 @@ module KnapsackPro
|
|
|
75
76
|
cli_args + ['--format', 'progress']
|
|
76
77
|
end
|
|
77
78
|
|
|
79
|
+
def args_with_require_rails_helper_if_needed(cli_args, has_require_rails_helper_option, rails_helper_exists)
|
|
80
|
+
return cli_args if has_require_rails_helper_option
|
|
81
|
+
return cli_args unless rails_helper_exists
|
|
82
|
+
|
|
83
|
+
cli_args + ['--require', 'rails_helper']
|
|
84
|
+
end
|
|
85
|
+
|
|
78
86
|
def args_with_default_options(cli_args, test_dir)
|
|
79
87
|
new_cli_args = cli_args + [
|
|
80
88
|
'--default-path', test_dir,
|
|
@@ -24,8 +24,11 @@ module KnapsackPro
|
|
|
24
24
|
super(adapter_class)
|
|
25
25
|
@adapter_class = adapter_class
|
|
26
26
|
@rspec_pure = rspec_pure
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
args_array = (args || '').split
|
|
28
|
+
has_format_option = @adapter_class.has_format_option?(args_array)
|
|
29
|
+
has_require_rails_helper_option = @adapter_class.has_require_rails_helper_option?(args_array)
|
|
30
|
+
rails_helper_exists = @adapter_class.rails_helper_exists?(test_dir)
|
|
31
|
+
@cli_args = rspec_pure.prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir)
|
|
29
32
|
@stream_error = stream_error
|
|
30
33
|
@stream_out = stream_out
|
|
31
34
|
@node_test_file_paths = []
|
|
@@ -53,6 +56,8 @@ module KnapsackPro
|
|
|
53
56
|
Kernel.exit(exit_code)
|
|
54
57
|
rescue Exception => exception
|
|
55
58
|
KnapsackPro.logger.error("An unexpected exception happened. RSpec cannot handle it. The exception: #{exception.inspect}")
|
|
59
|
+
KnapsackPro.logger.error("Exception message: #{exception.message}")
|
|
60
|
+
KnapsackPro.logger.error("Exception backtrace: #{exception.backtrace.join("\n")}")
|
|
56
61
|
|
|
57
62
|
message = @rspec_pure.exit_summary(unexecuted_test_files)
|
|
58
63
|
KnapsackPro.logger.warn(message) if message
|
data/lib/knapsack_pro/version.rb
CHANGED
|
@@ -26,7 +26,7 @@ module KnapsackProExtensions
|
|
|
26
26
|
@batch_index += 1
|
|
27
27
|
|
|
28
28
|
if SHOW_DEBUG_LOG
|
|
29
|
-
IntegrationTestLogger.log("
|
|
29
|
+
IntegrationTestLogger.log("Stubbed tests from the Queue API: #{tests.inspect}")
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
tests
|
|
@@ -41,13 +41,13 @@ module KnapsackProExtensions
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
return unless SHOW_DEBUG_LOG
|
|
44
|
-
IntegrationTestLogger.log("
|
|
44
|
+
IntegrationTestLogger.log("Stubbed the #{__method__} method")
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
module RSpecAdapter
|
|
49
49
|
def test_file_cases_for(slow_test_files)
|
|
50
|
-
IntegrationTestLogger.log("
|
|
50
|
+
IntegrationTestLogger.log("Stubbed test file cases for slow test files: #{slow_test_files}")
|
|
51
51
|
|
|
52
52
|
test_file_paths = JSON.load(ENV.fetch('TEST__TEST_FILE_CASES_FOR_SLOW_TEST_FILES'))
|
|
53
53
|
test_file_paths.map do |path|
|
|
@@ -32,13 +32,18 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
32
32
|
)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
def create_rails_helper_file(rails_helper)
|
|
36
|
+
rails_helper_path = "#{SPEC_DIRECTORY}/rails_helper.rb"
|
|
37
|
+
File.open(rails_helper_path, 'w') { |file| file.write(rails_helper) }
|
|
38
|
+
end
|
|
39
|
+
|
|
35
40
|
def stub_spec_batches(batched_tests)
|
|
36
41
|
ENV['TEST__SPEC_BATCHES'] = batched_tests.to_json
|
|
37
42
|
end
|
|
38
43
|
|
|
39
44
|
# @param test_file_paths Array[String]
|
|
40
45
|
# Example: ['spec_integration/a_spec.rb[1:1]']
|
|
41
|
-
def
|
|
46
|
+
def stub_test_cases_for_slow_test_files(test_file_paths)
|
|
42
47
|
ENV['TEST__TEST_FILE_CASES_FOR_SLOW_TEST_FILES'] = test_file_paths.to_json
|
|
43
48
|
end
|
|
44
49
|
|
|
@@ -327,6 +332,174 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
327
332
|
end
|
|
328
333
|
end
|
|
329
334
|
|
|
335
|
+
context 'when rails_helper file does not exist' do
|
|
336
|
+
it 'does not require the rails_helper file when running RSpec' do
|
|
337
|
+
rspec_options = ''
|
|
338
|
+
|
|
339
|
+
spec_helper = <<~SPEC
|
|
340
|
+
require 'knapsack_pro'
|
|
341
|
+
KnapsackPro::Adapters::RSpecAdapter.bind
|
|
342
|
+
SPEC
|
|
343
|
+
|
|
344
|
+
spec_a = Spec.new('a_spec.rb', <<~SPEC)
|
|
345
|
+
describe 'A_describe' do
|
|
346
|
+
it 'A1 test example' do
|
|
347
|
+
expect(1).to eq 1
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
SPEC
|
|
351
|
+
|
|
352
|
+
spec_b = Spec.new('b_spec.rb', <<~SPEC)
|
|
353
|
+
describe 'B_describe' do
|
|
354
|
+
it 'B1 test example' do
|
|
355
|
+
expect(1).to eq 1
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
SPEC
|
|
359
|
+
|
|
360
|
+
spec_c = Spec.new('c_spec.rb', <<~SPEC)
|
|
361
|
+
describe 'C_describe' do
|
|
362
|
+
it 'C1 test example' do
|
|
363
|
+
expect(1).to eq 1
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
SPEC
|
|
367
|
+
|
|
368
|
+
generate_specs(spec_helper, rspec_options, [
|
|
369
|
+
[spec_a, spec_b],
|
|
370
|
+
[spec_c],
|
|
371
|
+
])
|
|
372
|
+
|
|
373
|
+
actual = subject
|
|
374
|
+
|
|
375
|
+
expect(actual.stdout).to_not include('--require rails_helper')
|
|
376
|
+
|
|
377
|
+
expect(actual.exit_code).to eq 0
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
context 'when rails_helper file exists' do
|
|
382
|
+
it 'requires the rails_helper file when running RSpec and runs hooks defined within it' do
|
|
383
|
+
rspec_options = ''
|
|
384
|
+
|
|
385
|
+
spec_helper = <<~SPEC
|
|
386
|
+
require 'knapsack_pro'
|
|
387
|
+
KnapsackPro::Adapters::RSpecAdapter.bind
|
|
388
|
+
SPEC
|
|
389
|
+
|
|
390
|
+
spec_a = Spec.new('a_spec.rb', <<~SPEC)
|
|
391
|
+
describe 'A_describe' do
|
|
392
|
+
it 'A1 test example' do
|
|
393
|
+
expect(1).to eq 1
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
SPEC
|
|
397
|
+
|
|
398
|
+
spec_b = Spec.new('b_spec.rb', <<~SPEC)
|
|
399
|
+
describe 'B_describe' do
|
|
400
|
+
it 'B1 test example' do
|
|
401
|
+
expect(1).to eq 1
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
SPEC
|
|
405
|
+
|
|
406
|
+
spec_c = Spec.new('c_spec.rb', <<~SPEC)
|
|
407
|
+
describe 'C_describe' do
|
|
408
|
+
it 'C1 test example' do
|
|
409
|
+
expect(1).to eq 1
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
SPEC
|
|
413
|
+
|
|
414
|
+
generate_specs(spec_helper, rspec_options, [
|
|
415
|
+
[spec_a, spec_b],
|
|
416
|
+
[spec_c],
|
|
417
|
+
])
|
|
418
|
+
|
|
419
|
+
rails_helper = <<~SPEC
|
|
420
|
+
RSpec.configure do |config|
|
|
421
|
+
config.before(:suite) do
|
|
422
|
+
puts 'RSpec_before_suite_hook_from_rails_helper'
|
|
423
|
+
end
|
|
424
|
+
config.after(:suite) do
|
|
425
|
+
puts 'RSpec_after_suite_hook_from_rails_helper'
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
SPEC
|
|
429
|
+
|
|
430
|
+
create_rails_helper_file(rails_helper)
|
|
431
|
+
|
|
432
|
+
actual = subject
|
|
433
|
+
|
|
434
|
+
expect(actual.stdout).to include('--require rails_helper')
|
|
435
|
+
expect(actual.stdout.scan(/RSpec_before_suite_hook_from_rails_helper/).size).to eq 1
|
|
436
|
+
expect(actual.stdout.scan(/RSpec_after_suite_hook_from_rails_helper/).size).to eq 1
|
|
437
|
+
|
|
438
|
+
expect(actual.exit_code).to eq 0
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
it 'runs suite hooks defined in rails_helper only once, even if file is required multiple times' do
|
|
442
|
+
rspec_options = ''
|
|
443
|
+
|
|
444
|
+
spec_helper = <<~SPEC
|
|
445
|
+
require 'knapsack_pro'
|
|
446
|
+
KnapsackPro::Adapters::RSpecAdapter.bind
|
|
447
|
+
SPEC
|
|
448
|
+
|
|
449
|
+
spec_a = Spec.new('a_spec.rb', <<~SPEC)
|
|
450
|
+
require 'rails_helper'
|
|
451
|
+
describe 'A_describe' do
|
|
452
|
+
it 'A1 test example' do
|
|
453
|
+
expect(1).to eq 1
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
SPEC
|
|
457
|
+
|
|
458
|
+
spec_b = Spec.new('b_spec.rb', <<~SPEC)
|
|
459
|
+
require 'rails_helper'
|
|
460
|
+
describe 'B_describe' do
|
|
461
|
+
it 'B1 test example' do
|
|
462
|
+
expect(1).to eq 1
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
SPEC
|
|
466
|
+
|
|
467
|
+
spec_c = Spec.new('c_spec.rb', <<~SPEC)
|
|
468
|
+
require 'rails_helper'
|
|
469
|
+
describe 'C_describe' do
|
|
470
|
+
it 'C1 test example' do
|
|
471
|
+
expect(1).to eq 1
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
SPEC
|
|
475
|
+
|
|
476
|
+
generate_specs(spec_helper, rspec_options, [
|
|
477
|
+
[spec_a, spec_b],
|
|
478
|
+
[spec_c],
|
|
479
|
+
])
|
|
480
|
+
|
|
481
|
+
rails_helper = <<~SPEC
|
|
482
|
+
RSpec.configure do |config|
|
|
483
|
+
config.before(:suite) do
|
|
484
|
+
puts 'RSpec_before_suite_hook_from_rails_helper'
|
|
485
|
+
end
|
|
486
|
+
config.after(:suite) do
|
|
487
|
+
puts 'RSpec_after_suite_hook_from_rails_helper'
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
SPEC
|
|
491
|
+
|
|
492
|
+
create_rails_helper_file(rails_helper)
|
|
493
|
+
|
|
494
|
+
actual = subject
|
|
495
|
+
|
|
496
|
+
expect(actual.stdout.scan(/RSpec_before_suite_hook_from_rails_helper/).size).to eq 1
|
|
497
|
+
expect(actual.stdout.scan(/RSpec_after_suite_hook_from_rails_helper/).size).to eq 1
|
|
498
|
+
|
|
499
|
+
expect(actual.exit_code).to eq 0
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
|
|
330
503
|
context 'when hooks are defined' do
|
|
331
504
|
it 'calls RSpec before/after hooks only once for multiple batches of tests' do
|
|
332
505
|
rspec_options = ''
|
|
@@ -942,6 +1115,8 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
942
1115
|
|
|
943
1116
|
expect(actual.stdout).to include('B_describe')
|
|
944
1117
|
expect(actual.stdout).to include('An unexpected exception happened. RSpec cannot handle it. The exception: #<NoMemoryError: NoMemoryError>')
|
|
1118
|
+
expect(actual.stdout).to include('Exception message: ')
|
|
1119
|
+
expect(actual.stdout).to include('Exception backtrace: ')
|
|
945
1120
|
expect(actual.stdout).to_not include('B1 test example')
|
|
946
1121
|
|
|
947
1122
|
expect(actual.stdout).to_not include('C1 test example')
|
|
@@ -1640,7 +1815,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1640
1815
|
before do
|
|
1641
1816
|
ENV['KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES'] = 'true'
|
|
1642
1817
|
|
|
1643
|
-
# remember to
|
|
1818
|
+
# remember to stub Queue API batches to include test examples (example: a_spec.rb[1:1])
|
|
1644
1819
|
# for the following slow test files
|
|
1645
1820
|
ENV['KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN'] = "#{SPEC_DIRECTORY}/a_spec.rb"
|
|
1646
1821
|
end
|
|
@@ -1688,7 +1863,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1688
1863
|
generate_specs(spec_helper_with_knapsack, rspec_options, [
|
|
1689
1864
|
[spec_a, spec_b, spec_c]
|
|
1690
1865
|
])
|
|
1691
|
-
|
|
1866
|
+
stub_test_cases_for_slow_test_files([
|
|
1692
1867
|
"#{spec_a.path}[1:1]",
|
|
1693
1868
|
"#{spec_a.path}[1:2]",
|
|
1694
1869
|
])
|
|
@@ -1736,7 +1911,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1736
1911
|
before do
|
|
1737
1912
|
ENV['KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES'] = 'true'
|
|
1738
1913
|
|
|
1739
|
-
# remember to
|
|
1914
|
+
# remember to stub Queue API batches to include test examples (example: a_spec.rb[1:1])
|
|
1740
1915
|
# for the following slow test files
|
|
1741
1916
|
ENV['KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN'] = "#{SPEC_DIRECTORY}/a_spec.rb"
|
|
1742
1917
|
end
|
|
@@ -1784,7 +1959,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1784
1959
|
generate_specs(spec_helper_with_knapsack, rspec_options, [
|
|
1785
1960
|
[spec_a, spec_b, spec_c]
|
|
1786
1961
|
])
|
|
1787
|
-
|
|
1962
|
+
stub_test_cases_for_slow_test_files([
|
|
1788
1963
|
"#{spec_a.path}[1:1]",
|
|
1789
1964
|
"#{spec_a.path}[1:2]",
|
|
1790
1965
|
])
|
|
@@ -1814,7 +1989,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1814
1989
|
before do
|
|
1815
1990
|
ENV['KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES'] = 'true'
|
|
1816
1991
|
|
|
1817
|
-
# remember to
|
|
1992
|
+
# remember to stub Queue API batches to include test examples (example: a_spec.rb[1:1])
|
|
1818
1993
|
# for the following slow test files
|
|
1819
1994
|
ENV['KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN'] = "#{SPEC_DIRECTORY}/a_spec.rb"
|
|
1820
1995
|
end
|
|
@@ -1862,7 +2037,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1862
2037
|
generate_specs(spec_helper_with_knapsack, rspec_options, [
|
|
1863
2038
|
[spec_a, spec_b, spec_c]
|
|
1864
2039
|
])
|
|
1865
|
-
|
|
2040
|
+
stub_test_cases_for_slow_test_files([
|
|
1866
2041
|
"#{spec_a.path}[1:1]",
|
|
1867
2042
|
"#{spec_a.path}[1:2]",
|
|
1868
2043
|
])
|
|
@@ -1913,7 +2088,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1913
2088
|
before do
|
|
1914
2089
|
ENV['KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES'] = 'true'
|
|
1915
2090
|
|
|
1916
|
-
# remember to
|
|
2091
|
+
# remember to stub Queue API batches to include test examples (example: a_spec.rb[1:1])
|
|
1917
2092
|
# for the following slow test files
|
|
1918
2093
|
ENV['KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN'] = "#{SPEC_DIRECTORY}/a_spec.rb"
|
|
1919
2094
|
end
|
|
@@ -1961,7 +2136,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1961
2136
|
generate_specs(spec_helper_with_knapsack, rspec_options, [
|
|
1962
2137
|
[spec_a, spec_b, spec_c]
|
|
1963
2138
|
])
|
|
1964
|
-
|
|
2139
|
+
stub_test_cases_for_slow_test_files([
|
|
1965
2140
|
"#{spec_a.path}[1:1]",
|
|
1966
2141
|
"#{spec_a.path}[1:2]",
|
|
1967
2142
|
])
|
|
@@ -2010,7 +2185,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
2010
2185
|
before do
|
|
2011
2186
|
ENV['KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES'] = 'true'
|
|
2012
2187
|
|
|
2013
|
-
# remember to
|
|
2188
|
+
# remember to stub Queue API batches to include test examples (example: a_spec.rb[1:1])
|
|
2014
2189
|
# for the following slow test files
|
|
2015
2190
|
ENV['KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN'] = "#{SPEC_DIRECTORY}/a_spec.rb"
|
|
2016
2191
|
end
|
|
@@ -2068,7 +2243,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
2068
2243
|
generate_specs(spec_helper, rspec_options, [
|
|
2069
2244
|
[spec_a, spec_b, spec_c]
|
|
2070
2245
|
])
|
|
2071
|
-
|
|
2246
|
+
stub_test_cases_for_slow_test_files([
|
|
2072
2247
|
"#{spec_a.path}[1:1]",
|
|
2073
2248
|
"#{spec_a.path}[1:2]",
|
|
2074
2249
|
])
|
|
@@ -187,6 +187,60 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
|
187
187
|
end
|
|
188
188
|
end
|
|
189
189
|
|
|
190
|
+
describe '.has_require_rails_helper_option?' do
|
|
191
|
+
subject { described_class.has_require_rails_helper_option?(cli_args) }
|
|
192
|
+
|
|
193
|
+
context 'when require option is provided as -r' do
|
|
194
|
+
let(:cli_args) { ['-r', 'rails_helper'] }
|
|
195
|
+
|
|
196
|
+
it { expect(subject).to be true }
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
context 'when require option is provided as --require' do
|
|
200
|
+
let(:cli_args) { ['--require', 'rails_helper'] }
|
|
201
|
+
|
|
202
|
+
it { expect(subject).to be true }
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context 'when require option is provided without delimiter' do
|
|
206
|
+
let(:cli_args) { ['-rrails_helper'] }
|
|
207
|
+
|
|
208
|
+
it { expect(subject).to be true }
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
context 'when require option is not provided' do
|
|
212
|
+
let(:cli_args) { ['--fake', 'value'] }
|
|
213
|
+
|
|
214
|
+
it { expect(subject).to be false }
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
describe '.rails_helper_exists?' do
|
|
219
|
+
subject { described_class.rails_helper_exists?(test_dir) }
|
|
220
|
+
|
|
221
|
+
let(:test_dir) { 'spec_fake' }
|
|
222
|
+
|
|
223
|
+
context 'when rails_helper exists' do
|
|
224
|
+
before do
|
|
225
|
+
File.open("#{test_dir}/rails_helper.rb", 'w')
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
after do
|
|
229
|
+
FileUtils.rm("#{test_dir}/rails_helper.rb")
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it { expect(subject).to be true }
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context 'when rails_helper does not exist' do
|
|
236
|
+
before do
|
|
237
|
+
FileUtils.rm_f("#{test_dir}/rails_helper.rb")
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
it { expect(subject).to be false }
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
190
244
|
describe '.order_option' do
|
|
191
245
|
subject { described_class.order_option(cli_args) }
|
|
192
246
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require(KnapsackPro.root + '/lib/knapsack_pro/formatters/time_tracker')
|
|
2
|
+
|
|
3
|
+
describe KnapsackPro::Formatters::TimeTrackerFetcher do
|
|
4
|
+
describe '.unexecuted_test_files' do
|
|
5
|
+
subject { described_class.unexecuted_test_files(scheduled_paths) }
|
|
6
|
+
|
|
7
|
+
context 'when the time tracker formatter not found' do
|
|
8
|
+
let(:scheduled_paths) { ['a_spec.rb'] }
|
|
9
|
+
|
|
10
|
+
it do
|
|
11
|
+
expect(subject).to eq []
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'when the time tracker formatter is found' do
|
|
16
|
+
let(:time_tracker) { instance_double(KnapsackPro::Formatters::TimeTracker) }
|
|
17
|
+
let(:scheduled_paths) { ['a_spec.rb', 'b_spec.rb'] }
|
|
18
|
+
let(:unexecuted_test_files) { double(:unexecuted_test_files) }
|
|
19
|
+
|
|
20
|
+
before do
|
|
21
|
+
expect(described_class).to receive(:call).and_return(time_tracker)
|
|
22
|
+
expect(time_tracker).to receive(:unexecuted_test_files).with(scheduled_paths).and_return(unexecuted_test_files)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it do
|
|
26
|
+
expect(subject).to eq unexecuted_test_files
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -382,7 +382,7 @@ class TestTimeTracker
|
|
|
382
382
|
|
|
383
383
|
def run_specs(specs)
|
|
384
384
|
files = Array(specs).map.with_index do |spec, i|
|
|
385
|
-
file = Tempfile.new(["
|
|
385
|
+
file = Tempfile.new(["tmp_time_tracker_#{i}", "_spec.rb"], "./spec/knapsack_pro/formatters/")
|
|
386
386
|
file.write(spec)
|
|
387
387
|
file.rewind
|
|
388
388
|
file
|
|
@@ -117,31 +117,52 @@ describe KnapsackPro::Pure::Queue::RSpecPure do
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
describe '#prepare_cli_args' do
|
|
120
|
-
subject { rspec_pure.prepare_cli_args(args, has_format_option, test_dir) }
|
|
120
|
+
subject { rspec_pure.prepare_cli_args(args, has_format_option, has_require_rails_helper_option, rails_helper_exists, test_dir) }
|
|
121
121
|
|
|
122
122
|
context 'when no args' do
|
|
123
123
|
let(:args) { nil }
|
|
124
124
|
let(:has_format_option) { false }
|
|
125
|
+
let(:has_require_rails_helper_option) { false }
|
|
125
126
|
let(:test_dir) { 'spec' }
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
|
133
151
|
end
|
|
134
152
|
end
|
|
135
153
|
|
|
136
154
|
context 'when args are present and a custom test directory is set' do
|
|
137
|
-
let(:args) { '--color --profile' }
|
|
155
|
+
let(:args) { '--color --profile --require rails_helper' }
|
|
138
156
|
let(:has_format_option) { false }
|
|
157
|
+
let(:has_require_rails_helper_option) { true }
|
|
158
|
+
let(:rails_helper_exists) { true }
|
|
139
159
|
let(:test_dir) { 'custom_spec_dir' }
|
|
140
160
|
|
|
141
161
|
it do
|
|
142
162
|
expect(subject).to eq [
|
|
143
163
|
'--color',
|
|
144
164
|
'--profile',
|
|
165
|
+
'--require', 'rails_helper',
|
|
145
166
|
'--format', 'progress',
|
|
146
167
|
'--default-path', 'custom_spec_dir',
|
|
147
168
|
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
@@ -150,8 +171,10 @@ describe KnapsackPro::Pure::Queue::RSpecPure do
|
|
|
150
171
|
end
|
|
151
172
|
|
|
152
173
|
context 'when args are present and has format option' do
|
|
153
|
-
let(:args) { '--color --profile --format d' }
|
|
174
|
+
let(:args) { '--color --profile --format d --require rails_helper' }
|
|
154
175
|
let(:has_format_option) { true }
|
|
176
|
+
let(:has_require_rails_helper_option) { true }
|
|
177
|
+
let(:rails_helper_exists) { true }
|
|
155
178
|
let(:test_dir) { 'spec' }
|
|
156
179
|
|
|
157
180
|
it 'uses the format option from args instead of the default formatter' do
|
|
@@ -159,6 +182,7 @@ describe KnapsackPro::Pure::Queue::RSpecPure do
|
|
|
159
182
|
'--color',
|
|
160
183
|
'--profile',
|
|
161
184
|
'--format', 'd',
|
|
185
|
+
'--require', 'rails_helper',
|
|
162
186
|
'--default-path', 'spec',
|
|
163
187
|
'--format', 'KnapsackPro::Formatters::TimeTracker',
|
|
164
188
|
]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knapsack_pro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ArturT
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|
|
@@ -340,6 +340,7 @@ files:
|
|
|
340
340
|
- spec/knapsack_pro/crypto/decryptor_spec.rb
|
|
341
341
|
- spec/knapsack_pro/crypto/digestor_spec.rb
|
|
342
342
|
- spec/knapsack_pro/crypto/encryptor_spec.rb
|
|
343
|
+
- spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb
|
|
343
344
|
- spec/knapsack_pro/formatters/time_tracker_specs.rb
|
|
344
345
|
- spec/knapsack_pro/hooks/queue_spec.rb
|
|
345
346
|
- spec/knapsack_pro/logger_wrapper_spec.rb
|
|
@@ -462,6 +463,7 @@ test_files:
|
|
|
462
463
|
- spec/knapsack_pro/crypto/decryptor_spec.rb
|
|
463
464
|
- spec/knapsack_pro/crypto/digestor_spec.rb
|
|
464
465
|
- spec/knapsack_pro/crypto/encryptor_spec.rb
|
|
466
|
+
- spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb
|
|
465
467
|
- spec/knapsack_pro/formatters/time_tracker_specs.rb
|
|
466
468
|
- spec/knapsack_pro/hooks/queue_spec.rb
|
|
467
469
|
- spec/knapsack_pro/logger_wrapper_spec.rb
|