cuke_linter 0.1.0 → 0.2.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/.simplecov +8 -0
- data/.travis.yml +16 -14
- data/CHANGELOG.md +11 -2
- data/Gemfile +6 -6
- data/README.md +160 -148
- data/Rakefile +48 -23
- data/cuke_linter.gemspec +3 -0
- data/environments/cucumber_env.rb +10 -0
- data/environments/rspec_env.rb +3 -0
- data/lib/cuke_linter/formatters/pretty_formatter.rb +4 -0
- data/lib/cuke_linter/linters/example_without_name_linter.rb +24 -0
- data/lib/cuke_linter/linters/feature_without_scenarios_linter.rb +6 -4
- data/lib/cuke_linter/linters/outline_with_single_example_row_linter.rb +27 -0
- data/lib/cuke_linter/linters/test_with_too_many_steps_linter.rb +26 -0
- data/lib/cuke_linter/version.rb +4 -3
- data/lib/cuke_linter.rb +14 -1
- data/testing/cucumber/features/linters/default_linters.feature +8 -1
- data/testing/cucumber/features/linters/example_without_name.feature +27 -0
- data/testing/cucumber/features/linters/feature_without_scenarios.feature +7 -2
- data/testing/cucumber/features/linters/outline_with_single_example_row.feature +23 -0
- data/testing/cucumber/features/linters/test_with_too_many_steps.feature +33 -0
- data/testing/cucumber/step_definitions/action_steps.rb +5 -1
- data/testing/cucumber/step_definitions/setup_steps.rb +12 -0
- data/testing/cucumber/step_definitions/verification_steps.rb +3 -2
- data/testing/model_factory.rb +36 -0
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +6 -0
- data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +5 -1
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +83 -0
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +52 -2
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +231 -0
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +156 -0
- metadata +57 -2
@@ -0,0 +1,231 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::OutlineWithSingleExampleRowLinter do
|
5
|
+
|
6
|
+
let(:good_data) do
|
7
|
+
outline_text = 'Scenario Outline:
|
8
|
+
* a step
|
9
|
+
Examples:
|
10
|
+
| param |
|
11
|
+
| value 1 |
|
12
|
+
| value 2 |'
|
13
|
+
|
14
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: outline_text)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:bad_data) do
|
18
|
+
outline_text = 'Scenario Outline:
|
19
|
+
* a step
|
20
|
+
Examples:
|
21
|
+
| param |
|
22
|
+
| value 1 |'
|
23
|
+
|
24
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: outline_text)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
it_should_behave_like 'a linter at the unit level'
|
29
|
+
|
30
|
+
|
31
|
+
it 'has a name' do
|
32
|
+
expect(subject.name).to eq('OutlineWithSingleExampleRowLinter')
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'linting' do
|
36
|
+
|
37
|
+
context 'an outline with only one example row' do
|
38
|
+
|
39
|
+
context 'with only one example set' do
|
40
|
+
|
41
|
+
let(:test_model) do
|
42
|
+
gherkin = 'Scenario Outline:
|
43
|
+
* a step
|
44
|
+
Examples:
|
45
|
+
| param |
|
46
|
+
| value |'
|
47
|
+
|
48
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'records a problem' do
|
52
|
+
results = subject.lint(test_model)
|
53
|
+
|
54
|
+
expect(results.first[:problem]).to eq('Outline has only one example row')
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'with multiple example sets' do
|
60
|
+
|
61
|
+
let(:test_model) do
|
62
|
+
gherkin = 'Scenario Outline:
|
63
|
+
* a step
|
64
|
+
Examples:
|
65
|
+
| param |
|
66
|
+
Examples:
|
67
|
+
| param |
|
68
|
+
| value |'
|
69
|
+
|
70
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'records a problem' do
|
74
|
+
results = subject.lint(test_model)
|
75
|
+
|
76
|
+
expect(results.first[:problem]).to eq('Outline has only one example row')
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
it 'records the location of the problem' do
|
83
|
+
gherkin = 'Scenario Outline:
|
84
|
+
* a step
|
85
|
+
Examples:
|
86
|
+
| param |
|
87
|
+
| value |'
|
88
|
+
|
89
|
+
model_1 = CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin, parent_file_path: 'path_to_file')
|
90
|
+
model_2 = CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin, parent_file_path: 'path_to_file')
|
91
|
+
|
92
|
+
model_1.source_line = 1
|
93
|
+
model_2.source_line = 3
|
94
|
+
|
95
|
+
results = subject.lint(model_1)
|
96
|
+
expect(results.first[:location]).to eq('path_to_file:1')
|
97
|
+
|
98
|
+
results = subject.lint(model_2)
|
99
|
+
expect(results.first[:location]).to eq('path_to_file:3')
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'an outline with more than one example row' do
|
105
|
+
|
106
|
+
context 'with only one example set' do
|
107
|
+
|
108
|
+
let(:test_model) do
|
109
|
+
gherkin = 'Scenario Outline:
|
110
|
+
* a step
|
111
|
+
Examples:
|
112
|
+
| param |
|
113
|
+
| value 1 |
|
114
|
+
| value 2 |'
|
115
|
+
|
116
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'does not record a problem' do
|
120
|
+
expect(subject.lint(test_model)).to eq([])
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with multiple example sets' do
|
126
|
+
|
127
|
+
let(:test_model) do
|
128
|
+
gherkin = 'Scenario Outline:
|
129
|
+
* a step
|
130
|
+
Examples:
|
131
|
+
| param |
|
132
|
+
| value 1 |
|
133
|
+
Examples:
|
134
|
+
| param |
|
135
|
+
| value 1 |'
|
136
|
+
|
137
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'does not record a problem' do
|
141
|
+
expect(subject.lint(test_model)).to eq([])
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'an outline with no example rows' do
|
149
|
+
|
150
|
+
context 'because it has no example sets' do
|
151
|
+
|
152
|
+
context 'because its examples are nil' do
|
153
|
+
|
154
|
+
let(:test_model) do
|
155
|
+
model = CukeLinter::ModelFactory.generate_outline_model
|
156
|
+
model.examples = nil
|
157
|
+
|
158
|
+
model
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'does not record a problem' do
|
162
|
+
expect(subject.lint(test_model)).to eq([])
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
context 'because its examples are empty' do
|
168
|
+
let(:test_model) do
|
169
|
+
model = CukeLinter::ModelFactory.generate_outline_model
|
170
|
+
model.examples = []
|
171
|
+
|
172
|
+
model
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'does not record a problem' do
|
176
|
+
expect(subject.lint(test_model)).to eq([])
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'with only one example set' do
|
184
|
+
|
185
|
+
let(:test_model) do
|
186
|
+
gherkin = 'Scenario Outline:
|
187
|
+
* a step
|
188
|
+
Examples:
|
189
|
+
| param |'
|
190
|
+
|
191
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'does not record a problem' do
|
195
|
+
expect(subject.lint(test_model)).to eq([])
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'with multiple example sets' do
|
201
|
+
|
202
|
+
let(:test_model) do
|
203
|
+
gherkin = 'Scenario Outline:
|
204
|
+
* a step
|
205
|
+
Examples:
|
206
|
+
| param |
|
207
|
+
Examples:
|
208
|
+
| param |'
|
209
|
+
|
210
|
+
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'does not record a problem' do
|
214
|
+
expect(subject.lint(test_model)).to eq([])
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
context 'a non-outline model' do
|
222
|
+
|
223
|
+
it 'returns an empty set of results' do
|
224
|
+
results = subject.lint(CukeModeler::Model.new)
|
225
|
+
|
226
|
+
expect(results).to eq([])
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require_relative '../../../../../environments/rspec_env'
|
2
|
+
|
3
|
+
|
4
|
+
RSpec.describe CukeLinter::TestWithTooManyStepsLinter do
|
5
|
+
|
6
|
+
let(:good_data) do
|
7
|
+
model = CukeLinter::ModelFactory.generate_scenario_model
|
8
|
+
model.steps = [:step_1]
|
9
|
+
|
10
|
+
model
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:bad_data) do
|
14
|
+
model = CukeLinter::ModelFactory.generate_scenario_model
|
15
|
+
model.steps = [:step_1,
|
16
|
+
:step_2,
|
17
|
+
:step_3,
|
18
|
+
:step_4,
|
19
|
+
:step_5,
|
20
|
+
:step_6,
|
21
|
+
:step_7,
|
22
|
+
:step_8,
|
23
|
+
:step_9,
|
24
|
+
:step_10,
|
25
|
+
:step_11]
|
26
|
+
|
27
|
+
model
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
it_should_behave_like 'a linter at the unit level'
|
32
|
+
|
33
|
+
|
34
|
+
it 'has a name' do
|
35
|
+
expect(subject.name).to eq('TestWithTooManyStepsLinter')
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'linting' do
|
39
|
+
|
40
|
+
['scenario', 'outline'].each do |model_type|
|
41
|
+
|
42
|
+
context "with a #{model_type} that has too many steps" do
|
43
|
+
|
44
|
+
let(:test_model) do
|
45
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
46
|
+
model.steps = [:step_1,
|
47
|
+
:step_2,
|
48
|
+
:step_3,
|
49
|
+
:step_4,
|
50
|
+
:step_5,
|
51
|
+
:step_6,
|
52
|
+
:step_7,
|
53
|
+
:step_8,
|
54
|
+
:step_9,
|
55
|
+
:step_10,
|
56
|
+
:step_11]
|
57
|
+
|
58
|
+
model
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'records a problem' do
|
62
|
+
results = subject.lint(test_model)
|
63
|
+
|
64
|
+
expect(results.first[:problem]).to match(/^Test has too many steps. \d+ steps found \(max 10\)/)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'records the location of the problem' do
|
68
|
+
test_model.source_line = 1
|
69
|
+
results = subject.lint(test_model)
|
70
|
+
expect(results.first[:location]).to eq('path_to_file:1')
|
71
|
+
|
72
|
+
test_model.source_line = 3
|
73
|
+
results = subject.lint(test_model)
|
74
|
+
expect(results.first[:location]).to eq('path_to_file:3')
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'includes the number of steps found in the problem record' do
|
78
|
+
step_count = test_model.steps.count
|
79
|
+
results = subject.lint(test_model)
|
80
|
+
expect(results.first[:problem]).to eq("Test has too many steps. #{step_count} steps found (max 10)")
|
81
|
+
|
82
|
+
test_model.steps << :another_step
|
83
|
+
results = subject.lint(test_model)
|
84
|
+
expect(results.first[:problem]).to eq("Test has too many steps. #{step_count + 1} steps found (max 10)")
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with a #{model_type} that does not have too many steps" do
|
90
|
+
|
91
|
+
context 'because it has fewer than 10 steps' do
|
92
|
+
|
93
|
+
let(:test_model) do
|
94
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
95
|
+
model.steps = [:step_1]
|
96
|
+
|
97
|
+
model
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'does not record a problem' do
|
101
|
+
expect(subject.lint(test_model)).to eq([])
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'because it has no steps' do
|
107
|
+
|
108
|
+
context 'because its steps are empty' do
|
109
|
+
|
110
|
+
let(:test_model) do
|
111
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
112
|
+
model.steps = []
|
113
|
+
|
114
|
+
model
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'does not record a problem' do
|
118
|
+
expect(subject.lint(test_model)).to eq([])
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'because its steps are nil' do
|
124
|
+
|
125
|
+
let(:test_model) do
|
126
|
+
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
127
|
+
model.steps = nil
|
128
|
+
|
129
|
+
model
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'does not record a problem' do
|
133
|
+
expect(subject.lint(test_model)).to eq([])
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'a non-test model' do
|
145
|
+
|
146
|
+
let(:test_model) { CukeModeler::Model.new }
|
147
|
+
|
148
|
+
it 'returns an empty set of results' do
|
149
|
+
results = subject.lint(test_model)
|
150
|
+
|
151
|
+
expect(results).to eq([])
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
156
|
+
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.2.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-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cuke_modeler
|
@@ -108,6 +108,48 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "<"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.0.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "<"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.0.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: coveralls
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "<"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "<"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.0.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: colorize
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "<"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.0.0
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.0.0
|
111
153
|
description:
|
112
154
|
email:
|
113
155
|
- morrow748@gmail.com
|
@@ -117,6 +159,7 @@ extensions: []
|
|
117
159
|
extra_rdoc_files: []
|
118
160
|
files:
|
119
161
|
- ".gitignore"
|
162
|
+
- ".simplecov"
|
120
163
|
- ".travis.yml"
|
121
164
|
- CHANGELOG.md
|
122
165
|
- Gemfile
|
@@ -133,12 +176,18 @@ files:
|
|
133
176
|
- exe/cuke_linter
|
134
177
|
- lib/cuke_linter.rb
|
135
178
|
- lib/cuke_linter/formatters/pretty_formatter.rb
|
179
|
+
- lib/cuke_linter/linters/example_without_name_linter.rb
|
136
180
|
- lib/cuke_linter/linters/feature_without_scenarios_linter.rb
|
181
|
+
- lib/cuke_linter/linters/outline_with_single_example_row_linter.rb
|
182
|
+
- lib/cuke_linter/linters/test_with_too_many_steps_linter.rb
|
137
183
|
- lib/cuke_linter/version.rb
|
138
184
|
- testing/cucumber/features/command_line.feature
|
139
185
|
- testing/cucumber/features/formatters/pretty_formatter.feature
|
140
186
|
- testing/cucumber/features/linters/default_linters.feature
|
187
|
+
- testing/cucumber/features/linters/example_without_name.feature
|
141
188
|
- testing/cucumber/features/linters/feature_without_scenarios.feature
|
189
|
+
- testing/cucumber/features/linters/outline_with_single_example_row.feature
|
190
|
+
- testing/cucumber/features/linters/test_with_too_many_steps.feature
|
142
191
|
- testing/cucumber/step_definitions/action_steps.rb
|
143
192
|
- testing/cucumber/step_definitions/setup_steps.rb
|
144
193
|
- testing/cucumber/step_definitions/verification_steps.rb
|
@@ -149,13 +198,19 @@ files:
|
|
149
198
|
- testing/rspec/spec/integration/cuke_linter_integration_spec.rb
|
150
199
|
- testing/rspec/spec/integration/formatters/formatter_integration_specs.rb
|
151
200
|
- testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb
|
201
|
+
- testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb
|
152
202
|
- testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb
|
153
203
|
- testing/rspec/spec/integration/linters/linter_integration_specs.rb
|
204
|
+
- testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb
|
205
|
+
- testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb
|
154
206
|
- testing/rspec/spec/unit/cuke_linter_unit_spec.rb
|
155
207
|
- testing/rspec/spec/unit/formatters/formatter_unit_specs.rb
|
156
208
|
- testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb
|
209
|
+
- testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb
|
157
210
|
- testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb
|
158
211
|
- testing/rspec/spec/unit/linters/linter_unit_specs.rb
|
212
|
+
- testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb
|
213
|
+
- testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb
|
159
214
|
homepage: https://github.com/enkessler/cuke_linter
|
160
215
|
licenses:
|
161
216
|
- MIT
|