cuke_linter 0.12.0 → 1.1.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 +41 -1
  3. data/README.md +12 -8
  4. data/cuke_linter.gemspec +25 -21
  5. data/exe/cuke_linter +3 -1
  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 +56 -4
  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 +88 -106
  37. data/.gitignore +0 -19
  38. data/.simplecov +0 -8
  39. data/.travis.yml +0 -23
  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 -226
  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,226 +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 a #{model_type} that does not share a first step with all other tests in the feature" do
54
-
55
- context 'because the steps are different' do
56
-
57
- let(:test_model) do
58
- step_text = 'the step'
59
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
60
- Scenario:
61
- * #{step_text}
62
- Scenario Outline:
63
- * #{step_text}
64
- Examples:
65
- | param |
66
- | value |")
67
-
68
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
69
- model.steps = [CukeModeler::Step.new("* #{step_text} plus extra")]
70
-
71
- model.parent_model = feature_model
72
- feature_model.tests << model
73
-
74
- model
75
- end
76
-
77
- it_should_behave_like 'a linter linting a good model'
78
-
79
- end
80
-
81
- context 'because it has no steps' do
82
-
83
- context 'because its steps are empty' do
84
-
85
- let(:test_model) do
86
- step_text = 'the step'
87
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
88
- Scenario:
89
- * #{step_text}
90
- Scenario Outline:
91
- * #{step_text}
92
- Examples:
93
- | param |
94
- | value |")
95
-
96
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
97
- model.steps = []
98
-
99
- model.parent_model = feature_model
100
- feature_model.tests << model
101
-
102
- model
103
- end
104
-
105
- it_should_behave_like 'a linter linting a good model'
106
-
107
- end
108
-
109
- context 'because its steps are nil' do
110
-
111
- let(:test_model) do
112
- step_text = 'the step'
113
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
114
- Scenario:
115
- * #{step_text}
116
- Scenario Outline:
117
- * #{step_text}
118
- Examples:
119
- | param |
120
- | value |")
121
-
122
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
123
- model.steps = nil
124
-
125
- model.parent_model = feature_model
126
- feature_model.tests << model
127
-
128
- model
129
- end
130
-
131
- it_should_behave_like 'a linter linting a good model'
132
-
133
- end
134
-
135
- end
136
-
137
- context 'because another test has no steps' do
138
-
139
- context 'because its steps are empty' 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}")]
154
-
155
- model.parent_model = feature_model
156
- feature_model.tests.first.steps = []
157
- feature_model.tests << model
158
-
159
- model
160
- end
161
-
162
- it_should_behave_like 'a linter linting a good model'
163
-
164
- end
165
-
166
- context 'because its steps are nil' do
167
-
168
- let(:test_model) do
169
- step_text = 'the step'
170
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
171
- Scenario:
172
- * #{step_text}
173
- Scenario Outline:
174
- * #{step_text}
175
- Examples:
176
- | param |
177
- | value |")
178
-
179
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
180
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
181
-
182
- model.parent_model = feature_model
183
- feature_model.tests.first.steps = nil
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
- end
194
-
195
- context 'because there are not other tests in the feature' do
196
-
197
- let(:test_model) do
198
- step_text = 'the step'
199
- feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:')
200
-
201
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
202
- model.steps = [CukeModeler::Step.new("* #{step_text}")]
203
-
204
- model.parent_model = feature_model
205
- feature_model.tests << model
206
-
207
- model
208
- end
209
-
210
- it_should_behave_like 'a linter linting a good model'
211
-
212
- end
213
-
214
- end
215
-
216
- end
217
-
218
- context 'a non-test model' do
219
-
220
- let(:test_model) { CukeModeler::Model.new }
221
-
222
- it_should_behave_like 'a linter linting a good model'
223
-
224
- end
225
- end
226
- end
@@ -1,98 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithActionStepAsFinalStepLinter 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('TestWithActionStepAsFinalStepLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that has an action 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('Given a step'),
24
- CukeModeler::Step.new('When 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 'When' as the final step.")
36
- end
37
-
38
- end
39
-
40
- context "with a #{model_type} that does not have an action 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 an action 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,81 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithBadNameLinter 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('TestWithBadNameLinter')
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 bad name" do
20
-
21
- context 'because its name contains a bad word' do
22
-
23
- ['test', 'check', 'verify'].each do |bad_word|
24
-
25
- let(:test_model) do
26
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
27
- model.name = "#{bad_word} bad names are reported"
28
-
29
- model
30
- end
31
-
32
- it_should_behave_like 'a linter linting a bad model'
33
-
34
- it 'records a problem' do
35
- result = subject.lint(test_model)
36
-
37
- expect(result[:problem]).to eq('"Test", "Verify" and "Check" should not be used in scenario names.')
38
- end
39
-
40
- end
41
-
42
- context 'because bad words are case insensitive' do
43
-
44
- ['Test', 'TEST'].each do |bad_word|
45
-
46
- let(:test_model) do
47
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
48
- model.name = "#{bad_word} bad names are reported"
49
-
50
- model
51
- end
52
-
53
- it_should_behave_like 'a linter linting a bad model'
54
-
55
- it 'records a problem' do
56
- result = subject.lint(test_model)
57
-
58
- expect(result[:problem]).to eq('"Test", "Verify" and "Check" should not be used in scenario names.')
59
- end
60
-
61
- end
62
-
63
- end
64
-
65
- end
66
-
67
- context 'a non-test model' do
68
-
69
- let(:test_model) { CukeModeler::Model.new }
70
-
71
- it_should_behave_like 'a linter linting a good model'
72
-
73
- end
74
-
75
- end
76
-
77
- end
78
-
79
- end
80
-
81
- end
@@ -1,176 +0,0 @@
1
- require_relative '../../../../../environments/rspec_env'
2
-
3
-
4
- RSpec.describe CukeLinter::TestWithNoActionStepLinter 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('TestWithNoActionStepLinter')
13
- end
14
-
15
- describe 'linting' do
16
-
17
- ['scenario', 'outline'].each do |model_type|
18
-
19
- context "with a #{model_type} that has no action step" do
20
-
21
- context 'because it has no steps' do
22
-
23
- context 'because its steps are empty' do
24
-
25
- let(:test_model) do
26
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
27
- model.steps = []
28
-
29
- model
30
- end
31
-
32
- it 'records a problem' do
33
- result = subject.lint(test_model)
34
-
35
- expect(result[:problem]).to eq("Test does not have a 'When' step.")
36
- end
37
-
38
- it_should_behave_like 'a linter linting a bad model'
39
-
40
- end
41
-
42
- context 'because its steps are nil' do
43
-
44
- let(:test_model) do
45
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
46
- model.steps = nil
47
-
48
- model
49
- end
50
-
51
- it 'records a problem' do
52
- result = subject.lint(test_model)
53
-
54
- expect(result[:problem]).to eq("Test does not have a 'When' step.")
55
- end
56
-
57
- it_should_behave_like 'a linter linting a bad model'
58
-
59
- end
60
-
61
- end
62
-
63
- context 'because none of its steps is an action step' do
64
-
65
- let(:test_model) do
66
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
67
- model.steps = [CukeModeler::Step.new('* not an action step')]
68
-
69
- model
70
- end
71
-
72
- it 'records a problem' do
73
- result = subject.lint(test_model)
74
-
75
- expect(result[:problem]).to eq("Test does not have a 'When' step.")
76
- end
77
-
78
- it_should_behave_like 'a linter linting a bad model'
79
-
80
- end
81
-
82
- end
83
-
84
- context "with a #{model_type} that does have an action step" do
85
-
86
- context 'that comes from its background' do
87
-
88
- let(:test_model) do
89
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
90
- model.steps = []
91
- background_model = CukeModeler::Background.new
92
- background_model.steps = [CukeModeler::Step.new('When an action step')]
93
- model.parent_model.background = background_model
94
-
95
- model
96
- end
97
-
98
- it_should_behave_like 'a linter linting a good model'
99
-
100
- end
101
-
102
- context 'that is part of itself' do
103
-
104
- let(:test_model) do
105
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
106
- model.steps = [CukeModeler::Step.new('When an action step')]
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
- ['scenario', 'outline'].each do |model_type|
120
-
121
- context "with a #{model_type} that has a related background" do
122
-
123
- let(:test_model) do
124
- model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
125
- model.parent_model.background = background_model
126
-
127
- model
128
- end
129
-
130
- context 'that has no background steps' do
131
- context 'because its steps are empty' do
132
-
133
- let(:background_model) do
134
- model = CukeModeler::Background.new
135
- model.steps = []
136
-
137
- model
138
- end
139
-
140
- it 'can handle it' do
141
- expect { subject.lint(test_model) }.to_not raise_error
142
- end
143
-
144
- end
145
-
146
- context 'because its steps are nil' do
147
-
148
- let(:background_model) do
149
- model = CukeModeler::Background.new
150
- model.steps = nil
151
-
152
- model
153
- end
154
-
155
- it 'can handle it' do
156
- expect { subject.lint(test_model) }.to_not raise_error
157
- end
158
-
159
- end
160
-
161
- end
162
-
163
- end
164
-
165
- end
166
-
167
-
168
- context 'a non-test model' do
169
-
170
- let(:test_model) { CukeModeler::Model.new }
171
-
172
- it_should_behave_like 'a linter linting a good model'
173
-
174
- end
175
- end
176
- end