cuke_linter 0.11.1 → 0.12.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/.travis.yml +5 -1
- data/CHANGELOG.md +13 -2
- data/LICENSE.txt +1 -1
- data/appveyor.yml +19 -0
- data/cuke_linter.gemspec +1 -1
- data/environments/rspec_env.rb +4 -0
- data/lib/cuke_linter.rb +6 -0
- data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +41 -0
- data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +44 -0
- data/lib/cuke_linter/linters/feature_file_with_mismatched_name_linter.rb +26 -0
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/command_line.feature +7 -7
- data/testing/cucumber/features/default_linters.feature +3 -0
- data/testing/cucumber/features/linters/element_with_common_tags.feature +28 -0
- data/testing/cucumber/features/linters/element_with_duplicate_tags.feature +71 -0
- data/testing/cucumber/features/linters/feature_file_with_mismatched_name.feature +32 -0
- data/testing/cucumber/step_definitions/setup_steps.rb +25 -0
- data/testing/gemfiles/cuke_modeler1.gemfile +8 -0
- data/testing/gemfiles/cuke_modeler2.gemfile +8 -0
- data/testing/model_factory.rb +14 -2
- data/testing/rspec/spec/integration/cli_integration_spec.rb +8 -7
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +5 -0
- data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +8 -0
- data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +248 -0
- data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +203 -0
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +1 -4
- data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +1 -1
- data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +124 -0
- metadata +24 -4
@@ -0,0 +1,203 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::ElementWithDuplicateTagsLinter do
|
5
|
+
|
6
|
+
let(:model_file_path) { 'some_file_path' }
|
7
|
+
|
8
|
+
it_should_behave_like 'a linter at the unit level'
|
9
|
+
it_should_behave_like 'a configurable linter at the unit level'
|
10
|
+
|
11
|
+
|
12
|
+
it 'has a name' do
|
13
|
+
expect(subject.name).to eq('ElementWithDuplicateTagsLinter')
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'linting' do
|
17
|
+
|
18
|
+
TAGGABLE_ELEMENTS.each do |model_type|
|
19
|
+
|
20
|
+
context "with a #{model_type} that has duplicate tags" do
|
21
|
+
|
22
|
+
let(:test_model) do
|
23
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
|
24
|
+
model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same'),
|
25
|
+
CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
|
26
|
+
|
27
|
+
model
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like 'a linter linting a bad model'
|
31
|
+
|
32
|
+
|
33
|
+
it 'records a problem' do
|
34
|
+
result = subject.lint(test_model)
|
35
|
+
|
36
|
+
expect(result[:problem]).to match(/^#{model_type.capitalize} has duplicate tag '@\w+'\.$/)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'includes the name of the duplicate tag found in the problem record' do
|
40
|
+
duplicate_tag = test_model.tags.first.name
|
41
|
+
result = subject.lint(test_model)
|
42
|
+
expect(result[:problem]).to eq("#{model_type.capitalize} has duplicate tag '#{duplicate_tag}'.")
|
43
|
+
|
44
|
+
test_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same'),
|
45
|
+
CukeLinter::ModelFactory.generate_tag_model(source_text: '@still_same')]
|
46
|
+
|
47
|
+
duplicate_tag = test_model.tags.first.name
|
48
|
+
result = subject.lint(test_model)
|
49
|
+
expect(result[:problem]).to eq("#{model_type.capitalize} has duplicate tag '#{duplicate_tag}'.")
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a #{model_type} that does not have duplicate tags" do
|
55
|
+
|
56
|
+
context 'because none of it tags are duplicates' do
|
57
|
+
|
58
|
+
let(:test_model) do
|
59
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
60
|
+
model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@foo'),
|
61
|
+
CukeLinter::ModelFactory.generate_tag_model(source_text: '@bar')]
|
62
|
+
|
63
|
+
model
|
64
|
+
end
|
65
|
+
|
66
|
+
it_should_behave_like 'a linter linting a good model'
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'because it has no tags' do
|
71
|
+
|
72
|
+
context 'because its tags are empty' do
|
73
|
+
|
74
|
+
let(:test_model) do
|
75
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
76
|
+
model.tags = []
|
77
|
+
|
78
|
+
model
|
79
|
+
end
|
80
|
+
|
81
|
+
it_should_behave_like 'a linter linting a good model'
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'because its tags are nil' do
|
86
|
+
|
87
|
+
let(:test_model) do
|
88
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
89
|
+
model.tags = nil
|
90
|
+
|
91
|
+
model
|
92
|
+
end
|
93
|
+
|
94
|
+
it_should_behave_like 'a linter linting a good model'
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
describe 'configuration' do
|
104
|
+
|
105
|
+
describe 'tag inheritance configuration' do
|
106
|
+
|
107
|
+
let(:test_model_with_inherited_tags) do
|
108
|
+
test_model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
109
|
+
test_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
|
110
|
+
|
111
|
+
distant_ancestor_model = CukeLinter::ModelFactory.generate_lintable_model
|
112
|
+
distant_ancestor_model.tags = [CukeLinter::ModelFactory.generate_tag_model(source_text: '@same')]
|
113
|
+
ancestor_model = CukeLinter::ModelFactory.generate_lintable_model
|
114
|
+
|
115
|
+
# Adding an extra ancestor in the chain in order to make sure that the linter isn't just checking the parent model
|
116
|
+
ancestor_model.parent_model = distant_ancestor_model
|
117
|
+
test_model.parent_model = ancestor_model
|
118
|
+
|
119
|
+
test_model
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
context 'with no configuration' do
|
124
|
+
|
125
|
+
context 'because configuration never happened' do
|
126
|
+
|
127
|
+
it 'does not include inherited tags' do
|
128
|
+
result = subject.lint(test_model_with_inherited_tags)
|
129
|
+
|
130
|
+
expect(result).to eq(nil)
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'because configuration did not set tag inheritance' do
|
136
|
+
|
137
|
+
let(:configuration) { {} }
|
138
|
+
|
139
|
+
before(:each) do
|
140
|
+
subject.configure(configuration)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'does not include inherited tags' do
|
144
|
+
result = subject.lint(test_model_with_inherited_tags)
|
145
|
+
|
146
|
+
expect(result).to eq(nil)
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'with configuration' do
|
154
|
+
|
155
|
+
before(:each) do
|
156
|
+
subject.configure(configuration)
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'enabling tag inheritance' do
|
160
|
+
|
161
|
+
let(:configuration) { { 'IncludeInheritedTags' => true } }
|
162
|
+
|
163
|
+
it 'does include inherited tags' do
|
164
|
+
result = subject.lint(test_model_with_inherited_tags)
|
165
|
+
|
166
|
+
expect(result).to_not be_nil
|
167
|
+
expect(result[:problem]).to match(/#{model_type.capitalize} has duplicate tag '@\w+'\./)
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'disabling tag inheritance' do
|
173
|
+
|
174
|
+
let(:configuration) { { 'IncludeInheritedTags' => false } }
|
175
|
+
|
176
|
+
it 'does not include inherited tags' do
|
177
|
+
result = subject.lint(test_model_with_inherited_tags)
|
178
|
+
|
179
|
+
expect(result).to eq(nil)
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
context 'a non-taggable model' do
|
194
|
+
|
195
|
+
let(:test_model) { CukeModeler::Model.new }
|
196
|
+
|
197
|
+
it_should_behave_like 'a linter linting a good model'
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
@@ -15,10 +15,7 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
15
15
|
|
16
16
|
describe 'linting' do
|
17
17
|
|
18
|
-
|
19
|
-
taggable_elements = ['feature', 'scenario', 'outline', 'example']
|
20
|
-
|
21
|
-
taggable_elements.each do |model_type|
|
18
|
+
TAGGABLE_ELEMENTS.each do |model_type|
|
22
19
|
|
23
20
|
context "with a #{model_type} that has too many tags" do
|
24
21
|
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::FeatureFileWithMismatchedNameLinter do
|
5
|
+
|
6
|
+
let(:model_file_path) { 'some_file_path' }
|
7
|
+
|
8
|
+
it_should_behave_like 'a linter at the unit level'
|
9
|
+
|
10
|
+
|
11
|
+
it 'has a name' do
|
12
|
+
expect(subject.name).to eq('FeatureFileWithMismatchedNameLinter')
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'linting' do
|
16
|
+
|
17
|
+
let(:test_model) do
|
18
|
+
feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
|
19
|
+
source_text: "Feature: #{model_feature_name}")
|
20
|
+
|
21
|
+
feature_model.parent_model
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
context "with a feature file model that has mismatched feature name" do
|
26
|
+
|
27
|
+
let(:model_file_path) { 'foo.feature' }
|
28
|
+
let(:model_feature_name) { 'Bar' }
|
29
|
+
|
30
|
+
it_should_behave_like 'a linter linting a bad model'
|
31
|
+
|
32
|
+
it 'records a problem' do
|
33
|
+
result = subject.lint(test_model)
|
34
|
+
|
35
|
+
expect(result[:problem]).to eq('Feature file name does not match feature name.')
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
context "with a feature file model that does not have a mismatched feature name" do
|
41
|
+
|
42
|
+
context 'with a file name that has caps' do
|
43
|
+
let(:model_file_path) { 'Name With Caps.feature' }
|
44
|
+
let(:model_feature_name) { 'name with caps' }
|
45
|
+
|
46
|
+
it_should_behave_like 'a linter linting a good model'
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with a feature name that has caps' do
|
50
|
+
let(:model_file_path) { 'name with caps.feature' }
|
51
|
+
let(:model_feature_name) { 'Name With Caps' }
|
52
|
+
|
53
|
+
it_should_behave_like 'a linter linting a good model'
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with a file name that has underscores' do
|
57
|
+
let(:model_file_path) { 'name_with_underscores.feature' }
|
58
|
+
let(:model_feature_name) { 'name with underscores' }
|
59
|
+
|
60
|
+
it_should_behave_like 'a linter linting a good model'
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with a feature name that has underscores' do
|
64
|
+
let(:model_file_path) { 'name with underscores.feature' }
|
65
|
+
let(:model_feature_name) { 'name_with_underscores' }
|
66
|
+
|
67
|
+
it_should_behave_like 'a linter linting a good model'
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with a file name that has spaces' do
|
71
|
+
let(:model_file_path) { 'name with spaces.feature' }
|
72
|
+
let(:model_feature_name) { 'namewithspaces' }
|
73
|
+
|
74
|
+
it_should_behave_like 'a linter linting a good model'
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with a feature name that has spaces' do
|
78
|
+
let(:model_file_path) { 'namewithspaces.feature' }
|
79
|
+
let(:model_feature_name) { 'name with spaces' }
|
80
|
+
|
81
|
+
it_should_behave_like 'a linter linting a good model'
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with a file name that has hyphens' do
|
85
|
+
let(:model_file_path) { 'name-with-hyphens.feature' }
|
86
|
+
let(:model_feature_name) { 'namewithhyphens' }
|
87
|
+
|
88
|
+
it_should_behave_like 'a linter linting a good model'
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'with a feature name that has hyphens' do
|
92
|
+
let(:model_file_path) { 'namewithhyphens.feature' }
|
93
|
+
let(:model_feature_name) { 'name-with-hyphens' }
|
94
|
+
|
95
|
+
it_should_behave_like 'a linter linting a good model'
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'with a file name that has mixed ignored characters' do
|
99
|
+
let(:model_file_path) { '_namewith lotsOf-stuff.feature' }
|
100
|
+
let(:model_feature_name) { 'namewithlotsofstuff' }
|
101
|
+
|
102
|
+
it_should_behave_like 'a linter linting a good model'
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'with a feature name that has mixed ignored characters' do
|
106
|
+
let(:model_file_path) { 'namewithlotsofstuff.feature' }
|
107
|
+
let(:model_feature_name) { '_namewith lotsOf-stuff' }
|
108
|
+
|
109
|
+
it_should_behave_like 'a linter linting a good model'
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'a non-feature-file model' do
|
115
|
+
|
116
|
+
let(:test_model) { CukeModeler::Model.new }
|
117
|
+
|
118
|
+
it_should_behave_like 'a linter linting a good model'
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_linter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuke_modeler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.5'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,9 +184,12 @@ files:
|
|
178
184
|
- lib/cuke_linter.rb
|
179
185
|
- lib/cuke_linter/formatters/pretty_formatter.rb
|
180
186
|
- lib/cuke_linter/linters/background_does_more_than_setup_linter.rb
|
187
|
+
- lib/cuke_linter/linters/element_with_common_tags_linter.rb
|
188
|
+
- lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb
|
181
189
|
- lib/cuke_linter/linters/element_with_too_many_tags_linter.rb
|
182
190
|
- lib/cuke_linter/linters/example_without_name_linter.rb
|
183
191
|
- lib/cuke_linter/linters/feature_file_with_invalid_name_linter.rb
|
192
|
+
- lib/cuke_linter/linters/feature_file_with_mismatched_name_linter.rb
|
184
193
|
- lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb
|
185
194
|
- lib/cuke_linter/linters/feature_without_description_linter.rb
|
186
195
|
- lib/cuke_linter/linters/feature_without_name_linter.rb
|
@@ -209,9 +218,12 @@ files:
|
|
209
218
|
- testing/cucumber/features/default_linters.feature
|
210
219
|
- testing/cucumber/features/formatters/pretty_formatter.feature
|
211
220
|
- testing/cucumber/features/linters/background_does_more_than_setup.feature
|
221
|
+
- testing/cucumber/features/linters/element_with_common_tags.feature
|
222
|
+
- testing/cucumber/features/linters/element_with_duplicate_tags.feature
|
212
223
|
- testing/cucumber/features/linters/element_with_too_many_tags.feature
|
213
224
|
- testing/cucumber/features/linters/example_without_name.feature
|
214
225
|
- testing/cucumber/features/linters/feature_file_with_invalid_name.feature
|
226
|
+
- testing/cucumber/features/linters/feature_file_with_mismatched_name.feature
|
215
227
|
- testing/cucumber/features/linters/feature_with_too_many_different_tags.feature
|
216
228
|
- testing/cucumber/features/linters/feature_without_description.feature
|
217
229
|
- testing/cucumber/features/linters/feature_without_name.feature
|
@@ -235,6 +247,8 @@ files:
|
|
235
247
|
- testing/cucumber/step_definitions/verification_steps.rb
|
236
248
|
- testing/file_helper.rb
|
237
249
|
- testing/formatter_factory.rb
|
250
|
+
- testing/gemfiles/cuke_modeler1.gemfile
|
251
|
+
- testing/gemfiles/cuke_modeler2.gemfile
|
238
252
|
- testing/linter_factory.rb
|
239
253
|
- testing/model_factory.rb
|
240
254
|
- testing/rspec/spec/integration/cli_integration_spec.rb
|
@@ -243,9 +257,12 @@ files:
|
|
243
257
|
- testing/rspec/spec/integration/formatters/formatter_integration_specs.rb
|
244
258
|
- testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb
|
245
259
|
- testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb
|
260
|
+
- testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb
|
261
|
+
- testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb
|
246
262
|
- testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb
|
247
263
|
- testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb
|
248
264
|
- testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb
|
265
|
+
- testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb
|
249
266
|
- testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb
|
250
267
|
- testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb
|
251
268
|
- testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb
|
@@ -271,9 +288,12 @@ files:
|
|
271
288
|
- testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb
|
272
289
|
- testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb
|
273
290
|
- testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb
|
291
|
+
- testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb
|
292
|
+
- testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb
|
274
293
|
- testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb
|
275
294
|
- testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb
|
276
295
|
- testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb
|
296
|
+
- testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb
|
277
297
|
- testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb
|
278
298
|
- testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb
|
279
299
|
- testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb
|