knapsack_pro 2.17.0 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +21 -0
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +4 -21
- data/lib/knapsack_pro/runners/rspec_runner.rb +3 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +98 -0
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +2 -17
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e5ae3f380ffe2e210417898e30fc7091abcc4fbcacab97b340e9e5ea5e700b
|
4
|
+
data.tar.gz: 481dda7a93c2ba5964fa3c20cf60bf2666432311c9a7f1bf59b3be1c905939bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 185add13dfe335fb6b83c1d4a0121f7e097535459c10356401176e1acea5722764554e8f44a2db2ccf806e9a3f4f0a77ca3f701b5b1bc65881d1771722992e67
|
7
|
+
data.tar.gz: a267ddf7469e2affd5e472661dbd2a4fdd17c7f58543dc2c40e305d905004ff7d85808f3e7705892cb4da7ea2dd6fac447ca4a30fc15f296abfafb4668f0f001
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 2.18.0
|
4
|
+
|
5
|
+
* Do not allow to use the RSpec tag option together with the RSpec split by test examples feature in knapsack_pro gem in Regular Mode
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/148
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.17.0...v2.18.0
|
10
|
+
|
3
11
|
### 2.17.0
|
4
12
|
|
5
13
|
* Use Ruby 3 in development and add small improvements
|
data/README.md
CHANGED
@@ -838,7 +838,7 @@ Here you can read how to configure [junit formatter](https://knapsackpro.com/faq
|
|
838
838
|
# spec_helper.rb or rails_helper.rb
|
839
839
|
|
840
840
|
# TODO This must be the same path as value for rspec --out argument
|
841
|
-
# Note the path should not contain
|
841
|
+
# Note the path should not contain ~ char, for instance path ~/project/tmp/rspec.xml may not work. Please use full path instead.
|
842
842
|
TMP_RSPEC_XML_REPORT = 'tmp/rspec.xml'
|
843
843
|
# move results to FINAL_RSPEC_XML_REPORT so the results won't accumulate with duplicated xml tags in TMP_RSPEC_XML_REPORT
|
844
844
|
FINAL_RSPEC_XML_REPORT = 'tmp/rspec_final_results.xml'
|
@@ -3,6 +3,27 @@ module KnapsackPro
|
|
3
3
|
class RSpecAdapter < BaseAdapter
|
4
4
|
TEST_DIR_PATTERN = 'spec/**{,/*/**}/*_spec.rb'
|
5
5
|
|
6
|
+
def self.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
|
7
|
+
if KnapsackPro::Config::Env.rspec_split_by_test_examples? && has_tag_option?(cli_args)
|
8
|
+
error_message = 'It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it#warning-dont-use-rspec-tag-option'
|
9
|
+
KnapsackPro.logger.error(error_message)
|
10
|
+
raise error_message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.has_tag_option?(cli_args)
|
15
|
+
# use start_with? because user can define tag option in a few ways:
|
16
|
+
# -t mytag
|
17
|
+
# -tmytag
|
18
|
+
# --tag mytag
|
19
|
+
# --tag=mytag
|
20
|
+
cli_args.any? { |arg| arg.start_with?('-t') || arg.start_with?('--tag') }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.has_format_option?(cli_args)
|
24
|
+
cli_args.any? { |arg| arg.start_with?('-f') || arg.start_with?('--format') }
|
25
|
+
end
|
26
|
+
|
6
27
|
def self.test_path(example_group)
|
7
28
|
if defined?(::Turnip) && ::Turnip::VERSION.to_i < 2
|
8
29
|
unless example_group[:turnip]
|
@@ -11,18 +11,14 @@ module KnapsackPro
|
|
11
11
|
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
|
12
12
|
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
|
13
13
|
|
14
|
-
|
14
|
+
adapter_class = KnapsackPro::Adapters::RSpecAdapter
|
15
|
+
runner = new(adapter_class)
|
15
16
|
|
16
17
|
cli_args = (args || '').split
|
17
|
-
|
18
|
-
if KnapsackPro::Config::Env.rspec_split_by_test_examples? && has_tag_option?(cli_args)
|
19
|
-
error_message = 'It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature. Please see: https://knapsackpro.com/faq/question/how-to-split-slow-rspec-test-files-by-test-examples-by-individual-it#warning-dont-use-rspec-tag-option'
|
20
|
-
KnapsackPro.logger.error(error_message)
|
21
|
-
raise error_message
|
22
|
-
end
|
18
|
+
adapter_class.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
|
23
19
|
|
24
20
|
# when format option is not defined by user then use progress formatter to show tests execution progress
|
25
|
-
cli_args += ['--format', 'progress'] unless has_format_option?(cli_args)
|
21
|
+
cli_args += ['--format', 'progress'] unless adapter_class.has_format_option?(cli_args)
|
26
22
|
|
27
23
|
cli_args += [
|
28
24
|
# shows summary of all tests executed in Queue Mode at the very end
|
@@ -154,19 +150,6 @@ module KnapsackPro
|
|
154
150
|
::RSpec.configuration.reset_filters
|
155
151
|
end
|
156
152
|
end
|
157
|
-
|
158
|
-
def self.has_tag_option?(cli_args)
|
159
|
-
# use start_with? because user can define tag option in a few ways:
|
160
|
-
# -t mytag
|
161
|
-
# -tmytag
|
162
|
-
# --tag mytag
|
163
|
-
# --tag=mytag
|
164
|
-
cli_args.any? { |arg| arg.start_with?('-t') || arg.start_with?('--tag') }
|
165
|
-
end
|
166
|
-
|
167
|
-
def self.has_format_option?(cli_args)
|
168
|
-
cli_args.any? { |arg| arg.start_with?('-f') || arg.start_with?('--format') }
|
169
|
-
end
|
170
153
|
end
|
171
154
|
end
|
172
155
|
end
|
@@ -11,6 +11,9 @@ module KnapsackPro
|
|
11
11
|
if runner.test_files_to_execute_exist?
|
12
12
|
adapter_class.verify_bind_method_called
|
13
13
|
|
14
|
+
cli_args = (args || '').split
|
15
|
+
adapter_class.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
|
16
|
+
|
14
17
|
require 'rspec/core/rake_task'
|
15
18
|
|
16
19
|
task_name = 'knapsack_pro:rspec_run'
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -12,6 +12,104 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
12
12
|
it_behaves_like 'adapter'
|
13
13
|
end
|
14
14
|
|
15
|
+
describe '.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!' do
|
16
|
+
let(:cli_args) { double }
|
17
|
+
|
18
|
+
subject { described_class.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
expect(KnapsackPro::Config::Env).to receive(:rspec_split_by_test_examples?).and_return(rspec_split_by_test_examples_enabled)
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when RSpec split by test examples enabled' do
|
25
|
+
let(:rspec_split_by_test_examples_enabled) { true }
|
26
|
+
|
27
|
+
before do
|
28
|
+
expect(described_class).to receive(:has_tag_option?).with(cli_args).and_return(has_tag_option)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when RSpec tag option is provided' do
|
32
|
+
let(:has_tag_option) { true }
|
33
|
+
|
34
|
+
it do
|
35
|
+
expect { subject }.to raise_error(/It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature/)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when RSpec tag option is not provided' do
|
40
|
+
let(:has_tag_option) { false }
|
41
|
+
|
42
|
+
it 'does nothing' do
|
43
|
+
expect(subject).to be_nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when RSpec split by test examples disabled' do
|
49
|
+
let(:rspec_split_by_test_examples_enabled) { false }
|
50
|
+
|
51
|
+
it 'does nothing' do
|
52
|
+
expect(subject).to be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.has_tag_option?' do
|
58
|
+
subject { described_class.has_tag_option?(cli_args) }
|
59
|
+
|
60
|
+
context 'when tag option is provided as -t' do
|
61
|
+
let(:cli_args) { ['-t', 'mytag'] }
|
62
|
+
|
63
|
+
it { expect(subject).to be true }
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when tag option is provided as --tag' do
|
67
|
+
let(:cli_args) { ['--tag', 'mytag'] }
|
68
|
+
|
69
|
+
it { expect(subject).to be true }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when tag option is provided without delimiter' do
|
73
|
+
let(:cli_args) { ['-tmytag'] }
|
74
|
+
|
75
|
+
it { expect(subject).to be true }
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'when tag option is not provided' do
|
79
|
+
let(:cli_args) { ['--fake', 'value'] }
|
80
|
+
|
81
|
+
it { expect(subject).to be false }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '.has_format_option?' do
|
86
|
+
subject { described_class.has_format_option?(cli_args) }
|
87
|
+
|
88
|
+
context 'when format option is provided as -f' do
|
89
|
+
let(:cli_args) { ['-f', 'documentation'] }
|
90
|
+
|
91
|
+
it { expect(subject).to be true }
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when format option is provided as --format' do
|
95
|
+
let(:cli_args) { ['--format', 'documentation'] }
|
96
|
+
|
97
|
+
it { expect(subject).to be true }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when format option is provided without delimiter' do
|
101
|
+
let(:cli_args) { ['-fd'] }
|
102
|
+
|
103
|
+
it { expect(subject).to be true }
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when format option is not provided' do
|
107
|
+
let(:cli_args) { ['--fake', 'value'] }
|
108
|
+
|
109
|
+
it { expect(subject).to be false }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
15
113
|
describe '.test_path' do
|
16
114
|
let(:current_example_metadata) do
|
17
115
|
{
|
@@ -133,31 +133,16 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
|
|
133
133
|
context 'when RSpec split by test examples feature is enabled' do
|
134
134
|
before do
|
135
135
|
expect(KnapsackPro::Config::Env).to receive(:rspec_split_by_test_examples?).and_return(true)
|
136
|
+
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).and_call_original
|
136
137
|
end
|
137
138
|
|
138
|
-
context 'when tag option is provided
|
139
|
+
context 'when tag option is provided' do
|
139
140
|
let(:args) { '--tag example-value' }
|
140
141
|
|
141
142
|
it do
|
142
143
|
expect { subject }.to raise_error(/It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature/)
|
143
144
|
end
|
144
145
|
end
|
145
|
-
|
146
|
-
context 'when tag option is provided as -t' do
|
147
|
-
let(:args) { '-t example-value' }
|
148
|
-
|
149
|
-
it do
|
150
|
-
expect { subject }.to raise_error(/It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature/)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context 'when tag option is provided without delimiter' do
|
155
|
-
let(:args) { '-texample-value' }
|
156
|
-
|
157
|
-
it do
|
158
|
-
expect { subject }.to raise_error(/It is not allowed to use the RSpec tag option together with the RSpec split by test examples feature/)
|
159
|
-
end
|
160
|
-
end
|
161
146
|
end
|
162
147
|
end
|
163
148
|
|
@@ -34,7 +34,8 @@ describe KnapsackPro::Runners::RSpecRunner do
|
|
34
34
|
let(:task) { double }
|
35
35
|
|
36
36
|
before do
|
37
|
-
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called)
|
37
|
+
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:verify_bind_method_called).ordered
|
38
|
+
expect(KnapsackPro::Adapters::RSpecAdapter).to receive(:ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!).with(['--profile', '--color']).ordered
|
38
39
|
|
39
40
|
expect(Rake::Task).to receive(:[]).with('knapsack_pro:rspec_run').at_least(1).and_return(task)
|
40
41
|
|
@@ -44,7 +45,7 @@ describe KnapsackPro::Runners::RSpecRunner do
|
|
44
45
|
expect(t).to receive(:pattern=).with([])
|
45
46
|
end
|
46
47
|
|
47
|
-
context 'when task already exists' do
|
48
|
+
context 'when rake task already exists' do
|
48
49
|
before do
|
49
50
|
expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(true)
|
50
51
|
expect(task).to receive(:clear)
|
@@ -57,7 +58,7 @@ describe KnapsackPro::Runners::RSpecRunner do
|
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
context "when task doesn't exist" do
|
61
|
+
context "when rake task doesn't exist" do
|
61
62
|
before do
|
62
63
|
expect(Rake::Task).to receive(:task_defined?).with('knapsack_pro:rspec_run').and_return(false)
|
63
64
|
expect(task).not_to receive(:clear)
|
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: 2.
|
4
|
+
version: 2.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|