cuke_linter 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +217 -211
  3. data/LICENSE.txt +21 -21
  4. data/README.md +160 -160
  5. data/cuke_linter.gemspec +59 -58
  6. data/exe/cuke_linter +112 -112
  7. data/lib/cuke_linter/configuration.rb +45 -45
  8. data/lib/cuke_linter/default_linters.rb +32 -32
  9. data/lib/cuke_linter/formatters/pretty_formatter.rb +84 -84
  10. data/lib/cuke_linter/gherkin.rb +10 -10
  11. data/lib/cuke_linter/linter_registration.rb +32 -32
  12. data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +35 -35
  13. data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +49 -49
  14. data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +48 -48
  15. data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +46 -46
  16. data/lib/cuke_linter/linters/example_without_name_linter.rb +19 -19
  17. data/lib/cuke_linter/linters/feature_file_with_invalid_name_linter.rb +20 -20
  18. data/lib/cuke_linter/linters/feature_file_with_mismatched_name_linter.rb +25 -25
  19. data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +35 -35
  20. data/lib/cuke_linter/linters/feature_without_description_linter.rb +19 -19
  21. data/lib/cuke_linter/linters/feature_without_name_linter.rb +19 -19
  22. data/lib/cuke_linter/linters/feature_without_scenarios_linter.rb +23 -23
  23. data/lib/cuke_linter/linters/linter.rb +42 -42
  24. data/lib/cuke_linter/linters/outline_with_single_example_row_linter.rb +22 -22
  25. data/lib/cuke_linter/linters/single_test_background_linter.rb +19 -19
  26. data/lib/cuke_linter/linters/step_with_end_period_linter.rb +19 -19
  27. data/lib/cuke_linter/linters/step_with_too_many_characters_linter.rb +38 -38
  28. data/lib/cuke_linter/linters/test_name_with_too_many_characters_linter.rb +38 -38
  29. data/lib/cuke_linter/linters/test_should_use_background_linter.rb +80 -80
  30. data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +33 -33
  31. data/lib/cuke_linter/linters/test_with_bad_name_linter.rb +23 -23
  32. data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +33 -33
  33. data/lib/cuke_linter/linters/test_with_no_name_linter.rb +19 -19
  34. data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +33 -33
  35. data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +46 -46
  36. data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +46 -46
  37. data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +33 -33
  38. data/lib/cuke_linter/linters/test_with_too_many_steps_linter.rb +27 -27
  39. data/lib/cuke_linter/version.rb +4 -4
  40. data/lib/cuke_linter.rb +196 -196
  41. data/testing/cucumber/features/command_line.feature +202 -202
  42. data/testing/cucumber/features/configuration/configuring_linters.feature +58 -58
  43. data/testing/cucumber/features/configuration/locally_scoping_linters.feature +55 -55
  44. data/testing/cucumber/features/configuration/using_configurations.feature +41 -41
  45. data/testing/cucumber/features/custom_linters.feature +56 -56
  46. data/testing/cucumber/features/default_linters.feature +57 -57
  47. data/testing/cucumber/features/formatters/pretty_formatter.feature +26 -26
  48. data/testing/cucumber/features/linters/background_does_more_than_setup.feature +84 -84
  49. data/testing/cucumber/features/linters/element_with_common_tags.feature +28 -28
  50. data/testing/cucumber/features/linters/element_with_duplicate_tags.feature +71 -71
  51. data/testing/cucumber/features/linters/element_with_too_many_tags.feature +70 -70
  52. data/testing/cucumber/features/linters/example_without_name.feature +34 -34
  53. data/testing/cucumber/features/linters/feature_file_with_invalid_name.feature +20 -20
  54. data/testing/cucumber/features/linters/feature_file_with_mismatched_name.feature +32 -32
  55. data/testing/cucumber/features/linters/feature_with_too_many_different_tags.feature +56 -56
  56. data/testing/cucumber/features/linters/feature_without_description.feature +17 -17
  57. data/testing/cucumber/features/linters/feature_without_name.feature +18 -18
  58. data/testing/cucumber/features/linters/feature_without_scenarios.feature +39 -39
  59. data/testing/cucumber/features/linters/outline_with_single_example_row.feature +23 -23
  60. data/testing/cucumber/features/linters/single_test_background.feature +24 -24
  61. data/testing/cucumber/features/linters/step_too_long.feature +43 -43
  62. data/testing/cucumber/features/linters/step_with_end_period.feature +21 -21
  63. data/testing/cucumber/features/linters/test_name_too_long.feature +41 -41
  64. data/testing/cucumber/features/linters/test_should_use_background.feature +29 -29
  65. data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +50 -50
  66. data/testing/cucumber/features/linters/test_with_bad_name.feature +29 -29
  67. data/testing/cucumber/features/linters/test_with_no_action_step.feature +56 -56
  68. data/testing/cucumber/features/linters/test_with_no_name.feature +23 -23
  69. data/testing/cucumber/features/linters/test_with_no_verification_step.feature +58 -58
  70. data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +57 -57
  71. data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +57 -57
  72. data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +50 -50
  73. data/testing/cucumber/features/linters/test_with_too_many_steps.feature +61 -61
  74. metadata +21 -25
  75. data/testing/cucumber/features/linters/rule_without_name.feature +0 -18
