cuke_linter 0.12.0 → 1.1.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 +41 -1
- data/README.md +12 -8
- data/cuke_linter.gemspec +25 -21
- data/exe/cuke_linter +3 -1
- data/lib/cuke_linter.rb +119 -176
- data/lib/cuke_linter/configuration.rb +45 -0
- data/lib/cuke_linter/default_linters.rb +32 -0
- data/lib/cuke_linter/formatters/pretty_formatter.rb +63 -35
- data/lib/cuke_linter/gherkin.rb +10 -0
- data/lib/cuke_linter/linter_registration.rb +32 -0
- data/lib/cuke_linter/linters/background_does_more_than_setup_linter.rb +17 -1
- data/lib/cuke_linter/linters/element_with_common_tags_linter.rb +23 -14
- data/lib/cuke_linter/linters/element_with_duplicate_tags_linter.rb +18 -13
- data/lib/cuke_linter/linters/element_with_too_many_tags_linter.rb +17 -11
- data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +1 -3
- data/lib/cuke_linter/linters/feature_without_description_linter.rb +1 -1
- data/lib/cuke_linter/linters/linter.rb +17 -13
- data/lib/cuke_linter/linters/step_with_too_many_characters_linter.rb +2 -2
- data/lib/cuke_linter/linters/test_should_use_background_linter.rb +56 -4
- data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +12 -1
- data/lib/cuke_linter/linters/test_with_bad_name_linter.rb +4 -4
- 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
- metadata +88 -106
- data/.gitignore +0 -19
- data/.simplecov +0 -8
- data/.travis.yml +0 -23
- 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 -230
- 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 -102
- 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 -77
- 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 -226
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +0 -98
- 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 -176
- 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 -179
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +0 -124
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +0 -125
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +0 -98
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +0 -192
@@ -1,98 +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
|
-
|
10
|
-
|
11
|
-
it 'has a name' do
|
12
|
-
expect(subject.name).to eq('TestWithSetupStepAsFinalStepLinter')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'linting' do
|
16
|
-
|
17
|
-
['scenario', 'outline'].each do |model_type|
|
18
|
-
|
19
|
-
context "with a #{model_type} that has a setup step as its final step" do
|
20
|
-
|
21
|
-
let(:test_model) do
|
22
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model", parent_file_path: model_file_path)
|
23
|
-
model.steps = [CukeModeler::Step.new('When a step'),
|
24
|
-
CukeModeler::Step.new('Given a step')]
|
25
|
-
|
26
|
-
model
|
27
|
-
end
|
28
|
-
|
29
|
-
it_should_behave_like 'a linter linting a bad model'
|
30
|
-
|
31
|
-
|
32
|
-
it 'records a problem' do
|
33
|
-
result = subject.lint(test_model)
|
34
|
-
|
35
|
-
expect(result[:problem]).to eq("Test has 'Given' as the final step.")
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with a #{model_type} that does not have a setup step as its final step" do
|
41
|
-
|
42
|
-
context 'because it has no steps' do
|
43
|
-
|
44
|
-
context 'because its steps are empty' do
|
45
|
-
|
46
|
-
let(:test_model) do
|
47
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
48
|
-
model.steps = []
|
49
|
-
|
50
|
-
model
|
51
|
-
end
|
52
|
-
|
53
|
-
it_should_behave_like 'a linter linting a good model'
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'because its steps are nil' do
|
58
|
-
|
59
|
-
let(:test_model) do
|
60
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
61
|
-
model.steps = nil
|
62
|
-
|
63
|
-
model
|
64
|
-
end
|
65
|
-
|
66
|
-
it_should_behave_like 'a linter linting a good model'
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'because its final step is not a setup step' do
|
73
|
-
|
74
|
-
let(:test_model) do
|
75
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
76
|
-
model.steps = [CukeModeler::Step.new('Then a step')]
|
77
|
-
|
78
|
-
model
|
79
|
-
end
|
80
|
-
|
81
|
-
it_should_behave_like 'a linter linting a good model'
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
context 'a non-test model' do
|
91
|
-
|
92
|
-
let(:test_model) { CukeModeler::Model.new }
|
93
|
-
|
94
|
-
it_should_behave_like 'a linter linting a good model'
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
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
|