cuke_linter 0.12.1 → 0.13.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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -1
  3. data/lib/cuke_linter.rb +4 -0
  4. data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
  5. data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
  6. data/lib/cuke_linter/linters/test_with_no_action_step_linter.rb +12 -1
  7. data/lib/cuke_linter/linters/test_with_no_verification_step_linter.rb +12 -1
  8. data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +18 -2
  9. data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +18 -2
  10. data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +12 -1
  11. data/lib/cuke_linter/version.rb +1 -1
  12. data/testing/cucumber/features/linters/background_does_more_than_setup.feature +34 -0
  13. data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +25 -3
  14. data/testing/cucumber/features/linters/test_with_no_action_step.feature +27 -1
  15. data/testing/cucumber/features/linters/test_with_no_verification_step.feature +28 -1
  16. data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +28 -1
  17. data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +28 -1
  18. data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +25 -3
  19. data/testing/cucumber/step_definitions/setup_steps.rb +28 -0
  20. data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +12 -0
  21. data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +109 -0
  22. data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +67 -0
  23. data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +68 -0
  24. data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +67 -0
  25. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +109 -0
  26. data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +108 -0
  27. data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +66 -0
  28. metadata +2 -2
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithNoVerificationStepLinter 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
@@ -168,6 +169,72 @@ RSpec.describe CukeLinter::TestWithNoVerificationStepLinter do
168
169
  end
169
170
 
170
171
 
172
+ describe 'configuration' do
173
+
174
+ let(:test_model) do
175
+ CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
176
+ Then a step')
177
+ end
178
+
179
+ context 'with configuration' do
180
+
181
+ before(:each) do
182
+ subject.configure(configuration)
183
+ end
184
+
185
+ context "with a configured 'Then' keyword" do
186
+
187
+ let(:then_keyword) { 'Foo' }
188
+ let(:configuration) { { 'Then' => then_keyword } }
189
+
190
+ it "uses the configured 'Then' keyword" do
191
+ test_model.steps.first.keyword = 'Then'
192
+
193
+ result = subject.lint(test_model)
194
+
195
+ expect(result).to_not be_nil
196
+ end
197
+
198
+ end
199
+
200
+ end
201
+
202
+ context 'without configuration' do
203
+
204
+ context 'because configuration never happened' do
205
+
206
+ it "uses the default 'Then' keyword" do
207
+ test_model.steps.first.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
208
+
209
+ result = subject.lint(test_model)
210
+
211
+ expect(result).to be_nil
212
+ end
213
+
214
+ end
215
+
216
+ context "because configuration did not set a 'Then' keyword" do
217
+
218
+ before(:each) do
219
+ subject.configure(configuration)
220
+ end
221
+
222
+ let(:configuration) { {} }
223
+
224
+ it "uses the default 'Then' keyword" do
225
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
226
+
227
+ result = subject.lint(test_model)
228
+
229
+ expect(result).to be_nil
230
+ end
231
+
232
+ end
233
+
234
+ end
235
+
236
+ end
237
+
171
238
  context 'a non-test model' do
172
239
 
173
240
  let(:test_model) { CukeModeler::Model.new }
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithSetupStepAfterActionStepLinter 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
@@ -112,6 +113,114 @@ RSpec.describe CukeLinter::TestWithSetupStepAfterActionStepLinter do
112
113
 
113
114
  end
114
115
 
116
+ describe 'configuration' do
117
+
118
+ let(:test_model) do
119
+ CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
120
+ When a step
121
+ Given a step')
122
+ end
123
+
124
+ context 'with configuration' do
125
+
126
+ before(:each) do
127
+ subject.configure(configuration)
128
+ end
129
+
130
+ context "with a configured 'Given' keyword" do
131
+
132
+ let(:given_keyword) { 'Foo' }
133
+ let(:configuration) { { 'Given' => given_keyword } }
134
+
135
+ it "uses the configured 'Given' keyword" do
136
+ test_model.steps.last.keyword = given_keyword
137
+
138
+ result = subject.lint(test_model)
139
+
140
+ expect(result).to_not be_nil
141
+ end
142
+
143
+ end
144
+
145
+ context "with a configured 'When' keyword" do
146
+
147
+ let(:when_keyword) { 'Foo' }
148
+ let(:configuration) { { 'When' => when_keyword } }
149
+
150
+ it "uses the configured 'When' keyword" do
151
+ test_model.steps.first.keyword = when_keyword
152
+
153
+ result = subject.lint(test_model)
154
+
155
+ expect(result).to_not be_nil
156
+ end
157
+
158
+ end
159
+
160
+ end
161
+
162
+ context 'without configuration' do
163
+
164
+ context 'because configuration never happened' do
165
+
166
+ it "uses the default 'Given' keyword" do
167
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_KEYWORD
168
+
169
+ result = subject.lint(test_model)
170
+
171
+ expect(result).to_not be_nil
172
+ end
173
+
174
+ it "uses the default 'When' keyword" do
175
+ test_model.steps.first.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
176
+
177
+ result = subject.lint(test_model)
178
+
179
+ expect(result).to_not be_nil
180
+ end
181
+
182
+ end
183
+
184
+ context "because configuration did not set a 'Given' keyword" do
185
+
186
+ before(:each) do
187
+ subject.configure(configuration)
188
+ end
189
+
190
+ let(:configuration) { {} }
191
+
192
+ it "uses the default 'Given' keyword" do
193
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_KEYWORD
194
+
195
+ result = subject.lint(test_model)
196
+
197
+ expect(result).to_not be_nil
198
+ end
199
+
200
+ end
201
+
202
+ context "because configuration did not set a 'When' keyword" do
203
+
204
+ before(:each) do
205
+ subject.configure(configuration)
206
+ end
207
+
208
+ let(:configuration) { {} }
209
+
210
+ it "uses the default 'When' keyword" do
211
+ test_model.steps.first.keyword = CukeLinter::DEFAULT_WHEN_KEYWORD
212
+
213
+ result = subject.lint(test_model)
214
+
215
+ expect(result).to_not be_nil
216
+ end
217
+
218
+ end
219
+
220
+ end
221
+
222
+ end
223
+
115
224
 
