cuke_linter 0.12.0 → 1.1.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 +41 -1
- data/README.md +12 -8
- data/cuke_linter.gemspec +25 -21
- data/exe/cuke_linter +3 -1
- data/lib/cuke_linter.rb +119 -176
- data/lib/cuke_linter/configuration.rb +45 -0
- data/lib/cuke_linter/default_linters.rb +32 -0
- data/lib/cuke_linter/formatters/pretty_formatter.rb +63 -35
- data/lib/cuke_linter/gherkin.rb +10 -0
- data/lib/cuke_linter/linter_registration.rb +32 -0
- data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
- data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +23 -14
- data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +18 -13
- data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +17 -11
- data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +1 -3
- data/lib/cuke_linter/linters/feature_without_description_linter.rb +1 -1
- data/lib/cuke_linter/linters/linter.rb +17 -13
- data/lib/cuke_linter/linters/step_with_too_many_characters_linter.rb +2 -2
- data/lib/cuke_linter/linters/test_should_use_background_linter.rb +56 -4
- data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_bad_name_linter.rb +4 -4
- data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +18 -2
- data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +18 -2
- data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +12 -1
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/linters/background_does_more_than_setup.feature +34 -0
- data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +25 -3
- data/testing/cucumber/features/linters/test_with_no_action_step.feature +27 -1
- data/testing/cucumber/features/linters/test_with_no_verification_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +25 -3
- metadata +88 -106
- data/.gitignore +0 -19
- data/.simplecov +0 -8
- data/.travis.yml +0 -23
- data/CONTRIBUTING.md +0 -26
- data/Gemfile +0 -6
- data/Rakefile +0 -63
- data/appveyor.yml +0 -43
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/environments/common_env.rb +0 -12
- data/environments/cucumber_env.rb +0 -22
- data/environments/rspec_env.rb +0 -50
- data/testing/cucumber/step_definitions/action_steps.rb +0 -84
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -230
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
- data/testing/file_helper.rb +0 -41
- data/testing/formatter_factory.rb +0 -15
- data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
- data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
- data/testing/linter_factory.rb +0 -60
- data/testing/model_factory.rb +0 -109
- data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
- data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
- data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
- data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
- data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -102
- data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -77
- data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
- data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
- data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
- data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
- data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
- data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
- data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
- data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
- data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
- data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -226
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -98
- data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -176
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -179
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -124
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -98
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,203 +0,0 @@
|
|
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
|
@@ -1,296 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::ElementWithTooManyTagsLinter 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('ElementWithTooManyTagsLinter')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'linting' do
|
17
|
-
|
18
|
-
TAGGABLE_ELEMENTS.each do |model_type|
|
19
|
-
|
20
|
-
context "with a #{model_type} that has too many 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 = [:tag_1,
|
25
|
-
:tag_2,
|
26
|
-
:tag_3,
|
27
|
-
:tag_4,
|
28
|
-
:tag_5,
|
29
|
-
:tag_6]
|
30
|
-
|
31
|
-
model
|
32
|
-
end
|
33
|
-
|
34
|
-
it_should_behave_like 'a linter linting a bad model'
|
35
|
-
|
36
|
-
|
37
|
-
it 'records a problem' do
|
38
|
-
result = subject.lint(test_model)
|
39
|
-
|
40
|
-
expect(result[:problem]).to match(/^#{model_type.capitalize} has too many tags. \d+ tags found \(max 5\)\.$/)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'includes the number of tags found in the problem record' do
|
44
|
-
tag_count = test_model.tags.count
|
45
|
-
result = subject.lint(test_model)
|
46
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{tag_count} tags found (max 5).")
|
47
|
-
|
48
|
-
test_model.tags << :another_tag
|
49
|
-
result = subject.lint(test_model)
|
50
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{tag_count + 1} tags found (max 5).")
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with a #{model_type} that does not have too many tags" do
|
56
|
-
|
57
|
-
context 'because it has 5 tags' do
|
58
|
-
|
59
|
-
let(:test_model) do
|
60
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
61
|
-
model.tags = [:tag_1,
|
62
|
-
:tag_2,
|
63
|
-
:tag_3,
|
64
|
-
:tag_4,
|
65
|
-
:tag_5]
|
66
|
-
|
67
|
-
model
|
68
|
-
end
|
69
|
-
|
70
|
-
it_should_behave_like 'a linter linting a good model'
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'because it has fewer than 5 tags' do
|
75
|
-
|
76
|
-
let(:test_model) do
|
77
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
78
|
-
model.tags = [:tag_1]
|
79
|
-
|
80
|
-
model
|
81
|
-
end
|
82
|
-
|
83
|
-
it_should_behave_like 'a linter linting a good model'
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'because it has no tags' do
|
88
|
-
|
89
|
-
context 'because its tags are empty' do
|
90
|
-
|
91
|
-
let(:test_model) do
|
92
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
93
|
-
model.tags = []
|
94
|
-
|
95
|
-
model
|
96
|
-
end
|
97
|
-
|
98
|
-
it_should_behave_like 'a linter linting a good model'
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'because its tags are nil' do
|
103
|
-
|
104
|
-
let(:test_model) do
|
105
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
106
|
-
model.tags = nil
|
107
|
-
|
108
|
-
model
|
109
|
-
end
|
110
|
-
|
111
|
-
it_should_behave_like 'a linter linting a good model'
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
describe 'configuration' do
|
121
|
-
|
122
|
-
let(:default_tag_threshold) { 5 }
|
123
|
-
|
124
|
-
|
125
|
-
describe 'tag threshold configuration' do
|
126
|
-
|
127
|
-
context 'with no configuration' do
|
128
|
-
|
129
|
-
context 'because configuration never happened' do
|
130
|
-
|
131
|
-
let(:unconfigured_test_model) do
|
132
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
133
|
-
model.tags = []
|
134
|
-
(default_tag_threshold + 1).times { model.tags << :a_tag }
|
135
|
-
|
136
|
-
model
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'defaults to a tag threshold of 5 tags' do
|
140
|
-
result = subject.lint(unconfigured_test_model)
|
141
|
-
|
142
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{unconfigured_test_model.tags.count} tags found (max 5).")
|
143
|
-
end
|
144
|
-
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'because configuration did not set a tag threshold' do
|
148
|
-
|
149
|
-
let(:configuration) { {} }
|
150
|
-
let(:test_model) do
|
151
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
152
|
-
model.tags = []
|
153
|
-
(default_tag_threshold + 1).times { model.tags << :a_tag }
|
154
|
-
|
155
|
-
model
|
156
|
-
end
|
157
|
-
|
158
|
-
before(:each) do
|
159
|
-
subject.configure(configuration)
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'defaults to a tag threshold of 5 tags' do
|
163
|
-
result = subject.lint(test_model)
|
164
|
-
|
165
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{test_model.tags.count} tags found (max 5).")
|
166
|
-
end
|
167
|
-
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'with configuration' do
|
173
|
-
|
174
|
-
let(:tag_threshold) { 3 }
|
175
|
-
let(:configuration) { { 'TagCountThreshold' => tag_threshold } }
|
176
|
-
|
177
|
-
before(:each) do
|
178
|
-
subject.configure(configuration)
|
179
|
-
end
|
180
|
-
|
181
|
-
let(:test_model) do
|
182
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
183
|
-
model.tags = []
|
184
|
-
(tag_threshold + 1).times { model.tags << :a_tag }
|
185
|
-
|
186
|
-
model
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'the tag threshold used is the configured value' do
|
190
|
-
result = subject.lint(test_model)
|
191
|
-
|
192
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{test_model.tags.count} tags found (max #{tag_threshold}).")
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
|
200
|
-
describe 'tag inheritance configuration' do
|
201
|
-
|
202
|
-
let(:test_model_with_inherited_tags) do
|
203
|
-
test_model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
204
|
-
test_model.tags = []
|
205
|
-
(default_tag_threshold).times { test_model.tags << :a_tag }
|
206
|
-
|
207
|
-
ancestor_model = CukeLinter::ModelFactory.generate_lintable_model
|
208
|
-
ancestor_model.tags = [:an_extra_tag]
|
209
|
-
|
210
|
-
test_model.parent_model = ancestor_model
|
211
|
-
|
212
|
-
test_model
|
213
|
-
end
|
214
|
-
|
215
|
-
|
216
|
-
context 'with no configuration' do
|
217
|
-
|
218
|
-
context 'because configuration never happened' do
|
219
|
-
|
220
|
-
it 'does not include inherited tags' do
|
221
|
-
result = subject.lint(test_model_with_inherited_tags)
|
222
|
-
|
223
|
-
expect(result).to eq(nil)
|
224
|
-
end
|
225
|
-
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'because configuration did not set tag inheritance' do
|
229
|
-
|
230
|
-
let(:configuration) { {} }
|
231
|
-
|
232
|
-
before(:each) do
|
233
|
-
subject.configure(configuration)
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'does not include inherited tags' do
|
237
|
-
result = subject.lint(test_model_with_inherited_tags)
|
238
|
-
|
239
|
-
expect(result).to eq(nil)
|
240
|
-
end
|
241
|
-
|
242
|
-
end
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
context 'with configuration' do
|
247
|
-
|
248
|
-
before(:each) do
|
249
|
-
subject.configure(configuration)
|
250
|
-
end
|
251
|
-
|
252
|
-
context 'enabling tag inheritance' do
|
253
|
-
|
254
|
-
let(:configuration) { { 'CountInheritedTags' => true } }
|
255
|
-
|
256
|
-
it 'does include inherited tags' do
|
257
|
-
result = subject.lint(test_model_with_inherited_tags)
|
258
|
-
|
259
|
-
expect(result).to_not be_nil
|
260
|
-
expect(result[:problem]).to eq("#{model_type.capitalize} has too many tags. #{test_model_with_inherited_tags.all_tags.count} tags found (max #{default_tag_threshold}).")
|
261
|
-
end
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
context 'disabling tag inheritance' do
|
266
|
-
|
267
|
-
let(:configuration) { { 'CountInheritedTags' => false } }
|
268
|
-
|
269
|
-
it 'does not include inherited tags' do
|
270
|
-
result = subject.lint(test_model_with_inherited_tags)
|
271
|
-
|
272
|
-
expect(result).to eq(nil)
|
273
|
-
end
|
274
|
-
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|
280
|
-
|
281
|
-
end
|
282
|
-
|
283
|
-
end
|
284
|
-
|
285
|
-
|
286
|
-
context 'a non-taggable model' do
|
287
|
-
|
288
|
-
let(:test_model) { CukeModeler::Model.new }
|
289
|
-
|
290
|
-
it_should_behave_like 'a linter linting a good model'
|
291
|
-
|
292
|
-
end
|
293
|
-
|
294
|
-
end
|
295
|
-
|
296
|
-
end
|