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,464 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestShouldUseBackgroundLinter 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('TestShouldUseBackgroundLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that shares a first step with all other tests in the feature" do
20
-
21
- let(:test_model) do
22
- step_text = 'the step'
23
- feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
24
- source_text: "Feature:
25
- Scenario:
26
- * #{step_text}
27
- Scenario Outline:
28
- * #{step_text}
29
- Examples:
30
- | param |
31
- | value |")
32
-
33
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
34
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
35
-
36
- model.parent_model = feature_model
37
- feature_model.tests << model
38
-
39
- model
40
- end
41
-
42
- it_should_behave_like 'a linter linting a bad model'
43
-
44
-
45
- it 'records a problem' do
46
- result = subject.lint(test_model)
47
-
48
- expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
49
- end
50
-
51
- end
52
-
53
- context 'with parameters that are not really parameters' do
54
-
55
- if (model_type == 'scenario')
56
-
57
- # Scenarios don't actually have parameters, even if they look like they do
58
- context 'because they are in scenarios' do
59
-
60
- let(:test_model) do
61
- step_text = 'the not really <parameterized> step'
62
- feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
63
- source_text: "Feature:
64
- Scenario:
65
- * #{step_text}
66
- Scenario:
67
- * #{step_text}")
68
-
69
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
70
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
71
-
72
- model.parent_model = feature_model
73
- feature_model.tests << model
74
-
75
- model
76
- end
77
-
78
- it_should_behave_like 'a linter linting a bad model'
79
-
80
-
81
- it 'records a problem' do
82
- result = subject.lint(test_model)
83
-
84
- expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
85
- end
86
-
87
- end
88
-
89
- end
90
-
91
-
92
- if model_type == 'outline'
93
-
94
- context 'because of extra whitespace' do
95
-
96
- let(:test_model) do
97
- # Whitespace is significant
98
- step_text = "the step < param_foo >"
99
- feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
100
- source_text: "Feature:
101
- Scenario Outline:
102
- * #{step_text}
103
- Examples:
104
- | param_foo |
105
- | value |
106
- Scenario Outline:
107
- * #{step_text}
108
- Examples:
109
- | param_foo |
110
- | value |")
111
-
112
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
113
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
114
-
115
- model.parent_model = feature_model
116
- feature_model.tests << model
117
-
118
- model
119
- end
120
-
121
- it_should_behave_like 'a linter linting a bad model'
122
-
123
-
124
- it 'records a problem' do
125
- result = subject.lint(test_model)
126
-
127
- expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
128
- end
129
-
130
- end
131
-
132
- end
133
-
134
- end
135
-
136
-
137
- context "with a #{model_type} that does not share a first step with all other tests in the feature" do
138
-
139
- context 'because the steps are different' do
140
-
141
- let(:test_model) do
142
- step_text = 'the step'
143
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
144
- Scenario:
145
- * #{step_text}
146
- Scenario Outline:
147
- * #{step_text}
148
- Examples:
149
- | param |
150
- | value |")
151
-
152
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
153
- model.steps = [CukeModeler::Step.new("* #{step_text} plus extra")]
154
-
155
- model.parent_model = feature_model
156
- feature_model.tests << model
157
-
158
- model
159
- end
160
-
161
- it_should_behave_like 'a linter linting a good model'
162
-
163
- end
164
-
165
- context 'because it has no steps' do
166
-
167
- context 'because its steps are empty' do
168
-
169
- let(:test_model) do
170
- step_text = 'the step'
171
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
172
- Scenario:
173
- * #{step_text}
174
- Scenario Outline:
175
- * #{step_text}
176
- Examples:
177
- | param |
178
- | value |")
179
-
180
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
181
- model.steps = []
182
-
183
- model.parent_model = feature_model
184
- feature_model.tests << model
185
-
186
- model
187
- end
188
-
189
- it_should_behave_like 'a linter linting a good model'
190
-
191
- end
192
-
193
- context 'because its steps are nil' do
194
-
195
- let(:test_model) do
196
- step_text = 'the step'
197
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
198
- Scenario:
199
- * #{step_text}
200
- Scenario Outline:
201
- * #{step_text}
202
- Examples:
203
- | param |
204
- | value |")
205
-
206
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
207
- model.steps = nil
208
-
209
- model.parent_model = feature_model
210
- feature_model.tests << model
211
-
212
- model
213
- end
214
-
215
- it_should_behave_like 'a linter linting a good model'
216
-
217
- end
218
-
219
- end
220
-
221
- context 'because another test has no steps' do
222
-
223
- context 'because its steps are empty' do
224
-
225
- let(:test_model) do
226
- step_text = 'the step'
227
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
228
- Scenario:
229
- * #{step_text}
230
- Scenario Outline:
231
- * #{step_text}
232
- Examples:
233
- | param |
234
- | value |")
235
-
236
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
237
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
238
-
239
- model.parent_model = feature_model
240
- feature_model.tests.first.steps = []
241
- feature_model.tests << model
242
-
243
- model
244
- end
245
-
246
- it_should_behave_like 'a linter linting a good model'
247
-
248
- end
249
-
250
- context 'because its steps are nil' do
251
-
252
- let(:test_model) do
253
- step_text = 'the step'
254
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
255
- Scenario:
256
- * #{step_text}
257
- Scenario Outline:
258
- * #{step_text}
259
- Examples:
260
- | param |
261
- | value |")
262
-
263
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
264
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
265
-
266
- model.parent_model = feature_model
267
- feature_model.tests.first.steps = nil
268
- feature_model.tests << model
269
-
270
- model
271
- end
272
-
273
- it_should_behave_like 'a linter linting a good model'
274
-
275
- end
276
-
277
- end
278
-
279
- context 'because there are not other tests in the feature' do
280
-
281
- let(:test_model) do
282
- step_text = 'the step'
283
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:')
284
-
285
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
286
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
287
-
288
- model.parent_model = feature_model
289
- feature_model.tests << model
290
-
291
- model
292
- end
293
-
294
- it_should_behave_like 'a linter linting a good model'
295
-
296
- end
297
-
298
- context 'because its first step contains a parameter' do
299
-
300
- let(:test_model) do
301
- step_text = 'the maybe <parameterized> step'
302
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
303
- Scenario:
304
- * #{step_text}
305
- Scenario Outline:
306
- * #{step_text}
307
- Examples:
308
- | parameterized |
309
- | value |")
310
-
311
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
312
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
313
-
314
- model.parent_model = feature_model
315
- feature_model.tests << model
316
-
317
- model
318
- end
319
-
320
- it_should_behave_like 'a linter linting a good model'
321
-
322
- if model_type == 'outline'
323
-
324
- context 'even with a bunch of parameterized outlines' do
325
-
326
- context 'with a parameter in the text of the step' do
327
-
328
- let(:test_model) do
329
- step_text = 'the <parameterized> step'
330
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
331
- Scenario Outline:
332
- * #{step_text}
333
- Examples:
334
- | parameterized |
335
- | value |
336
- Scenario Outline:
337
- * #{step_text}
338
- Examples:
339
- | parameterized |
340
- | value |")
341
-
342
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
343
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
344
-
345
- model.parent_model = feature_model
346
- feature_model.tests << model
347
-
348
- model
349
- end
350
-
351
- it_should_behave_like 'a linter linting a good model'
352
-
353
- end
354
-
355
- context 'with a parameter in the table of the step' do
356
-
357
- let(:test_model) do
358
- step_text = "the step\n | <param_foo> |"
359
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
360
- Scenario Outline:
361
- * #{step_text}
362
- Examples:
363
- | param_foo |
364
- | value |
365
- Scenario Outline:
366
- * #{step_text}
367
- Examples:
368
- | param_foo |
369
- | value |")
370
-
371
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
372
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
373
-
374
- model.parent_model = feature_model
375
- feature_model.tests << model
376
-
377
- model
378
- end
379
-
380
- it_should_behave_like 'a linter linting a good model'
381
-
382
- end
383
-
384
- context 'with a parameter in the doc string of the step' do
385
-
386
- let(:test_model) do
387
- step_text = "the step\n \"\"\"\n <param_foo>\n \"\"\""
388
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
389
- Scenario Outline:
390
- * #{step_text}
391
- Examples:
392
- | param_foo |
393
- | value |
394
- Scenario Outline:
395
- * #{step_text}
396
- Examples:
397
- | param_foo |
398
- | value |")
399
-
400
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
401
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
402
-
403
- model.parent_model = feature_model
404
- feature_model.tests << model
405
-
406
- model
407
- end
408
-
409
- it_should_behave_like 'a linter linting a good model'
410
-
411
- end
412
-
413
- context 'with inconsistent parameter usage' do
414
-
415
- let(:test_model) do
416
- step_text = "the step <param_foo>"
417
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
418
- Scenario Outline:
419
- * #{step_text}
420
- Examples:
421
- | param_foo |
422
- | value |
423
- Scenario Outline:
424
- * #{step_text}
425
- Examples:
426
- | param_bar |
427
- | value |
428
- Examples:
429
- | param_foo |
430
- | value |")
431
-
432
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
433
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
434
-
435
- model.parent_model = feature_model
436
- feature_model.tests << model
437
-
438
- model
439
- end
440
-
441
- it_should_behave_like 'a linter linting a good model'
442
-
443
- end
444
-
445
- # TODO: do outline parameters even get substituted in the doc string type?
446
- end
447
-
448
- end
449
-
450
- end
451
-
452
- end
453
-
454
- end
455
-
456
- context 'a non-test model' do
457
-
458
- let(:test_model) { CukeModeler::Model.new }
459
-
460
- it_should_behave_like 'a linter linting a good model'
461
-
462
- end
463
- end
464
- end