116
225
  context 'a non-test model' do
117
226
 
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithSetupStepAfterVerificationStepLinter 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
@@ -113,6 +114,113 @@ RSpec.describe CukeLinter::TestWithSetupStepAfterVerificationStepLinter do
113
114
 
114
115
  end
115
116
 
117
+ describe 'configuration' do
118
+
119
+ let(:test_model) do
120
+ CukeLinter::ModelFactory.generate_scenario_model(source_text: 'Scenario:
121
+ Then a step
122
+ Given a step')
123
+ end
124
+
125
+ context 'with configuration' do
126
+
127
+ before(:each) do
128
+ subject.configure(configuration)
129
+ end
130
+
131
+ context "with a configured 'Given' keyword" do
132
+
133
+ let(:given_keyword) { 'Foo' }
134
+ let(:configuration) { { 'Given' => given_keyword } }
135
+
136
+ it "uses the configured 'Given' keyword" do
137
+ test_model.steps.last.keyword = given_keyword
138
+
139
+ result = subject.lint(test_model)
140
+
141
+ expect(result).to_not be_nil
142
+ end
143
+
144
+ end
145
+
146
+ context "with a configured 'Then' keyword" do
147
+
148
+ let(:then_keyword) { 'Foo' }
149
+ let(:configuration) { { 'Then' => then_keyword } }
150
+
151
+ it "uses the configured 'Then' keyword" do
152
+ test_model.steps.first.keyword = then_keyword
153
+
154
+ result = subject.lint(test_model)
155
+
156
+ expect(result).to_not be_nil
157
+ end
158
+
159
+ end
160
+
161
+ end
162
+
163
+ context 'without configuration' do
164
+
165
+ context 'because configuration never happened' do
166
+
167
+ it "uses the default 'Given' keyword" do
168
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_KEYWORD
169
+
170
+ result = subject.lint(test_model)
171
+
172
+ expect(result).to_not be_nil
173
+ end
174
+
175
+ it "uses the default 'Then' keyword" do
176
+ test_model.steps.first.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
177
+
178
+ result = subject.lint(test_model)
179
+
180
+ expect(result).to_not be_nil
181
+ end
182
+
183
+ end
184
+
185
+ context "because configuration did not set a 'Given' keyword" do
186
+
187
+ before(:each) do
188
+ subject.configure(configuration)
189
+ end
190
+
191
+ let(:configuration) { {} }
192
+
193
+ it "uses the default 'Given' keyword" do
194
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_KEYWORD
195
+
196
+ result = subject.lint(test_model)
197
+
198
+ expect(result).to_not be_nil
199
+ end
200
+
201
+ end
202
+
203
+ context "because configuration did not set a 'Then' keyword" do
204
+
205
+ before(:each) do
206
+ subject.configure(configuration)
207
+ end
208
+
209
+ let(:configuration) { {} }
210
+
211
+ it "uses the default 'Then' keyword" do
212
+ test_model.steps.first.keyword = CukeLinter::DEFAULT_THEN_KEYWORD
213
+
214
+ result = subject.lint(test_model)
215
+
216
+ expect(result).to_not be_nil
217
+ end
218
+
219
+ end
220
+
221
+ end
222
+
223
+ end
116
224
 
117
225
  context 'a non-test model' do
118
226
 
@@ -6,6 +6,7 @@ RSpec.describe CukeLinter::TestWithSetupStepAsFinalStepLinter 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,71 @@ RSpec.describe CukeLinter::TestWithSetupStepAsFinalStepLinter 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 'Given' keyword" do
104
+
105
+ let(:given_keyword) { 'Foo' }
106
+ let(:configuration) { { 'Given' => given_keyword } }
107
+
108
+ it "uses the configured 'Given' keyword" do
109
+ test_model.steps.last.keyword = given_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 'Given' keyword" do
125
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_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 'Given' keyword" do
135
+
136
+ before(:each) do
137
+ subject.configure(configuration)
138
+ end
139
+
140
+ let(:configuration) { {} }
141
+
142
+ it "uses the default 'Given' keyword" do
143
+ test_model.steps.last.keyword = CukeLinter::DEFAULT_GIVEN_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
89
155
 
90
156
  context 'a non-test model' do
91
157
 
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.12.1
4
+ version: 0.13.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: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuke_modeler