cuke_linter 0.13.0 → 1.0.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 +9 -1
- data/README.md +4 -4
- data/cuke_linter.gemspec +3 -3
- data/lib/cuke_linter.rb +5 -3
- data/lib/cuke_linter/version.rb +1 -1
- metadata +2 -86
- data/.gitignore +0 -19
- data/.simplecov +0 -8
- data/.travis.yml +0 -33
- data/CONTRIBUTING.md +0 -26
- data/Gemfile +0 -6
- data/Rakefile +0 -63
- data/appveyor.yml +0 -43
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/environments/common_env.rb +0 -12
- data/environments/cucumber_env.rb +0 -22
- data/environments/rspec_env.rb +0 -50
- data/testing/cucumber/step_definitions/action_steps.rb +0 -84
- data/testing/cucumber/step_definitions/setup_steps.rb +0 -258
- data/testing/cucumber/step_definitions/verification_steps.rb +0 -94
- data/testing/file_helper.rb +0 -41
- data/testing/formatter_factory.rb +0 -15
- data/testing/gemfiles/cuke_modeler1.gemfile +0 -8
- data/testing/gemfiles/cuke_modeler2.gemfile +0 -8
- data/testing/linter_factory.rb +0 -60
- data/testing/model_factory.rb +0 -109
- data/testing/rspec/spec/integration/cli_integration_spec.rb +0 -556
- data/testing/rspec/spec/integration/configuration_spec.rb +0 -811
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +0 -243
- data/testing/rspec/spec/integration/formatters/formatter_integration_specs.rb +0 -5
- data/testing/rspec/spec/integration/formatters/pretty_formatter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/background_does_more_than_setup_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_common_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_duplicate_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/element_with_too_many_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/example_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_invalid_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_file_with_mismatched_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_description_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_name_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/feature_without_scenarios_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/linter_integration_specs.rb +0 -7
- data/testing/rspec/spec/integration/linters/outline_with_single_example_row_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/single_test_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_end_period_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/step_with_too_many_characters_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_bad_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_action_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_name_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_no_verification_step_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/integration/linters/test_with_too_many_steps_linter_integration_spec.rb +0 -8
- data/testing/rspec/spec/unit/cuke_linter_unit_spec.rb +0 -114
- data/testing/rspec/spec/unit/formatters/formatter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/formatters/pretty_formatter_unit_spec.rb +0 -115
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +0 -186
- data/testing/rspec/spec/unit/linters/configurable_linter_unit_specs.rb +0 -11
- data/testing/rspec/spec/unit/linters/element_with_common_tags_linter_unit_spec.rb +0 -248
- data/testing/rspec/spec/unit/linters/element_with_duplicate_tags_linter_unit_spec.rb +0 -203
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +0 -296
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/feature_file_with_invalid_name_linter_unit_spec.rb +0 -106
- data/testing/rspec/spec/unit/linters/feature_file_with_mismatched_name_linter_unit_spec.rb +0 -124
- data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +0 -293
- data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +0 -80
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +0 -84
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +0 -102
- data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +0 -197
- data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +0 -57
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +0 -184
- data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +0 -89
- data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +0 -54
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +0 -155
- data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +0 -464
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -165
- data/testing/rspec/spec/unit/linters/test_with_bad_name_linter_unit_spec.rb +0 -81
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +0 -244
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +0 -88
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +0 -246
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -233
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -233
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -164
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,233 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::TestWithSetupStepAfterVerificationStepLinter do
|
5
|
-
|
6
|
-
let(:model_file_path) { 'some_file_path' }
|
7
|
-
|
8
|
-
it_should_behave_like 'a linter at the unit level'
|
9
|
-
it_should_behave_like 'a configurable linter at the unit level'
|
10
|
-
|
11
|
-
|
12
|
-
it 'has a name' do
|
13
|
-
expect(subject.name).to eq('TestWithSetupStepAfterVerificationStepLinter')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'linting' do
|
17
|
-
|
18
|
-
['scenario', 'outline'].each do |model_type|
|
19
|
-
|
20
|
-
context "with a #{model_type} that has a setup step after a verification step" do
|
21
|
-
|
22
|
-
let(:test_model) do
|
23
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model",
|
24
|
-
parent_file_path: model_file_path)
|
25
|
-
model.steps = [CukeModeler::Step.new('Then a step'),
|
26
|
-
CukeModeler::Step.new('Given a step')]
|
27
|
-
|
28
|
-
model
|
29
|
-
end
|
30
|
-
|
31
|
-
it_should_behave_like 'a linter linting a bad model'
|
32
|
-
|
33
|
-
|
34
|
-
it 'records a problem' do
|
35
|
-
result = subject.lint(test_model)
|
36
|
-
|
37
|
-
expect(result[:problem]).to eq("Test has 'Given' step after 'Then' step.")
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with a #{model_type} that does not have a setup step after a verification step" do
|
43
|
-
|
44
|
-
context 'because it has no steps' do
|
45
|
-
|
46
|
-
context 'because its steps are empty' do
|
47
|
-
|
48
|
-
let(:test_model) do
|
49
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
50
|
-
model.steps = []
|
51
|
-
|
52
|
-
model
|
53
|
-
end
|
54
|
-
|
55
|
-
it_should_behave_like 'a linter linting a good model'
|
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")
|
63
|
-
model.steps = nil
|
64
|
-
|
65
|
-
model
|
66
|
-
end
|
67
|
-
|
68
|
-
it_should_behave_like 'a linter linting a good model'
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'because its setup steps come before its verification steps' do
|
75
|
-
|
76
|
-
let(:test_model) do
|
77
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
78
|
-
model.steps = [CukeModeler::Step.new('Given a step'),
|
79
|
-
CukeModeler::Step.new('Then a step'),]
|
80
|
-
|
81
|
-
model
|
82
|
-
end
|
83
|
-
|
84
|
-
it_should_behave_like 'a linter linting a good model'
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
context "with a #{model_type} that has an associated background" do
|
91
|
-
|
92
|
-
let(:test_model) do
|
93
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
|
94
|
-
Background:
|
95
|
-
Given a step
|
96
|
-
Then a step
|
97
|
-
Given a step
|
98
|
-
Then a step')
|
99
|
-
|
100
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
101
|
-
model.steps = [CukeModeler::Step.new('Given a step')]
|
102
|
-
|
103
|
-
model.parent_model = feature_model
|
104
|
-
feature_model.tests << model
|
105
|
-
|
106
|
-
model
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'does not consider those steps when linting' do
|
110
|
-
expect(subject.lint(test_model)).to eq(nil)
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
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
|
224
|
-
|
225
|
-
context 'a non-test model' do
|
226
|
-
|
227
|
-
let(:test_model) { CukeModeler::Model.new }
|
228
|
-
|
229
|
-
it_should_behave_like 'a linter linting a good model'
|
230
|
-
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
@@ -1,164 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::TestWithSetupStepAsFinalStepLinter do
|
5
|
-
|
6
|
-
let(:model_file_path) { 'some_file_path' }
|
7
|
-
|
8
|
-
it_should_behave_like 'a linter at the unit level'
|
9
|
-
it_should_behave_like 'a configurable linter at the unit level'
|
10
|
-
|
11
|
-
|
12
|
-
it 'has a name' do
|
13
|
-
expect(subject.name).to eq('TestWithSetupStepAsFinalStepLinter')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'linting' do
|
17
|
-
|
18
|
-
['scenario', 'outline'].each do |model_type|
|
19
|
-
|
20
|
-
context "with a #{model_type} that has a setup step as its final step" do
|
21
|
-
|
22
|
-
let(:test_model) do
|
23
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
|
24
|
-
model.steps = [CukeModeler::Step.new('When a step'),
|
25
|
-
CukeModeler::Step.new('Given a step')]
|
26
|
-
|
27
|
-
model
|
28
|
-
end
|
29
|
-
|
30
|
-
it_should_behave_like 'a linter linting a bad model'
|
31
|
-
|
32
|
-
|
33
|
-
it 'records a problem' do
|
34
|
-
result = subject.lint(test_model)
|
35
|
-
|
36
|
-
expect(result[:problem]).to eq("Test has 'Given' as the final step.")
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
context "with a #{model_type} that does not have a setup step as its final step" do
|
42
|
-
|
43
|
-
context 'because it has no steps' do
|
44
|
-
|
45
|
-
context 'because its steps are empty' do
|
46
|
-
|
47
|
-
let(:test_model) do
|
48
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
49
|
-
model.steps = []
|
50
|
-
|
51
|
-
model
|
52
|
-
end
|
53
|
-
|
54
|
-
it_should_behave_like 'a linter linting a good model'
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'because its steps are nil' do
|
59
|
-
|
60
|
-
let(:test_model) do
|
61
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
62
|
-
model.steps = nil
|
63
|
-
|
64
|
-
model
|
65
|
-
end
|
66
|
-
|
67
|
-
it_should_behave_like 'a linter linting a good model'
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'because its final step is not a setup step' do
|
74
|
-
|
75
|
-
let(:test_model) do
|
76
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
77
|
-
model.steps = [CukeModeler::Step.new('Then a step')]
|
78
|
-
|
79
|
-
model
|
80
|
-
end
|
81
|
-
|
82
|
-
it_should_behave_like 'a linter linting a good model'
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
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
|
155
|
-
|
156
|
-
context 'a non-test model' do
|
157
|
-
|
158
|
-
let(:test_model) { CukeModeler::Model.new }
|
159
|
-
|
160
|
-
it_should_behave_like 'a linter linting a good model'
|
161
|
-
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
@@ -1,192 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::TestWithTooManyStepsLinter do
|
5
|
-
|
6
|
-
let(:model_file_path) { 'some_file_path' }
|
7
|
-
|
8
|
-
it_should_behave_like 'a linter at the unit level'
|
9
|
-
it_should_behave_like 'a configurable linter at the unit level'
|
10
|
-
|
11
|
-
|
12
|
-
it 'has a name' do
|
13
|
-
expect(subject.name).to eq('TestWithTooManyStepsLinter')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'linting' do
|
17
|
-
|
18
|
-
['scenario', 'outline'].each do |model_type|
|
19
|
-
|
20
|
-
context "with a #{model_type} that has too many steps" do
|
21
|
-
|
22
|
-
let(:test_model) do
|
23
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
|
24
|
-
model.steps = [:step_1,
|
25
|
-
:step_2,
|
26
|
-
:step_3,
|
27
|
-
:step_4,
|
28
|
-
:step_5,
|
29
|
-
:step_6,
|
30
|
-
:step_7,
|
31
|
-
:step_8,
|
32
|
-
:step_9,
|
33
|
-
:step_10,
|
34
|
-
:step_11]
|
35
|
-
|
36
|
-
model
|
37
|
-
end
|
38
|
-
|
39
|
-
it_should_behave_like 'a linter linting a bad model'
|
40
|
-
|
41
|
-
|
42
|
-
it 'records a problem' do
|
43
|
-
result = subject.lint(test_model)
|
44
|
-
|
45
|
-
expect(result[:problem]).to match(/^Test has too many steps. \d+ steps found \(max 10\)/)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'includes the number of steps found in the problem record' do
|
49
|
-
step_count = test_model.steps.count
|
50
|
-
result = subject.lint(test_model)
|
51
|
-
expect(result[:problem]).to eq("Test has too many steps. #{step_count} steps found (max 10).")
|
52
|
-
|
53
|
-
test_model.steps << :another_step
|
54
|
-
result = subject.lint(test_model)
|
55
|
-
expect(result[:problem]).to eq("Test has too many steps. #{step_count + 1} steps found (max 10).")
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with a #{model_type} that does not have too many steps" do
|
61
|
-
|
62
|
-
context 'because it has fewer than 10 steps' do
|
63
|
-
|
64
|
-
let(:test_model) do
|
65
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
66
|
-
model.steps = [:step_1]
|
67
|
-
|
68
|
-
model
|
69
|
-
end
|
70
|
-
|
71
|
-
it_should_behave_like 'a linter linting a good model'
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'because it has no steps' do
|
76
|
-
|
77
|
-
context 'because its steps are empty' do
|
78
|
-
|
79
|
-
let(:test_model) do
|
80
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
81
|
-
model.steps = []
|
82
|
-
|
83
|
-
model
|
84
|
-
end
|
85
|
-
|
86
|
-
it_should_behave_like 'a linter linting a good model'
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'because its steps are nil' do
|
91
|
-
|
92
|
-
let(:test_model) do
|
93
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: 'path_to_file')
|
94
|
-
model.steps = nil
|
95
|
-
|
96
|
-
model
|
97
|
-
end
|
98
|
-
|
99
|
-
it_should_behave_like 'a linter linting a good model'
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
describe 'configuration' do
|
109
|
-
|
110
|
-
context 'with no configuration' do
|
111
|
-
|
112
|
-
let(:default_step_threshhold) { 10 }
|
113
|
-
|
114
|
-
context 'because configuration never happened' do
|
115
|
-
|
116
|
-
let(:unconfigured_test_model) do
|
117
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
118
|
-
model.steps = []
|
119
|
-
(default_step_threshhold + 1).times { model.steps << :a_step }
|
120
|
-
|
121
|
-
model
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'defaults to a step threshold of 10 steps' do
|
125
|
-
result = subject.lint(unconfigured_test_model)
|
126
|
-
|
127
|
-
expect(result[:problem]).to match(/^Test has too many steps. #{unconfigured_test_model.steps.count} steps found \(max 10\)/)
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
context 'because configuration did not set a step threshold' do
|
133
|
-
let(:configuration) { {} }
|
134
|
-
let(:configured_test_model) do
|
135
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
136
|
-
model.steps = []
|
137
|
-
(default_step_threshhold + 1).times { model.steps << :a_step }
|
138
|
-
|
139
|
-
subject.configure(configuration)
|
140
|
-
|
141
|
-
model
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'defaults to a step threshold of 10 steps' do
|
145
|
-
result = subject.lint(configured_test_model)
|
146
|
-
|
147
|
-
expect(result[:problem]).to match(/^Test has too many steps. #{configured_test_model.steps.count} steps found \(max 10\)/)
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
|
155
|
-
context 'with configuration' do
|
156
|
-
|
157
|
-
let(:step_threshhold) { 3 }
|
158
|
-
let(:configuration) { { 'StepThreshold' => step_threshhold } }
|
159
|
-
|
160
|
-
subject { linter = CukeLinter::TestWithTooManyStepsLinter.new
|
161
|
-
linter.configure(configuration)
|
162
|
-
linter }
|
163
|
-
|
164
|
-
let(:test_model) do
|
165
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
166
|
-
model.steps = []
|
167
|
-
(step_threshhold + 1).times { model.steps << :a_step }
|
168
|
-
|
169
|
-
model
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'the step threshold used is the configured value' do
|
173
|
-
result = subject.lint(test_model)
|
174
|
-
|
175
|
-
expect(result[:problem]).to match(/^Test has too many steps. #{test_model.steps.count} steps found \(max #{step_threshhold}\)/)
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
context 'a non-test model' do
|
185
|
-
|
186
|
-
let(:test_model) { CukeModeler::Model.new }
|
187
|
-
|
188
|
-
it_should_behave_like 'a linter linting a good model'
|
189
|
-
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|