cuke_linter 0.9.0 → 0.10.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 +17 -1
- data/CONTRIBUTING.md +26 -0
- data/README.md +2 -15
- data/lib/cuke_linter.rb +36 -18
- data/lib/cuke_linter/linters/example_without_name_linter.rb +1 -1
- data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +38 -0
- data/lib/cuke_linter/linters/test_should_use_background_linter.rb +28 -0
- data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +23 -0
- data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +31 -0
- data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +31 -0
- data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +23 -0
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/default_linters.feature +20 -14
- data/testing/cucumber/features/linters/example_without_name.feature +8 -6
- data/testing/cucumber/features/linters/feature_with_too_many_different_tags.feature +56 -0
- data/testing/cucumber/features/linters/step_with_end_period.feature +1 -1
- data/testing/cucumber/features/linters/test_should_use_background.feature +29 -0
- data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +28 -0
- data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +30 -0
- data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +30 -0
- data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +28 -0
- data/testing/cucumber/features/linters/test_with_too_many_steps.feature +5 -0
- data/testing/cucumber/step_definitions/setup_steps.rb +28 -0
- data/testing/model_factory.rb +1 -1
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +12 -0
- data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +20 -57
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +18 -52
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +41 -43
- data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +293 -0
- data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +25 -42
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +10 -38
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +32 -52
- data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +27 -10
- data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +26 -12
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +19 -66
- data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +12 -39
- data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +9 -28
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +19 -45
- data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +226 -0
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +98 -0
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +10 -51
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +11 -38
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +16 -54
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +124 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +125 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +98 -0
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +9 -49
- metadata +27 -2
@@ -3,25 +3,7 @@ require_relative '../../../../../environments/rspec_env'
|
|
3
3
|
|
4
4
|
RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
5
5
|
|
6
|
-
let(:
|
7
|
-
model = CukeLinter::ModelFactory.generate_scenario_model
|
8
|
-
model.tags = [:tag_1]
|
9
|
-
|
10
|
-
model
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:bad_data) do
|
14
|
-
model = CukeLinter::ModelFactory.generate_scenario_model
|
15
|
-
model.tags = [:tag_1,
|
16
|
-
:tag_2,
|
17
|
-
:tag_3,
|
18
|
-
:tag_4,
|
19
|
-
:tag_5,
|
20
|
-
:tag_6]
|
21
|
-
|
22
|
-
model
|
23
|
-
end
|
24
|
-
|
6
|
+
let(:model_file_path) { 'some_file_path' }
|
25
7
|
|
26
8
|
it_should_behave_like 'a linter at the unit level'
|
27
9
|
it_should_behave_like 'a configurable linter at the unit level'
|
@@ -33,12 +15,15 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
33
15
|
|
34
16
|
describe 'linting' do
|
35
17
|
|
36
|
-
|
18
|
+
# Descriptive variable name, just in case what kinds of elements are taggable ever changes
|
19
|
+
taggable_elements = ['feature', 'scenario', 'outline', 'example']
|
20
|
+
|
21
|
+
taggable_elements.each do |model_type|
|
37
22
|
|
38
23
|
context "with a #{model_type} that has too many tags" do
|
39
24
|
|
40
25
|
let(:test_model) do
|
41
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path:
|
26
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
|
42
27
|
model.tags = [:tag_1,
|
43
28
|
:tag_2,
|
44
29
|
:tag_3,
|
@@ -49,22 +34,15 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
49
34
|
model
|
50
35
|
end
|
51
36
|
|
37
|
+
it_should_behave_like 'a linter linting a bad model'
|
38
|
+
|
39
|
+
|
52
40
|
it 'records a problem' do
|
53
41
|
result = subject.lint(test_model)
|
54
42
|
|
55
43
|
expect(result[:problem]).to match(/^#{model_type.capitalize} has too many tags. \d+ tags found \(max 5\)\.$/)
|
56
44
|
end
|
57
45
|
|
58
|
-
it 'records the location of the problem' do
|
59
|
-
test_model.source_line = 1
|
60
|
-
result = subject.lint(test_model)
|
61
|
-
expect(result[:location]).to eq('path_to_file:1')
|
62
|
-
|
63
|
-
test_model.source_line = 3
|
64
|
-
result = subject.lint(test_model)
|
65
|
-
expect(result[:location]).to eq('path_to_file:3')
|
66
|
-
end
|
67
|
-
|
68
46
|
it 'includes the number of tags found in the problem record' do
|
69
47
|
tag_count = test_model.tags.count
|
70
48
|
result = subject.lint(test_model)
|
@@ -82,7 +60,7 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
82
60
|
context 'because it has 5 tags' do
|
83
61
|
|
84
62
|
let(:test_model) do
|
85
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model"
|
63
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
86
64
|
model.tags = [:tag_1,
|
87
65
|
:tag_2,
|
88
66
|
:tag_3,
|
@@ -92,24 +70,20 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
92
70
|
model
|
93
71
|
end
|
94
72
|
|
95
|
-
|
96
|
-
expect(subject.lint(test_model)).to eq(nil)
|
97
|
-
end
|
73
|
+
it_should_behave_like 'a linter linting a good model'
|
98
74
|
|
99
75
|
end
|
100
76
|
|
101
77
|
context 'because it has fewer than 5 tags' do
|
102
78
|
|
103
79
|
let(:test_model) do
|
104
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model"
|
80
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
105
81
|
model.tags = [:tag_1]
|
106
82
|
|
107
83
|
model
|
108
84
|
end
|
109
85
|
|
110
|
-
|
111
|
-
expect(subject.lint(test_model)).to eq(nil)
|
112
|
-
end
|
86
|
+
it_should_behave_like 'a linter linting a good model'
|
113
87
|
|
114
88
|
end
|
115
89
|
|
@@ -118,30 +92,26 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
118
92
|
context 'because its tags are empty' do
|
119
93
|
|
120
94
|
let(:test_model) do
|
121
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model"
|
95
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
122
96
|
model.tags = []
|
123
97
|
|
124
98
|
model
|
125
99
|
end
|
126
100
|
|
127
|
-
|
128
|
-
expect(subject.lint(test_model)).to eq(nil)
|
129
|
-
end
|
101
|
+
it_should_behave_like 'a linter linting a good model'
|
130
102
|
|
131
103
|
end
|
132
104
|
|
133
105
|
context 'because its tags are nil' do
|
134
106
|
|
135
107
|
let(:test_model) do
|
136
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model"
|
108
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
137
109
|
model.tags = nil
|
138
110
|
|
139
111
|
model
|
140
112
|
end
|
141
113
|
|
142
|
-
|
143
|
-
expect(subject.lint(test_model)).to eq(nil)
|
144
|
-
end
|
114
|
+
it_should_behave_like 'a linter linting a good model'
|
145
115
|
|
146
116
|
end
|
147
117
|
|
@@ -320,11 +290,7 @@ RSpec.describe CukeLinter::ElementWithTooManyTagsLinter do
|
|
320
290
|
|
321
291
|
let(:test_model) { CukeModeler::Model.new }
|
322
292
|
|
323
|
-
|
324
|
-
result = subject.lint(test_model)
|
325
|
-
|
326
|
-
expect(result).to eq(nil)
|
327
|
-
end
|
293
|
+
it_should_behave_like 'a linter linting a good model'
|
328
294
|
|
329
295
|
end
|
330
296
|
|
@@ -3,20 +3,7 @@ require_relative '../../../../../environments/rspec_env'
|
|
3
3
|
|
4
4
|
RSpec.describe CukeLinter::ExampleWithoutNameLinter do
|
5
5
|
|
6
|
-
let(:
|
7
|
-
model = CukeLinter::ModelFactory.generate_example_model
|
8
|
-
model.name = 'foo'
|
9
|
-
|
10
|
-
model
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:bad_data) do
|
14
|
-
model = CukeLinter::ModelFactory.generate_example_model
|
15
|
-
model.name = ''
|
16
|
-
|
17
|
-
model
|
18
|
-
end
|
19
|
-
|
6
|
+
let(:model_file_path) { 'some_file_path' }
|
20
7
|
|
21
8
|
it_should_behave_like 'a linter at the unit level'
|
22
9
|
|
@@ -29,54 +16,65 @@ RSpec.describe CukeLinter::ExampleWithoutNameLinter do
|
|
29
16
|
|
30
17
|
context 'an example with no name' do
|
31
18
|
|
32
|
-
|
33
|
-
model = CukeLinter::ModelFactory.generate_example_model(parent_file_path: 'path_to_file')
|
34
|
-
model.name = nil
|
19
|
+
context 'because the name is nil' do
|
35
20
|
|
36
|
-
|
37
|
-
|
21
|
+
let(:test_model) do
|
22
|
+
model = CukeLinter::ModelFactory.generate_example_model(parent_file_path: model_file_path)
|
23
|
+
model.name = nil
|
38
24
|
|
39
|
-
|
40
|
-
|
41
|
-
|
25
|
+
model
|
26
|
+
end
|
27
|
+
|
28
|
+
it_should_behave_like 'a linter linting a bad model'
|
29
|
+
|
30
|
+
it 'records a problem' do
|
31
|
+
result = subject.lint(test_model)
|
32
|
+
|
33
|
+
expect(result[:problem]).to eq('Example grouping has no name')
|
34
|
+
end
|
42
35
|
|
43
|
-
model
|
44
36
|
end
|
45
37
|
|
46
|
-
|
47
|
-
|
38
|
+
context 'because the name is empty' do
|
39
|
+
|
40
|
+
let(:test_model) do
|
41
|
+
model = CukeLinter::ModelFactory.generate_example_model(parent_file_path: model_file_path)
|
42
|
+
model.name = ''
|
43
|
+
|
44
|
+
model
|
45
|
+
end
|
48
46
|
|
49
|
-
|
47
|
+
it_should_behave_like 'a linter linting a bad model'
|
50
48
|
|
51
|
-
|
49
|
+
it 'records a problem' do
|
50
|
+
result = subject.lint(test_model)
|
51
|
+
|
52
|
+
expect(result[:problem]).to eq('Example grouping has no name')
|
53
|
+
end
|
52
54
|
|
53
|
-
expect(result[:problem]).to eq('Example has no name')
|
54
55
|
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
model_1.source_line = 1
|
60
|
-
model_2 = CukeLinter::ModelFactory.generate_example_model(parent_file_path: 'path_to_file')
|
61
|
-
model_2.name = nil
|
62
|
-
model_2.source_line = 3
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'an example with a name' do
|
63
60
|
|
64
|
-
|
65
|
-
|
61
|
+
let(:test_model) do
|
62
|
+
model = CukeLinter::ModelFactory.generate_example_model
|
63
|
+
model.name = 'a name'
|
66
64
|
|
67
|
-
|
68
|
-
expect(result[:location]).to eq('path_to_file:3')
|
65
|
+
model
|
69
66
|
end
|
70
67
|
|
68
|
+
it_should_behave_like 'a linter linting a good model'
|
69
|
+
|
71
70
|
end
|
72
71
|
|
72
|
+
|
73
73
|
context 'a non-example model' do
|
74
74
|
|
75
|
-
|
76
|
-
result = subject.lint(CukeModeler::Model.new)
|
75
|
+
let(:test_model) { CukeModeler::Model.new }
|
77
76
|
|
78
|
-
|
79
|
-
end
|
77
|
+
it_should_behave_like 'a linter linting a good model'
|
80
78
|
|
81
79
|
end
|
82
80
|
end
|
@@ -0,0 +1,293 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::FeatureWithTooManyDifferentTagsLinter 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('FeatureWithTooManyDifferentTagsLinter')
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'linting' do
|
17
|
+
|
18
|
+
context 'with a feature that contains too many different tags' do
|
19
|
+
|
20
|
+
let(:test_model) do
|
21
|
+
model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path)
|
22
|
+
model.tags = [CukeModeler::Tag.new('@1'),
|
23
|
+
CukeModeler::Tag.new('@2'),
|
24
|
+
CukeModeler::Tag.new('@3'),
|
25
|
+
CukeModeler::Tag.new('@4'),
|
26
|
+
CukeModeler::Tag.new('@5'),
|
27
|
+
CukeModeler::Tag.new('@6'),
|
28
|
+
CukeModeler::Tag.new('@7'),
|
29
|
+
CukeModeler::Tag.new('@8'),
|
30
|
+
CukeModeler::Tag.new('@9'),
|
31
|
+
CukeModeler::Tag.new('@10'),
|
32
|
+
CukeModeler::Tag.new('@11')]
|
33
|
+
|
34
|
+
model
|
35
|
+
end
|
36
|
+
|
37
|
+
it_should_behave_like 'a linter linting a bad model'
|
38
|
+
|
39
|
+
|
40
|
+
it 'records a problem' do
|
41
|
+
result = subject.lint(test_model)
|
42
|
+
|
43
|
+
expect(result[:problem]).to match(/^Feature contains too many different tags. \d+ tags found \(max 10\)\.$/)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'includes the number of different tags found in the problem record' do
|
47
|
+
unique_tag_count = test_model.tags.count
|
48
|
+
result = subject.lint(test_model)
|
49
|
+
expect(result[:problem]).to eq("Feature contains too many different tags. #{unique_tag_count} tags found (max 10).")
|
50
|
+
|
51
|
+
test_model.tags << CukeModeler::Tag.new('@had_better_be_unique')
|
52
|
+
result = subject.lint(test_model)
|
53
|
+
expect(result[:problem]).to eq("Feature contains too many different tags. #{unique_tag_count + 1} tags found (max 10).")
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'only counts unique tags' do
|
57
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
58
|
+
model.tags = []
|
59
|
+
100.times { model.tags << CukeModeler::Tag.new('@A') }
|
60
|
+
|
61
|
+
result = subject.lint(model)
|
62
|
+
|
63
|
+
expect(result).to eq(nil)
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with child models' do
|
67
|
+
|
68
|
+
let(:test_model) do
|
69
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
70
|
+
model.tags = [CukeModeler::Tag.new('@1'),
|
71
|
+
CukeModeler::Tag.new('@2'),
|
72
|
+
CukeModeler::Tag.new('@3'),
|
73
|
+
CukeModeler::Tag.new('@4'),
|
74
|
+
CukeModeler::Tag.new('@5'),
|
75
|
+
CukeModeler::Tag.new('@6'),
|
76
|
+
CukeModeler::Tag.new('@7'),
|
77
|
+
CukeModeler::Tag.new('@8'),
|
78
|
+
CukeModeler::Tag.new('@9'),
|
79
|
+
CukeModeler::Tag.new('@10'),
|
80
|
+
CukeModeler::Tag.new('@11')]
|
81
|
+
|
82
|
+
# Not all model types are a test but the models dont care and it's good enough for the test
|
83
|
+
model.tests = [child_model]
|
84
|
+
|
85
|
+
model
|
86
|
+
end
|
87
|
+
|
88
|
+
# Descriptive variable name, just in case what kinds of elements are taggable ever changes
|
89
|
+
taggable_elements = ['feature', 'scenario', 'outline', 'example']
|
90
|
+
|
91
|
+
taggable_elements.each do |model_type|
|
92
|
+
|
93
|
+
context 'that have tags' do
|
94
|
+
|
95
|
+
let(:child_model) do
|
96
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
97
|
+
model.tags = [CukeModeler::Tag.new('@12'),
|
98
|
+
CukeModeler::Tag.new('@13'),
|
99
|
+
CukeModeler::Tag.new('@14')]
|
100
|
+
|
101
|
+
model
|
102
|
+
end
|
103
|
+
|
104
|
+
it "considers tags from a #{model_type}" do
|
105
|
+
result = subject.lint(test_model)
|
106
|
+
expect(result[:problem]).to eq('Feature contains too many different tags. 14 tags found (max 10).')
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'that do not have tags' do
|
112
|
+
|
113
|
+
context 'because their tags are empty' do
|
114
|
+
|
115
|
+
let(:child_model) do
|
116
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
117
|
+
model.tags = []
|
118
|
+
|
119
|
+
model
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'can handle the child model without problem' do
|
123
|
+
expect { subject.lint(test_model) }.to_not raise_error
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
context 'with a feature that does not contain too many different tags' do
|
138
|
+
|
139
|
+
context 'because it contains 10 different tags' do
|
140
|
+
|
141
|
+
let(:test_model) do
|
142
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
143
|
+
model.tags = [CukeModeler::Tag.new('@1'),
|
144
|
+
CukeModeler::Tag.new('@2'),
|
145
|
+
CukeModeler::Tag.new('@3'),
|
146
|
+
CukeModeler::Tag.new('@4'),
|
147
|
+
CukeModeler::Tag.new('@5'),
|
148
|
+
CukeModeler::Tag.new('@6'),
|
149
|
+
CukeModeler::Tag.new('@7'),
|
150
|
+
CukeModeler::Tag.new('@8'),
|
151
|
+
CukeModeler::Tag.new('@9'),
|
152
|
+
CukeModeler::Tag.new('@10')]
|
153
|
+
|
154
|
+
model
|
155
|
+
end
|
156
|
+
|
157
|
+
it_should_behave_like 'a linter linting a good model'
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
context 'because it contains fewer than 10 different tags' do
|
162
|
+
|
163
|
+
let(:test_model) do
|
164
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
165
|
+
model.tags = [CukeModeler::Tag.new('@1')]
|
166
|
+
|
167
|
+
model
|
168
|
+
end
|
169
|
+
|
170
|
+
it_should_behave_like 'a linter linting a good model'
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
context 'because it contains no tags' do
|
175
|
+
|
176
|
+
context 'because its tags are empty' do
|
177
|
+
|
178
|
+
let(:test_model) do
|
179
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
180
|
+
model.tags = []
|
181
|
+
|
182
|
+
model
|
183
|
+
end
|
184
|
+
|
185
|
+
it_should_behave_like 'a linter linting a good model'
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'because its tags are nil' do
|
190
|
+
|
191
|
+
# NOTE: Not handling the case of the model's tags being nil because the model methods used in the
|
192
|
+
# linter's implementation will themselves not work when the tags are nil.
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
describe 'configuration' do
|
202
|
+
|
203
|
+
let(:default_tag_threshold) { 10 }
|
204
|
+
|
205
|
+
|
206
|
+
describe 'tag threshold configuration' do
|
207
|
+
|
208
|
+
context 'with no configuration' do
|
209
|
+
|
210
|
+
context 'because configuration never happened' do
|
211
|
+
|
212
|
+
let(:unconfigured_test_model) do
|
213
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
214
|
+
model.tags = []
|
215
|
+
(default_tag_threshold + 1).times { |count| model.tags << CukeModeler::Tag.new("@#{count}") }
|
216
|
+
|
217
|
+
model
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'defaults to a tag threshold of 10 tags' do
|
221
|
+
result = subject.lint(unconfigured_test_model)
|
222
|
+
|
223
|
+
expect(result[:problem]).to eq("Feature contains too many different tags. #{unconfigured_test_model.tags.count} tags found (max 10).")
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'because configuration did not set a tag threshold' do
|
229
|
+
|
230
|
+
let(:configuration) { {} }
|
231
|
+
let(:test_model) do
|
232
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
233
|
+
model.tags = []
|
234
|
+
(default_tag_threshold + 1).times { |count| model.tags << CukeModeler::Tag.new("@#{count}") }
|
235
|
+
|
236
|
+
model
|
237
|
+
end
|
238
|
+
|
239
|
+
before(:each) do
|
240
|
+
subject.configure(configuration)
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'defaults to a tag threshold of 10 tags' do
|
244
|
+
result = subject.lint(test_model)
|
245
|
+
|
246
|
+
expect(result[:problem]).to eq("Feature contains too many different tags. #{test_model.tags.count} tags found (max 10).")
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'with configuration' do
|
254
|
+
|
255
|
+
let(:tag_threshold) { 3 }
|
256
|
+
let(:configuration) { { 'TagCountThreshold' => tag_threshold } }
|
257
|
+
|
258
|
+
before(:each) do
|
259
|
+
subject.configure(configuration)
|
260
|
+
end
|
261
|
+
|
262
|
+
let(:test_model) do
|
263
|
+
model = CukeLinter::ModelFactory.generate_feature_model
|
264
|
+
model.tags = []
|
265
|
+
(tag_threshold + 1).times { |count| model.tags << CukeModeler::Tag.new("@#{count}") }
|
266
|
+
|
267
|
+
model
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'the tag threshold used is the configured value' do
|
271
|
+
result = subject.lint(test_model)
|
272
|
+
|
273
|
+
expect(result[:problem]).to eq("Feature contains too many different tags. #{test_model.tags.count} tags found (max #{tag_threshold}).")
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
context 'a non-feature model' do
|
284
|
+
|
285
|
+
let(:test_model) { CukeModeler::Model.new }
|
286
|
+
|
287
|
+
it_should_behave_like 'a linter linting a good model'
|
288
|
+
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|