cuke_linter 0.12.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -1
  3. data/README.md +12 -8
  4. data/cuke_linter.gemspec +26 -22
  5. data/exe/cuke_linter +4 -2
  6. data/lib/cuke_linter.rb +119 -176
  7. data/lib/cuke_linter/configuration.rb +45 -0
  8. data/lib/cuke_linter/default_linters.rb +32 -0
  9. data/lib/cuke_linter/formatters/pretty_formatter.rb +63 -35
  10. data/lib/cuke_linter/gherkin.rb +10 -0
  11. data/lib/cuke_linter/linter_registration.rb +32 -0
  12. data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
  13. data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +23 -14
  14. data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +18 -13
  15. data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +17 -11
  16. data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +1 -3
  17. data/lib/cuke_linter/linters/feature_without_description_linter.rb +1 -1
  18. data/lib/cuke_linter/linters/linter.rb +17 -13
  19. data/lib/cuke_linter/linters/step_with_too_many_characters_linter.rb +2 -2
  20. data/lib/cuke_linter/linters/test_should_use_background_linter.rb +23 -15
  21. data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
  22. data/lib/cuke_linter/linters/test_with_bad_name_linter.rb +4 -4
  23. data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +12 -1
  24. data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +12 -1
  25. data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +18 -2
  26. data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +18 -2
  27. data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +12 -1
  28. data/lib/cuke_linter/version.rb +1 -1
  29. data/testing/cucumber/features/linters/background_does_more_than_setup.feature +34 -0
  30. data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +25 -3
  31. data/testing/cucumber/features/linters/test_with_no_action_step.feature +27 -1
  32. data/testing/cucumber/features/linters/test_with_no_verification_step.feature +28 -1
  33. data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +28 -1
  34. data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +28 -1
  35. data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +25 -3
  36. metadata +101 -117
  37. data/.gitignore +0 -19
  38. data/.simplecov +0 -8
  39. data/.travis.yml +0 -33
  40. data/CONTRIBUTING.md +0 -26
  41. data/Gemfile +0 -6
  42. data/Rakefile +0 -63
  43. data/appveyor.yml +0 -43
  44. data/bin/console +0 -14
  45. data/bin/setup +0 -8
  46. data/environments/common_env.rb +0 -12
  47. data/environments/cucumber_env.rb +0 -22
  48. data/environments/rspec_env.rb +0 -50
  49. data/testing/cucumber/step_definitions/action_steps.rb +0 -84
  50. data/testing/cucumber/step_definitions/setup_steps.rb +0 -230
  51. data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
  52. data/testing/file_helper.rb +0 -41
  53. data/testing/formatter_factory.rb +0 -15
  54. data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
  55. data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
  56. data/testing/linter_factory.rb +0 -60
  57. data/testing/model_factory.rb +0 -109
  58. data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
  59. data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
  60. data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
  61. data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
  62. data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
  63. data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
  64. data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
  65. data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
  66. data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
  67. data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
  68. data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
  69. data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
  70. data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
  71. data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
  72. data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
  73. data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
  74. data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
  75. data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
  76. data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
  77. data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
  78. data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
  79. data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
  80. data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
  81. data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
  82. data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
  83. data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
  84. data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
  85. data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
  86. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
  87. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
  88. data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
  89. data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
  90. data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -102
  91. data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
  92. data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
  93. data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -77
  94. data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
  95. data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
  96. data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
  97. data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
  98. data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
  99. data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
  100. data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
  101. data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
  102. data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
  103. data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
  104. data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
  105. data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
  106. data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
  107. data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
  108. data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
  109. data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
  110. data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
  111. data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -464
  112. data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -98
  113. data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
  114. data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -176
  115. data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
  116. data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -179
  117. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -124
  118. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -125
  119. data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -98
  120. data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,81 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::ExampleWithoutNameLinter 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('ExampleWithoutNameLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- context 'an example with no name' do
18
-
19
- context 'because the name is nil' do
20
-
21
- let(:test_model) do
22
- model = CukeLinter::ModelFactory.generate_example_model(parent_file_path: model_file_path)
23
- model.name = nil
24
-
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
35
-
36
- end
37
-
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
46
-
47
- it_should_behave_like 'a linter linting a bad model'
48
-
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
54
-
55
- end
56
-
57
- end
58
-
59
- context 'an example with a name' do
60
-
61
- let(:test_model) do
62
- model = CukeLinter::ModelFactory.generate_example_model
63
- model.name = 'a name'
64
-
65
- model
66
- end
67
-
68
- it_should_behave_like 'a linter linting a good model'
69
-
70
- end
71
-
72
-
73
- context 'a non-example model' do
74
-
75
- let(:test_model) { CukeModeler::Model.new }
76
-
77
- it_should_behave_like 'a linter linting a good model'
78
-
79
- end
80
- end
81
- end
@@ -1,106 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::FeatureFileWithInvalidNameLinter 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('FeatureFileWithInvalidNameLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- it "only lints the file name" do
18
- test_model = CukeLinter::ModelFactory.generate_feature_file_model
19
- test_model.path = 'bad-directory/good_file.feature'
20
-
21
- expect(subject.lint(test_model)).to be_nil
22
- end
23
-
24
- context "with a feature file model that has an invalid file name" do
25
-
26
- let(:test_model) do
27
- model = CukeLinter::ModelFactory.generate_feature_file_model
28
-
29
- model.path = model_file_path
30
- model
31
- end
32
-
33
- context 'because its file name is capitalized' do
34
- let(:model_file_path) { 'Terrible' }
35
-
36
- it_should_behave_like 'a linter linting a bad model'
37
-
38
- it 'records a problem' do
39
- result = subject.lint(test_model)
40
-
41
- expect(result[:problem]).to eq('Feature files should be snake_cased.')
42
- end
43
- end
44
-
45
- context 'because its file name is camel-cased' do
46
- let(:model_file_path) { 'veryBad' }
47
-
48
- it_should_behave_like 'a linter linting a bad model'
49
-
50
- it 'records a problem' do
51
- result = subject.lint(test_model)
52
-
53
- expect(result[:problem]).to eq('Feature files should be snake_cased.')
54
- end
55
- end
56
-
57
- context 'because its file name contains whitespace' do
58
- let(:model_file_path) { 'stop this' }
59
-
60
- it_should_behave_like 'a linter linting a bad model'
61
-
62
- it 'records a problem' do
63
- result = subject.lint(test_model)
64
-
65
- expect(result[:problem]).to eq('Feature files should be snake_cased.')
66
- end
67
- end
68
-
69
- context 'because its file name is hyphenated' do
70
- let(:model_file_path) { 'the-worst-path' }
71
-
72
- it_should_behave_like 'a linter linting a bad model'
73
-
74
- it 'records a problem' do
75
- result = subject.lint(test_model)
76
-
77
- expect(result[:problem]).to eq('Feature files should be snake_cased.')
78
- end
79
- end
80
-
81
- end
82
-
83
- context "with a feature file model that does have a valid file name" do
84
-
85
- let(:test_model) do
86
- model = CukeLinter::ModelFactory.generate_feature_file_model
87
-
88
- model.path = 'very_good_path'
89
- model
90
- end
91
-
92
- it_should_behave_like 'a linter linting a good model'
93
-
94
- end
95
-
96
- context 'a non-feature-file model' do
97
-
98
- let(:test_model) { CukeModeler::Model.new }
99
-
100
- it_should_behave_like 'a linter linting a good model'
101
-
102
- end
103
-
104
- end
105
-
106
- end
@@ -1,124 +0,0 @@
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
@@ -1,293 +0,0 @@
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