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,124 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithSetupStepAfterActionStepLinter 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('TestWithSetupStepAfterActionStepLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that has a setup step after an action step" do
20
-
21
- let(:test_model) do
22
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model",
23
- parent_file_path: model_file_path)
24
- model.steps = [CukeModeler::Step.new('When a step'),
25
- CukeModeler::Step.new('Given a step')]
26
-
27
- model
28
- end
29
-
30
- it_should_behave_like 'a linter linting a bad model'
31
-
32
-
33
- it 'records a problem' do
34
- result = subject.lint(test_model)
35
-
36
- expect(result[:problem]).to eq("Test has 'Given' step after 'When' step.")
37
- end
38
-
39
- end
40
-
41
- context "with a #{model_type} that does not have a setup step after an action step" do
42
-
43
- context 'because it has no steps' do
44
-
45
- context 'because its steps are empty' do
46
-
47
- let(:test_model) do
48
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
49
- model.steps = []
50
-
51
- model
52
- end
53
-
54
- it_should_behave_like 'a linter linting a good model'
55
-
56
- end
57
-
58
- context 'because its steps are nil' do
59
-
60
- let(:test_model) do
61
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
62
- model.steps = nil
63
-
64
- model
65
- end
66
-
67
- it_should_behave_like 'a linter linting a good model'
68
-
69
- end
70
-
71
- end
72
-
73
- context 'because its setup steps come before its action steps' do
74
-
75
- let(:test_model) do
76
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
77
- model.steps = [CukeModeler::Step.new('* a step')]
78
-
79
- model
80
- end
81
-
82
- it_should_behave_like 'a linter linting a good model'
83
-
84
- end
85
-
86
- end
87
-
88
- context "with a #{model_type} that has an associated background" do
89
-
90
- let(:test_model) do
91
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
92
- Background:
93
- Given a step
94
- When a step
95
- Given a step
96
- When a step')
97
-
98
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
99
- model.steps = [CukeModeler::Step.new('Given a step')]
100
-
101
- model.parent_model = feature_model
102
- feature_model.tests << model
103
-
104
- model
105
- end
106
-
107
- it 'does not consider those steps when linting' do
108
- expect(subject.lint(test_model)).to eq(nil)
109
- end
110
-
111
- end
112
-
113
- end
114
-
115
-
116
- context 'a non-test model' do
117
-
118
- let(:test_model) { CukeModeler::Model.new }
119
-
120
- it_should_behave_like 'a linter linting a good model'
121
-
122
- end
123
- end
124
- end
@@ -1,125 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithSetupStepAfterVerificationStepLinter 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('TestWithSetupStepAfterVerificationStepLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that has a setup step after a verification step" do
20
-
21
- let(:test_model) do
22
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model",
23
- parent_file_path: model_file_path)
24
- model.steps = [CukeModeler::Step.new('Then a step'),
25
- CukeModeler::Step.new('Given a step')]
26
-
27
- model
28
- end
29
-
30
- it_should_behave_like 'a linter linting a bad model'
31
-
32
-
33
- it 'records a problem' do
34
- result = subject.lint(test_model)
35
-
36
- expect(result[:problem]).to eq("Test has 'Given' step after 'Then' step.")
37
- end
38
-
39
- end
40
-
41
- context "with a #{model_type} that does not have a setup step after a verification step" do
42
-
43
- context 'because it has no steps' do
44
-
45
- context 'because its steps are empty' do
46
-
47
- let(:test_model) do
48
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
49
- model.steps = []
50
-
51
- model
52
- end
53
-
54
- it_should_behave_like 'a linter linting a good model'
55
-
56
- end
57
-
58
- context 'because its steps are nil' do
59
-
60
- let(:test_model) do
61
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
62
- model.steps = nil
63
-
64
- model
65
- end
66
-
67
- it_should_behave_like 'a linter linting a good model'
68
-
69
- end
70
-
71
- end
72
-
73
- context 'because its setup steps come before its verification steps' do
74
-
75
- let(:test_model) do
76
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
77
- model.steps = [CukeModeler::Step.new('Given a step'),
78
- CukeModeler::Step.new('Then a step'),]
79
-
80
- model
81
- end
82
-
83
- it_should_behave_like 'a linter linting a good model'
84
-
85
- end
86
-
87
- end
88
-
89
- context "with a #{model_type} that has an associated background" do
90
-
91
- let(:test_model) do
92
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
93
- Background:
94
- Given a step
95
- Then a step
96
- Given a step
97
- Then a step')
98
-
99
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
100
- model.steps = [CukeModeler::Step.new('Given a step')]
101
-
102
- model.parent_model = feature_model
103
- feature_model.tests << model
104
-
105
- model
106
- end
107
-
108
- it 'does not consider those steps when linting' do
109
- expect(subject.lint(test_model)).to eq(nil)
110
- end
111
-
112
- end
113
-
114
- end
115
-
116
-
117
- context 'a non-test model' do
118
-
119
- let(:test_model) { CukeModeler::Model.new }
120
-
121
- it_should_behave_like 'a linter linting a good model'
122
-
123
- end
124
- end
125
- end
@@ -1,98 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithSetupStepAsFinalStepLinter 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('TestWithSetupStepAsFinalStepLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that has a setup step as its final step" do
20
-
21
- let(:test_model) do
22
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
23
- model.steps = [CukeModeler::Step.new('When a step'),
24
- CukeModeler::Step.new('Given a step')]
25
-
26
- model
27
- end
28
-
29
- it_should_behave_like 'a linter linting a bad model'
30
-
31
-
32
- it 'records a problem' do
33
- result = subject.lint(test_model)
34
-
35
- expect(result[:problem]).to eq("Test has 'Given' as the final step.")
36
- end
37
-
38
- end
39
-
40
- context "with a #{model_type} that does not have a setup step as its final step" do
41
-
42
- context 'because it has no steps' do
43
-
44
- context 'because its steps are empty' do
45
-
46
- let(:test_model) do
47
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
48
- model.steps = []
49
-
50
- model
51
- end
52
-
53
- it_should_behave_like 'a linter linting a good model'
54
-
55
- end
56
-
57
- context 'because its steps are nil' do
58
-
59
- let(:test_model) do
60
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
61
- model.steps = nil
62
-
63
- model
64
- end
65
-
66
- it_should_behave_like 'a linter linting a good model'
67
-
68
- end
69
-
70
- end
71
-
72
- context 'because its final step is not a setup step' do
73
-
74
- let(:test_model) do
75
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
76
- model.steps = [CukeModeler::Step.new('Then a step')]
77
-
78
- model
79
- end
80
-
81
- it_should_behave_like 'a linter linting a good model'
82
-
83
- end
84
-
85
- end
86
-
87
- end
88
-
89
-
90
- context 'a non-test model' do
91
-
92
- let(:test_model) { CukeModeler::Model.new }
93
-
94
- it_should_behave_like 'a linter linting a good model'
95
-
96
- end
97
- end
98
- end
@@ -1,192 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithTooManyStepsLinter 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('TestWithTooManyStepsLinter')
14
- end
15
-
16
- describe 'linting' do
17
-
18
- ['scenario', 'outline'].each do |model_type|
19
-
20
- context "with a #{model_type} that has too many steps" do
21
-
22
- let(:test_model) do
23
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
24
- model.steps = [:step_1,
25
- :step_2,
26
- :step_3,
27
- :step_4,
28
- :step_5,
29
- :step_6,
30
- :step_7,
31
- :step_8,
32
- :step_9,
33
- :step_10,
34
- :step_11]
35
-
36
- model
37
- end
38
-
39
- it_should_behave_like 'a linter linting a bad model'
40
-
41
-
42
- it 'records a problem' do
43
- result = subject.lint(test_model)
44
-
45
- expect(result[:problem]).to match(/^Test has too many steps. \d+ steps found \(max 10\)/)
46
- end
47
-
48
- it 'includes the number of steps found in the problem record' do
49
- step_count = test_model.steps.count
50
- result = subject.lint(test_model)
51
- expect(result[:problem]).to eq("Test has too many steps. #{step_count} steps found (max 10).")
52
-
53
- test_model.steps << :another_step
54
- result = subject.lint(test_model)
55
- expect(result[:problem]).to eq("Test has too many steps. #{step_count + 1} steps found (max 10).")
56
- end
57
-
58
- end
59
-
60
- context "with a #{model_type} that does not have too many steps" do
61
-
62
- context 'because it has fewer than 10 steps' do
63
-
64
- let(:test_model) do
65
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
66
- model.steps = [:step_1]
67
-
68
- model
69
- end
70
-
71
- it_should_behave_like 'a linter linting a good model'
72
-
73
- end
74
-
75
- context 'because it has no steps' do
76
-
77
- context 'because its steps are empty' do
78
-
79
- let(:test_model) do
80
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
81
- model.steps = []
82
-
83
- model
84
- end
85
-
86
- it_should_behave_like 'a linter linting a good model'
87
-
88
- end
89
-
90
- context 'because its steps are nil' do
91
-
92
- let(:test_model) do
93
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
94
- model.steps = nil
95
-
96
- model
97
- end
98
-
99
- it_should_behave_like 'a linter linting a good model'
100
-
101
- end
102
-
103
- end
104
-
105
- end
106
-
107
-
108
- describe 'configuration' do
109
-
110
- context 'with no configuration' do
111
-
112
- let(:default_step_threshhold) { 10 }
113
-
114
- context 'because configuration never happened' do
115
-
116
- let(:unconfigured_test_model) do
117
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
118
- model.steps = []
119
- (default_step_threshhold + 1).times { model.steps << :a_step }
120
-
121
- model
122
- end
123
-
124
- it 'defaults to a step threshold of 10 steps' do
125
- result = subject.lint(unconfigured_test_model)
126
-
127
- expect(result[:problem]).to match(/^Test has too many steps. #{unconfigured_test_model.steps.count} steps found \(max 10\)/)
128
- end
129
-
130
- end
131
-
132
- context 'because configuration did not set a step threshold' do
133
- let(:configuration) { {} }
134
- let(:configured_test_model) do
135
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
136
- model.steps = []
137
- (default_step_threshhold + 1).times { model.steps << :a_step }
138
-
139
- subject.configure(configuration)
140
-
141
- model
142
- end
143
-
144
- it 'defaults to a step threshold of 10 steps' do
145
- result = subject.lint(configured_test_model)
146
-
147
- expect(result[:problem]).to match(/^Test has too many steps. #{configured_test_model.steps.count} steps found \(max 10\)/)
148
- end
149
-
150
- end
151
-
152
- end
153
-
154
-
155
- context 'with configuration' do
156
-
157
- let(:step_threshhold) { 3 }
158
- let(:configuration) { { 'StepThreshold' => step_threshhold } }
159
-
160
- subject { linter = CukeLinter::TestWithTooManyStepsLinter.new
161
- linter.configure(configuration)
162
- linter }
163
-
164
- let(:test_model) do
165
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
166
- model.steps = []
167
- (step_threshhold + 1).times { model.steps << :a_step }
168
-
169
- model
170
- end
171
-
172
- it 'the step threshold used is the configured value' do
173
- result = subject.lint(test_model)
174
-
175
- expect(result[:problem]).to match(/^Test has too many steps. #{test_model.steps.count} steps found \(max #{step_threshhold}\)/)
176
- end
177
-
178
- end
179
-
180
- end
181
-
182
- end
183
-
184
- context 'a non-test model' do
185
-
186
- let(:test_model) { CukeModeler::Model.new }
187
-
188
- it_should_behave_like 'a linter linting a good model'
189
-
190
- end
191
- end
192
- end