@@ -1,23 +1,23 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that have a bad name
4
- class TestWithBadNameLinter < Linter
5
-
6
- # The rule used to determine if a model has a problem
7
- def rule(model)
8
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
9
-
10
- lowercase_name = model.name.downcase
11
-
12
- lowercase_name.include?('test') ||
13
- lowercase_name.include?('verif') ||
14
- lowercase_name.include?('check')
15
- end
16
-
17
- # The message used to describe the problem that has been found
18
- def message
19
- '"Test", "Verify" and "Check" should not be used in scenario names.'
20
- end
21
-
22
- end
23
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that have a bad name
4
+ class TestWithBadNameLinter < Linter
5
+
6
+ # The rule used to determine if a model has a problem
7
+ def rule(model)
8
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
9
+
10
+ lowercase_name = model.name.downcase
11
+
12
+ lowercase_name.include?('test') ||
13
+ lowercase_name.include?('verif') ||
14
+ lowercase_name.include?('check')
15
+ end
16
+
17
+ # The message used to describe the problem that has been found
18
+ def message
19
+ '"Test", "Verify" and "Check" should not be used in scenario names.'
20
+ end
21
+
22
+ end
23
+ end
@@ -1,33 +1,33 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that do not have an action (i.e. 'When') step
4
- class TestWithNoActionStepLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @when_keywords = options['When']
9
- end
10
-
11
- # The rule used to determine if a model has a problem
12
- def rule(model)
13
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
-
15
- model_steps = model.steps || []
16
- background_steps = model.parent_model.has_background? ? model.parent_model.background.steps || [] : []
17
- all_steps = model_steps + background_steps
18
- all_steps.none? { |step| when_keywords.include?(step.keyword) }
19
- end
20
-
21
- # The message used to describe the problem that has been found
22
- def message
23
- "Test does not have a 'When' step."
24
- end
25
-
26
- private
27
-
28
- def when_keywords
29
- @when_keywords || [DEFAULT_WHEN_KEYWORD]
30
- end
31
-
32
- end
33
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that do not have an action (i.e. 'When') step
4
+ class TestWithNoActionStepLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @when_keywords = options['When']
9
+ end
10
+
11
+ # The rule used to determine if a model has a problem
12
+ def rule(model)
13
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
+
15
+ model_steps = model.steps || []
16
+ background_steps = model.parent_model.has_background? ? model.parent_model.background.steps || [] : []
17
+ all_steps = model_steps + background_steps
18
+ all_steps.none? { |step| when_keywords.include?(step.keyword) }
19
+ end
20
+
21
+ # The message used to describe the problem that has been found
22
+ def message
23
+ "Test does not have a 'When' step."
24
+ end
25
+
26
+ private
27
+
28
+ def when_keywords
29
+ @when_keywords || [DEFAULT_WHEN_KEYWORD]
30
+ end
31
+
32
+ end
33
+ end
@@ -1,19 +1,19 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that do not have a name
4
- class TestWithNoNameLinter < Linter
5
-
6
- # The rule used to determine if a model has a problem
7
- def rule(model)
8
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
9
-
10
- model.name.nil? || model.name.empty?
11
- end
12
-
13
- # The message used to describe the problem that has been found
14
- def message
15
- 'Test does not have a name.'
16
- end
17
-
18
- end
19
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that do not have a name
4
+ class TestWithNoNameLinter < Linter
5
+
6
+ # The rule used to determine if a model has a problem
7
+ def rule(model)
8
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
9
+
10
+ model.name.nil? || model.name.empty?
11
+ end
12
+
13
+ # The message used to describe the problem that has been found
14
+ def message
15
+ 'Test does not have a name.'
16
+ end
17
+
18
+ end
19
+ end
@@ -1,33 +1,33 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that do not have a verification (i.e. 'Then') step
4
- class TestWithNoVerificationStepLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @then_keywords = options['Then']
9
- end
10
-
11
- # The rule used to determine if a model has a problem
12
- def rule(model)
13
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
-
15
- model_steps = model.steps || []
16
- background_steps = model.parent_model.has_background? ? model.parent_model.background.steps || [] : []
17
- all_steps = model_steps + background_steps
18
- all_steps.none? { |step| then_keywords.include?(step.keyword) }
19
- end
20
-
21
- # The message used to describe the problem that has been found
22
- def message
23
- "Test does not have a 'Then' step."
24
- end
25
-
26
- private
27
-
28
- def then_keywords
29
- @then_keywords || [DEFAULT_THEN_KEYWORD]
30
- end
31
-
32
- end
33
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that do not have a verification (i.e. 'Then') step
4
+ class TestWithNoVerificationStepLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @then_keywords = options['Then']
9
+ end
10
+
11
+ # The rule used to determine if a model has a problem
12
+ def rule(model)
13
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
+
15
+ model_steps = model.steps || []
16
+ background_steps = model.parent_model.has_background? ? model.parent_model.background.steps || [] : []
17
+ all_steps = model_steps + background_steps
18
+ all_steps.none? { |step| then_keywords.include?(step.keyword) }
19
+ end
20
+
21
+ # The message used to describe the problem that has been found
22
+ def message
23
+ "Test does not have a 'Then' step."
24
+ end
25
+
26
+ private
27
+
28
+ def then_keywords
29
+ @then_keywords || [DEFAULT_THEN_KEYWORD]
30
+ end
31
+
32
+ end
33
+ end
@@ -1,46 +1,46 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that have a setup step that comes after an action step
4
- class TestWithSetupStepAfterActionStepLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @given_keywords = options['Given']
9
- @when_keywords = options['When']
10
- end
11
-
12
- # The rule used to determine if a model has a problem
13
- def rule(model)
14
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
15
-
16
- model_steps = model.steps || []
17
- action_step_found = false
18
-
19
- model_steps.each do |step|
20
- if action_step_found
21
- return true if given_keywords.include?(step.keyword)
22
- else
23
- action_step_found = when_keywords.include?(step.keyword)
24
- end
25
- end
26
-
27
- false
28
- end
29
-
30
- # The message used to describe the problem that has been found
31
- def message
32
- "Test has 'Given' step after 'When' step."
33
- end
34
-
35
- private
36
-
37
- def given_keywords
38
- @given_keywords || [DEFAULT_GIVEN_KEYWORD]
39
- end
40
-
41
- def when_keywords
42
- @when_keywords || [DEFAULT_WHEN_KEYWORD]
43
- end
44
-
45
- end
46
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that have a setup step that comes after an action step
4
+ class TestWithSetupStepAfterActionStepLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @given_keywords = options['Given']
9
+ @when_keywords = options['When']
10
+ end
11
+
12
+ # The rule used to determine if a model has a problem
13
+ def rule(model)
14
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
15
+
16
+ model_steps = model.steps || []
17
+ action_step_found = false
18
+
19
+ model_steps.each do |step|
20
+ if action_step_found
21
+ return true if given_keywords.include?(step.keyword)
22
+ else
23
+ action_step_found = when_keywords.include?(step.keyword)
24
+ end
25
+ end
26
+
27
+ false
28
+ end
29
+
30
+ # The message used to describe the problem that has been found
31
+ def message
32
+ "Test has 'Given' step after 'When' step."
33
+ end
34
+
35
+ private
36
+
37
+ def given_keywords
38
+ @given_keywords || [DEFAULT_GIVEN_KEYWORD]
39
+ end
40
+
41
+ def when_keywords
42
+ @when_keywords || [DEFAULT_WHEN_KEYWORD]
43
+ end
44
+
45
+ end
46
+ end
@@ -1,46 +1,46 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that have a setup step that comes after a verification step
4
- class TestWithSetupStepAfterVerificationStepLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @given_keywords = options['Given']
9
- @then_keywords = options['Then']
10
- end
11
-
12
- # The rule used to determine if a model has a problem
13
- def rule(model)
14
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
15
-
16
- model_steps = model.steps || []
17
- verification_step_found = false
18
-
19
- model_steps.each do |step|
20
- if verification_step_found
21
- return true if given_keywords.include?(step.keyword)
22
- else
23
- verification_step_found = then_keywords.include?(step.keyword)
24
- end
25
- end
26
-
27
- false
28
- end
29
-
30
- # The message used to describe the problem that has been found
31
- def message
32
- "Test has 'Given' step after 'Then' step."
33
- end
34
-
35
- private
36
-
37
- def given_keywords
38
- @given_keywords || [DEFAULT_GIVEN_KEYWORD]
39
- end
40
-
41
- def then_keywords
42
- @then_keywords || [DEFAULT_THEN_KEYWORD]
43
- end
44
-
45
- end
46
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that have a setup step that comes after a verification step
4
+ class TestWithSetupStepAfterVerificationStepLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @given_keywords = options['Given']
9
+ @then_keywords = options['Then']
10
+ end
11
+
12
+ # The rule used to determine if a model has a problem
13
+ def rule(model)
14
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
15
+
16
+ model_steps = model.steps || []
17
+ verification_step_found = false
18
+
19
+ model_steps.each do |step|
20
+ if verification_step_found
21
+ return true if given_keywords.include?(step.keyword)
22
+ else
23
+ verification_step_found = then_keywords.include?(step.keyword)
24
+ end
25
+ end
26
+
27
+ false
28
+ end
29
+
30
+ # The message used to describe the problem that has been found
31
+ def message
32
+ "Test has 'Given' step after 'Then' step."
33
+ end
34
+
35
+ private
36
+
37
+ def given_keywords
38
+ @given_keywords || [DEFAULT_GIVEN_KEYWORD]
39
+ end
40
+
41
+ def then_keywords
42
+ @then_keywords || [DEFAULT_THEN_KEYWORD]
43
+ end
44
+
45
+ end
46
+ end
@@ -1,33 +1,33 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that have a setup step as their final step
4
- class TestWithSetupStepAsFinalStepLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @given_keywords = options['Given']
9
- end
10
-
11
- # The rule used to determine if a model has a problem
12
- def rule(model)
13
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
-
15
- model_steps = model.steps || []
16
- return false unless model_steps.last
17
-
18
- given_keywords.include?(model_steps.last.keyword)
19
- end
20
-
21
- # The message used to describe the problem that has been found
22
- def message
23
- "Test has 'Given' as the final step."
24
- end
25
-
26
- private
27
-
28
- def given_keywords
29
- @given_keywords || [DEFAULT_GIVEN_KEYWORD]
30
- end
31
-
32
- end
33
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that have a setup step as their final step
4
+ class TestWithSetupStepAsFinalStepLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @given_keywords = options['Given']
9
+ end
10
+
11
+ # The rule used to determine if a model has a problem
12
+ def rule(model)
13
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
+
15
+ model_steps = model.steps || []
16
+ return false unless model_steps.last
17
+
18
+ given_keywords.include?(model_steps.last.keyword)
19
+ end
20
+
21
+ # The message used to describe the problem that has been found
22
+ def message
23
+ "Test has 'Given' as the final step."
24
+ end
25
+
26
+ private
27
+
28
+ def given_keywords
29
+ @given_keywords || [DEFAULT_GIVEN_KEYWORD]
30
+ end
31
+
32
+ end
33
+ end
@@ -1,27 +1,27 @@
1
- module CukeLinter
2
-
3
- # A linter that detects scenarios and outlines that have too many steps
4
- class TestWithTooManyStepsLinter < Linter
5
-
6
- # Changes the linting settings on the linter using the provided configuration
7
- def configure(options)
8
- @step_threshold = options['StepThreshold'] if options['StepThreshold']
9
- end
10
-
11
- # The rule used to determine if a model has a problem
12
- def rule(model)
13
- return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
-
15
- @linted_step_count = model.steps.nil? ? 0 : model.steps.count
16
- @linted_step_threshold = @step_threshold || 10
17
-
18
- @linted_step_count > @linted_step_threshold
19
- end
20
-
21
- # The message used to describe the problem that has been found
22
- def message
23
- "Test has too many steps. #{@linted_step_count} steps found (max #{@linted_step_threshold})."
24
- end
25
-
26
- end
27
- end
1
+ module CukeLinter
2
+
3
+ # A linter that detects scenarios and outlines that have too many steps
4
+ class TestWithTooManyStepsLinter < Linter
5
+
6
+ # Changes the linting settings on the linter using the provided configuration
7
+ def configure(options)
8
+ @step_threshold = options['StepThreshold'] if options['StepThreshold']
9
+ end
10
+
11
+ # The rule used to determine if a model has a problem
12
+ def rule(model)
13
+ return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)
14
+
15
+ @linted_step_count = model.steps.nil? ? 0 : model.steps.count
16
+ @linted_step_threshold = @step_threshold || 10
17
+
18
+ @linted_step_count > @linted_step_threshold
19
+ end
20
+
21
+ # The message used to describe the problem that has been found
22
+ def message
23
+ "Test has too many steps. #{@linted_step_count} steps found (max #{@linted_step_threshold})."
24
+ end
25
+
26
+ end
27
+ end
@@ -1,4 +1,4 @@
1
- module CukeLinter
2
- # The release version of this gem
3
- VERSION = '1.3.0'.freeze
4
- end
1
+ module CukeLinter
2
+ # The release version of this gem
3
+ VERSION = '1.4.0'.freeze
4
+ end