knapsack_pro 2.17.0 → 2.18.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e22a25e69f6cfda9a42568aed336631f601423b0b930525fc8becbc1b1ee7fe9
4
- data.tar.gz: ac1df0750000066a933cc4814f185d09a6d38ce09028680c8f20678bb7b0473e
3
+ metadata.gz: b2e5ae3f380ffe2e210417898e30fc7091abcc4fbcacab97b340e9e5ea5e700b
4
+ data.tar.gz: 481dda7a93c2ba5964fa3c20cf60bf2666432311c9a7f1bf59b3be1c905939bb
5
5
  SHA512:
6
- metadata.gz: 91687797a4f7c80bcd852f7c8e5ec18f523eb5a9375b3dc069b6abce67bc58ccda010f36b6c003fefa01971e628518bf0b9f9e855d7992c86d9ea7dcb375be4b
7
- data.tar.gz: c32195b9e6fd4fdee7b5087f61f7d1b28fdb7a6a995930d23e109eda296156026a79fea579e06540e2a64c75ee3a03a6b216f2a8492eb48e422bc9193aad0146
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 sign ~, for instance path ~/project/tmp/rspec.xml may not work. Please use full path instead.
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
- runner = new(KnapsackPro::Adapters::RSpecAdapter)
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'
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '2.17.0'
2
+ VERSION = '2.18.0'
3
3
  end
@@ -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 as --tag' do
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.17.0
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-05-25 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake