cuke_linter 0.6.0 → 0.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -1
- data/cuke_linter.gemspec +1 -0
- data/lib/cuke_linter.rb +24 -3
- data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +41 -0
- data/lib/cuke_linter/linters/feature_without_name_linter.rb +20 -0
- data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +23 -0
- data/lib/cuke_linter/linters/test_with_no_name_linter.rb +20 -0
- data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +23 -0
- data/lib/cuke_linter/linters/test_with_too_many_steps_linter.rb +1 -1
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/command_line.feature +6 -4
- data/testing/cucumber/features/configuration/configuring_linters.feature +36 -0
- data/testing/cucumber/features/linters/{background_does_more_than_setup_linter.feature → background_does_more_than_setup.feature} +2 -2
- data/testing/cucumber/features/linters/custom_linters.feature +3 -3
- data/testing/cucumber/features/linters/default_linters.feature +5 -1
- data/testing/cucumber/features/linters/element_with_too_many_tags.feature +70 -0
- data/testing/cucumber/features/linters/example_without_name.feature +6 -1
- data/testing/cucumber/features/linters/feature_without_description.feature +1 -1
- data/testing/cucumber/features/linters/feature_without_name.feature +18 -0
- data/testing/cucumber/features/linters/feature_without_scenarios.feature +1 -1
- data/testing/cucumber/features/linters/outline_with_single_example_row.feature +1 -1
- data/testing/cucumber/features/linters/{single_test_background_linter.feature → single_test_background.feature} +1 -1
- data/testing/cucumber/features/linters/step_too_long.feature +3 -3
- data/testing/cucumber/features/linters/step_with_end_period.feature +1 -1
- data/testing/cucumber/features/linters/test_with_no_action_step.feature +30 -0
- data/testing/cucumber/features/linters/test_with_no_name.feature +23 -0
- data/testing/cucumber/features/linters/test_with_no_verification_step.feature +31 -0
- data/testing/cucumber/features/linters/test_with_too_many_steps.feature +6 -6
- data/testing/cucumber/step_definitions/setup_steps.rb +24 -0
- data/testing/cucumber/step_definitions/verification_steps.rb +5 -1
- data/testing/model_factory.rb +1 -0
- data/testing/rspec/spec/integration/cli_integration_spec.rb +16 -11
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +37 -0
- data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +8 -0
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +333 -0
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +112 -0
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +53 -52
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +217 -0
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +115 -0
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +217 -0
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +2 -2
- metadata +24 -4
@@ -0,0 +1,217 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::TestWithNoVerificationStepLinter do
|
5
|
+
|
6
|
+
let(:good_data) do
|
7
|
+
CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
|
8
|
+
Then a verification step')
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:bad_data) do
|
12
|
+
CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
|
13
|
+
* no verification step')
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
it_should_behave_like 'a linter at the unit level'
|
18
|
+
|
19
|
+
|
20
|
+
it 'has a name' do
|
21
|
+
expect(subject.name).to eq('TestWithNoVerificationStepLinter')
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'linting' do
|
25
|
+
|
26
|
+
['scenario', 'outline'].each do |model_type|
|
27
|
+
|
28
|
+
context "with a #{model_type} that has no verification step" do
|
29
|
+
|
30
|
+
context 'because it has no steps' do
|
31
|
+
|
32
|
+
context 'because its steps are empty' do
|
33
|
+
|
34
|
+
let(:test_model) do
|
35
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
36
|
+
model.steps = []
|
37
|
+
|
38
|
+
model
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'records a problem' do
|
42
|
+
result = subject.lint(test_model)
|
43
|
+
|
44
|
+
expect(result[:problem]).to eq("Test does not have a 'Then' step.")
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'records the location of the problem' do
|
48
|
+
test_model.source_line = 1
|
49
|
+
result = subject.lint(test_model)
|
50
|
+
expect(result[:location]).to eq('path_to_file:1')
|
51
|
+
|
52
|
+
test_model.source_line = 3
|
53
|
+
result = subject.lint(test_model)
|
54
|
+
expect(result[:location]).to eq('path_to_file:3')
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'because its steps are nil' do
|
60
|
+
|
61
|
+
let(:test_model) do
|
62
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
63
|
+
model.steps = nil
|
64
|
+
|
65
|
+
model
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'records a problem' do
|
69
|
+
result = subject.lint(test_model)
|
70
|
+
|
71
|
+
expect(result[:problem]).to eq("Test does not have a 'Then' step.")
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'records the location of the problem' do
|
75
|
+
test_model.source_line = 1
|
76
|
+
result = subject.lint(test_model)
|
77
|
+
expect(result[:location]).to eq('path_to_file:1')
|
78
|
+
|
79
|
+
test_model.source_line = 3
|
80
|
+
result = subject.lint(test_model)
|
81
|
+
expect(result[:location]).to eq('path_to_file:3')
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'because none of its steps is a verification step' do
|
89
|
+
|
90
|
+
let(:test_model) do
|
91
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
92
|
+
model.steps = [CukeModeler::Step.new('* not a verification step')]
|
93
|
+
|
94
|
+
model
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'records a problem' do
|
98
|
+
result = subject.lint(test_model)
|
99
|
+
|
100
|
+
expect(result[:problem]).to eq("Test does not have a 'Then' step.")
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'records the location of the problem' do
|
104
|
+
test_model.source_line = 1
|
105
|
+
result = subject.lint(test_model)
|
106
|
+
expect(result[:location]).to eq('path_to_file:1')
|
107
|
+
|
108
|
+
test_model.source_line = 3
|
109
|
+
result = subject.lint(test_model)
|
110
|
+
expect(result[:location]).to eq('path_to_file:3')
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with a #{model_type} that does have a verification step" do
|
118
|
+
|
119
|
+
context 'that comes from its background' do
|
120
|
+
|
121
|
+
let(:test_model) do
|
122
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
123
|
+
model.steps = []
|
124
|
+
background_model = CukeModeler::Background.new
|
125
|
+
background_model.steps = [CukeModeler::Step.new('Then a verification step')]
|
126
|
+
model.parent_model.background = background_model
|
127
|
+
|
128
|
+
model
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'does not record a problem' do
|
132
|
+
expect(subject.lint(test_model)).to eq(nil)
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'that is part of itself' do
|
138
|
+
|
139
|
+
let(:test_model) do
|
140
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
141
|
+
model.steps = [CukeModeler::Step.new('Then a verification step')]
|
142
|
+
|
143
|
+
model
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'does not record a problem' do
|
147
|
+
expect(subject.lint(test_model)).to eq(nil)
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
['scenario', 'outline'].each do |model_type|
|
157
|
+
|
158
|
+
context "with a #{model_type} that has a related background" do
|
159
|
+
|
160
|
+
let(:test_model) do
|
161
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
162
|
+
model.parent_model.background = background_model
|
163
|
+
|
164
|
+
model
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'that has no background steps' do
|
168
|
+
context 'because its steps are empty' do
|
169
|
+
|
170
|
+
let(:background_model) do
|
171
|
+
model = CukeModeler::Background.new
|
172
|
+
model.steps = []
|
173
|
+
|
174
|
+
model
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'can handle it' do
|
178
|
+
expect { subject.lint(test_model) }.to_not raise_error
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'because its steps are nil' do
|
184
|
+
|
185
|
+
let(:background_model) do
|
186
|
+
model = CukeModeler::Background.new
|
187
|
+
model.steps = nil
|
188
|
+
|
189
|
+
model
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'can handle it' do
|
193
|
+
expect { subject.lint(test_model) }.to_not raise_error
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
context 'a non-test model' do
|
206
|
+
|
207
|
+
let(:test_model) { CukeModeler::Model.new }
|
208
|
+
|
209
|
+
it 'returns no result' do
|
210
|
+
result = subject.lint(test_model)
|
211
|
+
|
212
|
+
expect(result).to eq(nil)
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -78,11 +78,11 @@ RSpec.describe CukeLinter::TestWithTooManyStepsLinter do
|
|
78
78
|
it 'includes the number of steps found in the problem record' do
|
79
79
|
step_count = test_model.steps.count
|
80
80
|
result = subject.lint(test_model)
|
81
|
-
expect(result[:problem]).to eq("Test has too many steps. #{step_count} steps found (max 10)")
|
81
|
+
expect(result[:problem]).to eq("Test has too many steps. #{step_count} steps found (max 10).")
|
82
82
|
|
83
83
|
test_model.steps << :another_step
|
84
84
|
result = subject.lint(test_model)
|
85
|
-
expect(result[:problem]).to eq("Test has too many steps. #{step_count + 1} steps found (max 10)")
|
85
|
+
expect(result[:problem]).to eq("Test has too many steps. #{step_count + 1} steps found (max 10).")
|
86
86
|
end
|
87
87
|
|
88
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_linter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuke_modeler
|
@@ -177,30 +177,40 @@ files:
|
|
177
177
|
- lib/cuke_linter.rb
|
178
178
|
- lib/cuke_linter/formatters/pretty_formatter.rb
|
179
179
|
- lib/cuke_linter/linters/background_does_more_than_setup_linter.rb
|
180
|
+
- lib/cuke_linter/linters/element_with_too_many_tags_linter.rb
|
180
181
|
- lib/cuke_linter/linters/example_without_name_linter.rb
|
181
182
|
- lib/cuke_linter/linters/feature_without_description_linter.rb
|
183
|
+
- lib/cuke_linter/linters/feature_without_name_linter.rb
|
182
184
|
- lib/cuke_linter/linters/feature_without_scenarios_linter.rb
|
183
185
|
- lib/cuke_linter/linters/linter.rb
|
184
186
|
- lib/cuke_linter/linters/outline_with_single_example_row_linter.rb
|
185
187
|
- lib/cuke_linter/linters/single_test_background_linter.rb
|
186
188
|
- lib/cuke_linter/linters/step_with_end_period_linter.rb
|
187
189
|
- lib/cuke_linter/linters/step_with_too_many_characters_linter.rb
|
190
|
+
- lib/cuke_linter/linters/test_with_no_action_step_linter.rb
|
191
|
+
- lib/cuke_linter/linters/test_with_no_name_linter.rb
|
192
|
+
- lib/cuke_linter/linters/test_with_no_verification_step_linter.rb
|
188
193
|
- lib/cuke_linter/linters/test_with_too_many_steps_linter.rb
|
189
194
|
- lib/cuke_linter/version.rb
|
190
195
|
- testing/cucumber/features/command_line.feature
|
191
196
|
- testing/cucumber/features/configuration/configuring_linters.feature
|
192
197
|
- testing/cucumber/features/configuration/using_configurations.feature
|
193
198
|
- testing/cucumber/features/formatters/pretty_formatter.feature
|
194
|
-
- testing/cucumber/features/linters/
|
199
|
+
- testing/cucumber/features/linters/background_does_more_than_setup.feature
|
195
200
|
- testing/cucumber/features/linters/custom_linters.feature
|
196
201
|
- testing/cucumber/features/linters/default_linters.feature
|
202
|
+
- testing/cucumber/features/linters/element_with_too_many_tags.feature
|
197
203
|
- testing/cucumber/features/linters/example_without_name.feature
|
198
204
|
- testing/cucumber/features/linters/feature_without_description.feature
|
205
|
+
- testing/cucumber/features/linters/feature_without_name.feature
|
199
206
|
- testing/cucumber/features/linters/feature_without_scenarios.feature
|
200
207
|
- testing/cucumber/features/linters/outline_with_single_example_row.feature
|
201
|
-
- testing/cucumber/features/linters/
|
208
|
+
- testing/cucumber/features/linters/single_test_background.feature
|
202
209
|
- testing/cucumber/features/linters/step_too_long.feature
|
203
210
|
- testing/cucumber/features/linters/step_with_end_period.feature
|
211
|
+
- testing/cucumber/features/linters/test_with_no_action_step.feature
|
212
|
+
- testing/cucumber/features/linters/test_with_no_name.feature
|
213
|
+
- testing/cucumber/features/linters/test_with_no_verification_step.feature
|
204
214
|
- testing/cucumber/features/linters/test_with_too_many_steps.feature
|
205
215
|
- testing/cucumber/step_definitions/action_steps.rb
|
206
216
|
- testing/cucumber/step_definitions/setup_steps.rb
|
@@ -214,8 +224,10 @@ files:
|
|
214
224
|
- testing/rspec/spec/integration/formatters/formatter_integration_specs.rb
|
215
225
|
- testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb
|
216
226
|
- testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb
|
227
|
+
- testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb
|
217
228
|
- testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb
|
218
229
|
- testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb
|
230
|
+
- testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb
|
219
231
|
- testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb
|
220
232
|
- testing/rspec/spec/integration/linters/linter_integration_spec.rb
|
221
233
|
- testing/rspec/spec/integration/linters/linter_integration_specs.rb
|
@@ -223,14 +235,19 @@ files:
|
|
223
235
|
- testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb
|
224
236
|
- testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb
|
225
237
|
- testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb
|
238
|
+
- testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb
|
239
|
+
- testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb
|
240
|
+
- testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb
|
226
241
|
- testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb
|
227
242
|
- testing/rspec/spec/unit/cuke_linter_unit_spec.rb
|
228
243
|
- testing/rspec/spec/unit/formatters/formatter_unit_specs.rb
|
229
244
|
- testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb
|
230
245
|
- testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb
|
231
246
|
- testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb
|
247
|
+
- testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb
|
232
248
|
- testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb
|
233
249
|
- testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb
|
250
|
+
- testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb
|
234
251
|
- testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb
|
235
252
|
- testing/rspec/spec/unit/linters/linter_unit_spec.rb
|
236
253
|
- testing/rspec/spec/unit/linters/linter_unit_specs.rb
|
@@ -238,6 +255,9 @@ files:
|
|
238
255
|
- testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb
|
239
256
|
- testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb
|
240
257
|
- testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb
|
258
|
+
- testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb
|
259
|
+
- testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb
|
260
|
+
- testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb
|
241
261
|
- testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb
|
242
262
|
homepage: https://github.com/enkessler/cuke_linter
|
243
263
|
licenses:
|