cuke_linter 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/lib/cuke_linter.rb +4 -0
- data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
- data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +18 -2
- data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +18 -2
- data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +12 -1
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/linters/background_does_more_than_setup.feature +34 -0
- data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +25 -3
- data/testing/cucumber/features/linters/test_with_no_action_step.feature +27 -1
- data/testing/cucumber/features/linters/test_with_no_verification_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +28 -1
- data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +25 -3
- data/testing/cucumber/step_definitions/setup_steps.rb +28 -0
- data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +12 -0
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +109 -0
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +67 -0
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +68 -0
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +67 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +109 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +108 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +66 -0
- metadata +2 -2
@@ -23,8 +23,35 @@ Feature: Test with setup step after action step linter
|
|
23
23
|
| linter | problem | location |
|
24
24
|
| TestWithSetupStepAfterActionStepLinter | Test has 'Given' step after 'When' step. | <path_to_file>:3 |
|
25
25
|
|
26
|
+
Scenario: Configuration of keywords for different dialect
|
27
|
+
Given a linter for tests with a setup step after an action step has been registered
|
28
|
+
And the following configuration file:
|
29
|
+
"""
|
30
|
+
TestWithSetupStepAfterActionStepLinter:
|
31
|
+
Given:
|
32
|
+
- Dado
|
33
|
+
- Dadas
|
34
|
+
When:
|
35
|
+
- Quando
|
36
|
+
Then:
|
37
|
+
- Então
|
38
|
+
"""
|
39
|
+
And the following feature:
|
40
|
+
"""
|
41
|
+
# language:pt
|
42
|
+
Funcionalidade: Feature name
|
43
|
+
|
44
|
+
Cenário: scenario name
|
45
|
+
Quando this is an action in pt dialect
|
46
|
+
Dado some setup in pt dialect
|
47
|
+
"""
|
48
|
+
When the configuration file is loaded
|
49
|
+
And it is linted
|
50
|
+
Then an error is reported:
|
51
|
+
| linter | problem | location |
|
52
|
+
| TestWithSetupStepAfterActionStepLinter | Test has 'Given' step after 'When' step. | <path_to_file>:4 |
|
53
|
+
|
26
54
|
@wip
|
27
55
|
Scenario: Configuration
|
28
56
|
|
29
|
-
Configure the keyword(s) that count as setup/action/verification steps?
|
30
57
|
Configure whether or not to include background steps?
|
@@ -23,8 +23,35 @@ Feature: Test with setup step after verification step linter
|
|
23
23
|
| linter | problem | location |
|
24
24
|
| TestWithSetupStepAfterVerificationStepLinter | Test has 'Given' step after 'Then' step. | <path_to_file>:3 |
|
25
25
|
|
26
|
+
Scenario: Configuration of keywords for different dialect
|
27
|
+
Given a linter for tests with a setup step after a verification step has been registered
|
28
|
+
And the following configuration file:
|
29
|
+
"""
|
30
|
+
TestWithSetupStepAfterVerificationStepLinter:
|
31
|
+
Given:
|
32
|
+
- Dado
|
33
|
+
- Dadas
|
34
|
+
When:
|
35
|
+
- Quando
|
36
|
+
Then:
|
37
|
+
- Então
|
38
|
+
"""
|
39
|
+
And the following feature:
|
40
|
+
"""
|
41
|
+
# language:pt
|
42
|
+
Funcionalidade: Feature name
|
43
|
+
|
44
|
+
Cenário: scenario name
|
45
|
+
Então this is an validation in pt dialect
|
46
|
+
Dado some setup in pt dialect
|
47
|
+
"""
|
48
|
+
When the configuration file is loaded
|
49
|
+
And it is linted
|
50
|
+
Then an error is reported:
|
51
|
+
| linter | problem | location |
|
52
|
+
| TestWithSetupStepAfterVerificationStepLinter | Test has 'Given' step after 'Then' step. | <path_to_file>:4 |
|
53
|
+
|
26
54
|
@wip
|
27
55
|
Scenario: Configuration
|
28
56
|
|
29
|
-
Configure the keyword(s) that count as verification steps?
|
30
57
|
Configure whether or not to include background steps?
|
@@ -22,7 +22,29 @@ Feature: Test with setup step as final step linter
|
|
22
22
|
| linter | problem | location |
|
23
23
|
| TestWithSetupStepAsFinalStepLinter | Test has 'Given' as the final step. | <path_to_file>:3 |
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
Scenario: Configuration of keywords for different dialect
|
26
|
+
Given a linter for tests with a setup step as the final step has been registered
|
27
|
+
And the following configuration file:
|
28
|
+
"""
|
29
|
+
TestWithSetupStepAsFinalStepLinter:
|
30
|
+
Given:
|
31
|
+
- Dado
|
32
|
+
- Dadas
|
33
|
+
When:
|
34
|
+
- Quando
|
35
|
+
Then:
|
36
|
+
- Então
|
37
|
+
"""
|
38
|
+
And the following feature:
|
39
|
+
"""
|
40
|
+
# language:pt
|
41
|
+
Funcionalidade: Feature name
|
27
42
|
|
28
|
-
|
43
|
+
Cenário: scenario name
|
44
|
+
Dado some setup in pt dialect
|
45
|
+
"""
|
46
|
+
When the configuration file is loaded
|
47
|
+
And it is linted
|
48
|
+
Then an error is reported:
|
49
|
+
| linter | problem | location |
|
50
|
+
| TestWithSetupStepAsFinalStepLinter | Test has 'Given' as the final step. | <path_to_file>:4 |
|
@@ -101,6 +101,34 @@ Given(/^a linter for tests with too many steps has been registered$/) do
|
|
101
101
|
CukeLinter.register_linter(linter: CukeLinter::TestWithTooManyStepsLinter.new, name: 'TestWithTooManyStepsLinter')
|
102
102
|
end
|
103
103
|
|
104
|
+
Given(/^a linter for backgrounds that do more than setup has been registered$/) do
|
105
|
+
CukeLinter.register_linter(linter: CukeLinter::BackgroundDoesMoreThanSetupLinter.new, name: 'BackgroundDoesMoreThanSetupLinter')
|
106
|
+
end
|
107
|
+
|
108
|
+
Given(/^a linter for tests with an action step as the final step has been registered$/) do
|
109
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithActionStepAsFinalStepLinter.new, name: 'TestWithActionStepAsFinalStepLinter')
|
110
|
+
end
|
111
|
+
|
112
|
+
Given(/^a linter for tests with no action step has been registered$/) do
|
113
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithNoActionStepLinter.new, name: 'TestWithNoActionStepLinter')
|
114
|
+
end
|
115
|
+
|
116
|
+
Given(/^a linter for tests with no verification step has been registered$/) do
|
117
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithNoVerificationStepLinter.new, name: 'TestWithNoVerificationStepLinter')
|
118
|
+
end
|
119
|
+
|
120
|
+
Given(/^a linter for tests with a setup step after an action step has been registered$/) do
|
121
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAfterActionStepLinter.new, name: 'TestWithSetupStepAfterActionStepLinter')
|
122
|
+
end
|
123
|
+
|
124
|
+
Given(/^a linter for tests with a setup step after a verification step has been registered$/) do
|
125
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAfterVerificationStepLinter.new, name: 'TestWithSetupStepAfterVerificationStepLinter')
|
126
|
+
end
|
127
|
+
|
128
|
+
Given(/^a linter for tests with a setup step as the final step has been registered$/) do
|
129
|
+
CukeLinter.register_linter(linter: CukeLinter::TestWithSetupStepAsFinalStepLinter.new, name: 'TestWithSetupStepAsFinalStepLinter')
|
130
|
+
end
|
131
|
+
|
104
132
|
Given("a linter for features without a description") do
|
105
133
|
@linter = CukeLinter::FeatureWithoutDescriptionLinter.new
|
106
134
|
end
|
@@ -25,6 +25,18 @@ RSpec.describe CukeLinter do
|
|
25
25
|
expect(CukeLinter::VERSION).not_to be nil
|
26
26
|
end
|
27
27
|
|
28
|
+
it "has a default keyword for 'Given'" do
|
29
|
+
expect(CukeLinter::DEFAULT_GIVEN_KEYWORD).to eq('Given')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has a default keyword for 'When'" do
|
33
|
+
expect(CukeLinter::DEFAULT_WHEN_KEYWORD).to eq('When')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "has a default keyword for 'Then'" do
|
37
|
+
expect(CukeLinter::DEFAULT_THEN_KEYWORD).to eq('Then')
|
38
|
+
end
|
39
|
+
|
28
40
|
it 'can lint' do
|
29
41
|
expect(CukeLinter).to respond_to(:lint)
|
30
42
|
end
|
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::BackgroundDoesMoreThanSetupLinter do
|
|
6
6
|
let(:model_file_path) { 'some_file_path' }
|
7
7
|
|
8
8
|
it_should_behave_like 'a linter at the unit level'
|
9
|
+
it_should_behave_like 'a configurable linter at the unit level'
|
9
10
|
|
10
11
|
|
11
12
|
it 'has a name' do
|
@@ -66,6 +67,114 @@ RSpec.describe CukeLinter::BackgroundDoesMoreThanSetupLinter do
|
|
66
67
|
|
67
68
|
end
|
68
69
|
|
70
|
+
|
71
|
+
describe 'configuration' do
|
72
|
+
|
73
|
+
let(:test_model) do
|
74
|
+
CukeLinter::ModelFactory.generate_background_model
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with configuration' do
|
78
|
+
|
79
|
+
before(:each) do
|
80
|
+
subject.configure(configuration)
|
81
|
+
end
|
82
|
+
|
83
|
+
context "with a configured 'When' keyword" do
|
84
|
+
|
85
|
+
let(:when_keyword) { 'Foo' }
|
86
|
+
let(:configuration) { { 'When' => when_keyword } }
|
87
|
+
|
88
|
+
it "uses the configured 'When' keyword" do
|
89
|
+
test_model.steps.first.keyword = when_keyword
|
90
|
+
|
91
|
+
result = subject.lint(test_model)
|
92
|
+
|
93
|
+
expect(result).to_not be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
context "with a configured 'Then' keyword" do
|
99
|
+
|
100
|
+
let(:then_keyword) { 'Foo' }
|
101
|
+
let(:configuration) { { 'Then' => then_keyword } }
|
102
|
+
|
103
|
+
it "uses the configured 'Then' keyword" do
|
104
|
+
test_model.steps.first.keyword = then_keyword
|
105
|
+
|
106
|
+
result = subject.lint(test_model)
|
107
|
+
|
108
|
+
expect(result).to_not be_nil
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'without configuration' do
|
116
|
+
|
117
|
+
context 'because configuration never happened' do
|
118
|
+
|
119
|
+
it "uses the default 'When' keyword" do
|
120
|
+
test_model.steps.first.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
121
|
+
|
122
|
+
result = subject.lint(test_model)
|
123
|
+
|
124
|
+
expect(result).to_not be_nil
|
125
|
+
end
|
126
|
+
|
127
|
+
it "uses the default 'Then' keyword" do
|
128
|
+
test_model.steps.first.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
|
129
|
+
|
130
|
+
result = subject.lint(test_model)
|
131
|
+
|
132
|
+
expect(result).to_not be_nil
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
context "because configuration did not set a 'When' keyword" do
|
138
|
+
|
139
|
+
before(:each) do
|
140
|
+
subject.configure(configuration)
|
141
|
+
end
|
142
|
+
|
143
|
+
let(:configuration) { {} }
|
144
|
+
|
145
|
+
it "uses the default 'When' keyword" do
|
146
|
+
test_model.steps.first.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
147
|
+
|
148
|
+
result = subject.lint(test_model)
|
149
|
+
|
150
|
+
expect(result).to_not be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
context "because configuration did not set a 'Then' keyword" do
|
156
|
+
|
157
|
+
before(:each) do
|
158
|
+
subject.configure(configuration)
|
159
|
+
end
|
160
|
+
|
161
|
+
let(:configuration) { {} }
|
162
|
+
|
163
|
+
it "uses the default 'Then' keyword" do
|
164
|
+
test_model.steps.first.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
|
165
|
+
|
166
|
+
result = subject.lint(test_model)
|
167
|
+
|
168
|
+
expect(result).to_not be_nil
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
|
69
178
|
context 'a non-background model' do
|
70
179
|
|
71
180
|
let(:test_model) { CukeModeler::Model.new }
|
data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb
CHANGED
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithActionStepAsFinalStepLinter do
|
|
6
6
|
let(:model_file_path) { 'some_file_path' }
|
7
7
|
|
8
8
|
it_should_behave_like 'a linter at the unit level'
|
9
|
+
it_should_behave_like 'a configurable linter at the unit level'
|
9
10
|
|
10
11
|
|
11
12
|
it 'has a name' do
|
@@ -86,6 +87,72 @@ RSpec.describe CukeLinter::TestWithActionStepAsFinalStepLinter do
|
|
86
87
|
|
87
88
|
end
|
88
89
|
|
90
|
+
describe 'configuration' do
|
91
|
+
|
92
|
+
let(:test_model) do
|
93
|
+
CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
|
94
|
+
* a step')
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'with configuration' do
|
98
|
+
|
99
|
+
before(:each) do
|
100
|
+
subject.configure(configuration)
|
101
|
+
end
|
102
|
+
|
103
|
+
context "with a configured 'When' keyword" do
|
104
|
+
|
105
|
+
let(:when_keyword) { 'Foo' }
|
106
|
+
let(:configuration) { { 'When' => when_keyword } }
|
107
|
+
|
108
|
+
it "uses the configured 'When' keyword" do
|
109
|
+
test_model.steps.last.keyword = when_keyword
|
110
|
+
|
111
|
+
result = subject.lint(test_model)
|
112
|
+
|
113
|
+
expect(result).to_not be_nil
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'without configuration' do
|
121
|
+
|
122
|
+
context 'because configuration never happened' do
|
123
|
+
|
124
|
+
it "uses the default 'When' keyword" do
|
125
|
+
test_model.steps.last.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
126
|
+
|
127
|
+
result = subject.lint(test_model)
|
128
|
+
|
129
|
+
expect(result).to_not be_nil
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
context "because configuration did not set a 'When' keyword" do
|
135
|
+
|
136
|
+
before(:each) do
|
137
|
+
subject.configure(configuration)
|
138
|
+
end
|
139
|
+
|
140
|
+
let(:configuration) { {} }
|
141
|
+
|
142
|
+
it "uses the default 'When' keyword" do
|
143
|
+
test_model.steps.last.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
144
|
+
|
145
|
+
result = subject.lint(test_model)
|
146
|
+
|
147
|
+
expect(result).to_not be_nil
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
|
89
156
|
|
90
157
|
context 'a non-test model' do
|
91
158
|
|
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithNoActionStepLinter do
|
|
6
6
|
let(:model_file_path) { 'some_file_path' }
|
7
7
|
|
8
8
|
it_should_behave_like 'a linter at the unit level'
|
9
|
+
it_should_behave_like 'a configurable linter at the unit level'
|
9
10
|
|
10
11
|
|
11
12
|
it 'has a name' do
|
@@ -165,6 +166,73 @@ RSpec.describe CukeLinter::TestWithNoActionStepLinter do
|
|
165
166
|
end
|
166
167
|
|
167
168
|
|
169
|
+
describe 'configuration' do
|
170
|
+
|
171
|
+
let(:test_model) do
|
172
|
+
CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
|
173
|
+
When a step')
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'with configuration' do
|
177
|
+
|
178
|
+
before(:each) do
|
179
|
+
subject.configure(configuration)
|
180
|
+
end
|
181
|
+
|
182
|
+
context "with a configured 'When' keyword" do
|
183
|
+
|
184
|
+
let(:when_keyword) { 'Foo' }
|
185
|
+
let(:configuration) { { 'When' => when_keyword } }
|
186
|
+
|
187
|
+
it "uses the configured 'When' keyword" do
|
188
|
+
test_model.steps.first.keyword = 'When'
|
189
|
+
|
190
|
+
result = subject.lint(test_model)
|
191
|
+
|
192
|
+
expect(result).to_not be_nil
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
context 'without configuration' do
|
200
|
+
|
201
|
+
context 'because configuration never happened' do
|
202
|
+
|
203
|
+
it "uses the default 'When' keyword" do
|
204
|
+
test_model.steps.first.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
205
|
+
|
206
|
+
result = subject.lint(test_model)
|
207
|
+
|
208
|
+
expect(result).to be_nil
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
context "because configuration did not set a 'When' keyword" do
|
214
|
+
|
215
|
+
before(:each) do
|
216
|
+
subject.configure(configuration)
|
217
|
+
end
|
218
|
+
|
219
|
+
let(:configuration) { {} }
|
220
|
+
|
221
|
+
it "uses the default 'When' keyword" do
|
222
|
+
test_model.steps.last.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
|
223
|
+
|
224
|
+
result = subject.lint(test_model)
|
225
|
+
|
226
|
+
expect(result).to be_nil
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
168
236
|
context 'a non-test model' do
|
169
237
|
|
170
238
|
let(:test_model) { CukeModeler::Model.new }
|