cuke_linter 0.13.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +4 -4
  4. data/cuke_linter.gemspec +3 -3
  5. data/lib/cuke_linter.rb +5 -3
  6. data/lib/cuke_linter/version.rb +1 -1
  7. metadata +2 -86
  8. data/.gitignore +0 -19
  9. data/.simplecov +0 -8
  10. data/.travis.yml +0 -33
  11. data/CONTRIBUTING.md +0 -26
  12. data/Gemfile +0 -6
  13. data/Rakefile +0 -63
  14. data/appveyor.yml +0 -43
  15. data/bin/console +0 -14
  16. data/bin/setup +0 -8
  17. data/environments/common_env.rb +0 -12
  18. data/environments/cucumber_env.rb +0 -22
  19. data/environments/rspec_env.rb +0 -50
  20. data/testing/cucumber/step_definitions/action_steps.rb +0 -84
  21. data/testing/cucumber/step_definitions/setup_steps.rb +0 -258
  22. data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
  23. data/testing/file_helper.rb +0 -41
  24. data/testing/formatter_factory.rb +0 -15
  25. data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
  26. data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
  27. data/testing/linter_factory.rb +0 -60
  28. data/testing/model_factory.rb +0 -109
  29. data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
  30. data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
  31. data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
  32. data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
  33. data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
  34. data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
  35. data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
  36. data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
  37. data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
  38. data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
  39. data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
  40. data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
  41. data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
  42. data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
  43. data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
  44. data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
  45. data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
  46. data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
  47. data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
  48. data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
  49. data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
  50. data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
  51. data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
  52. data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
  53. data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
  54. data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
  55. data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
  56. data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
  57. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
  58. data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
  59. data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
  60. data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
  61. data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -114
  62. data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
  63. data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
  64. data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -186
  65. data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
  66. data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
  67. data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
  68. data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
  69. data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
  70. data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
  71. data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
  72. data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
  73. data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
  74. data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
  75. data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
  76. data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
  77. data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
  78. data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
  79. data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
  80. data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
  81. data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
  82. data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -464
  83. data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -165
  84. data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
  85. data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -244
  86. data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
  87. data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -246
  88. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -233
  89. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -233
  90. data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -164
  91. data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -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
@@ -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