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,243 +0,0 @@
|
|
1
|
-
require_relative '../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
RSpec.describe CukeLinter do
|
4
|
-
|
5
|
-
let(:test_model_tree) { CukeLinter::ModelFactory.generate_lintable_model }
|
6
|
-
let(:test_linters) { [CukeLinter::LinterFactory.generate_fake_linter] }
|
7
|
-
let(:test_formatters) { [[CukeLinter::FormatterFactory.generate_fake_formatter, "#{CukeLinter::FileHelper::create_directory}/junk_output_file.txt"]] }
|
8
|
-
let(:linting_options) { { model_trees: [test_model_tree], linters: test_linters, formatters: test_formatters } }
|
9
|
-
|
10
|
-
|
11
|
-
it 'returns the un-formatted linting data when linting' do
|
12
|
-
results = subject.lint(linting_options)
|
13
|
-
|
14
|
-
expect(results).to eq([{ linter: 'FakeLinter', location: 'path_to_file:1', problem: 'FakeLinter problem' }])
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'uses every formatter provided' do
|
18
|
-
linting_options[:formatters] = [[CukeLinter::FormatterFactory.generate_fake_formatter(name: 'Formatter1')],
|
19
|
-
[CukeLinter::FormatterFactory.generate_fake_formatter(name: 'Formatter2')]]
|
20
|
-
|
21
|
-
expect { subject.lint(linting_options) }.to output("Formatter1: FakeLinter problem: path_to_file:1\nFormatter2: FakeLinter problem: path_to_file:1\n").to_stdout
|
22
|
-
end
|
23
|
-
|
24
|
-
it "uses the 'pretty' formatter if none are provided" do
|
25
|
-
linting_options.delete(:formatters)
|
26
|
-
|
27
|
-
expect { subject.lint(linting_options) }.to output(['FakeLinter',
|
28
|
-
' FakeLinter problem',
|
29
|
-
' path_to_file:1',
|
30
|
-
'',
|
31
|
-
'1 issues found',
|
32
|
-
''].join("\n")).to_stdout
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'outputs formatted linting data to the provided output location' do
|
36
|
-
output_path = "#{CukeLinter::FileHelper::create_directory}/output.txt"
|
37
|
-
linting_options[:formatters] = [[CukeLinter::FormatterFactory.generate_fake_formatter(name: 'Formatter1'),
|
38
|
-
output_path]]
|
39
|
-
|
40
|
-
expect { subject.lint(linting_options) }.to_not output.to_stdout
|
41
|
-
expect(File.read(output_path)).to eq("Formatter1: FakeLinter problem: path_to_file:1\n")
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'outputs formatted data to STDOUT if not location is provided' do
|
45
|
-
linting_options[:formatters] = [[CukeLinter::FormatterFactory.generate_fake_formatter(name: 'Formatter1')]]
|
46
|
-
|
47
|
-
expect { subject.lint(linting_options) }.to output("Formatter1: FakeLinter problem: path_to_file:1\n").to_stdout
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'with only model trees' do
|
51
|
-
|
52
|
-
before(:each) do
|
53
|
-
child_model = CukeLinter::ModelFactory.generate_lintable_model(source_line: 3)
|
54
|
-
parent_model = CukeLinter::ModelFactory.generate_lintable_model(source_line: 5, children: [child_model])
|
55
|
-
multi_node_tree = parent_model
|
56
|
-
single_node_tree = CukeLinter::ModelFactory.generate_lintable_model(source_line: 7)
|
57
|
-
|
58
|
-
linting_options[:model_trees] = [single_node_tree, multi_node_tree]
|
59
|
-
linting_options.delete(:file_paths)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'lints every model in each model tree' do
|
63
|
-
results = subject.lint(linting_options)
|
64
|
-
|
65
|
-
expect(results).to match_array([{ linter: 'FakeLinter', location: 'path_to_file:3', problem: 'FakeLinter problem' },
|
66
|
-
{ linter: 'FakeLinter', location: 'path_to_file:5', problem: 'FakeLinter problem' },
|
67
|
-
{ linter: 'FakeLinter', location: 'path_to_file:7', problem: 'FakeLinter problem' }])
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'with only file paths' do
|
73
|
-
|
74
|
-
before(:each) do
|
75
|
-
@a_feature_file = CukeLinter::FileHelper::create_file(text: "\nFeature:", extension: '.feature')
|
76
|
-
a_non_feature_file = CukeLinter::FileHelper::create_file(text: 'Some text', extension: '.foo')
|
77
|
-
@a_directory = CukeLinter::FileHelper::create_directory
|
78
|
-
File.write("#{@a_directory}/test_feature.feature", "Feature:")
|
79
|
-
|
80
|
-
linting_options[:file_paths] = [@a_feature_file, a_non_feature_file, @a_directory]
|
81
|
-
linting_options.delete(:model_trees)
|
82
|
-
end
|
83
|
-
|
84
|
-
# TODO: add a negative test that makes sure that non-included paths aren't linted when paths are explicitly included
|
85
|
-
|
86
|
-
it 'lints every model in each path' do
|
87
|
-
results = subject.lint(linting_options)
|
88
|
-
|
89
|
-
expect(results).to match_array([{ linter: 'FakeLinter', location: @a_directory, problem: 'FakeLinter problem' },
|
90
|
-
{ linter: 'FakeLinter', location: "#{@a_directory}/test_feature.feature", problem: 'FakeLinter problem' },
|
91
|
-
{ linter: 'FakeLinter', location: "#{@a_directory}/test_feature.feature:1", problem: 'FakeLinter problem' },
|
92
|
-
{ linter: 'FakeLinter', location: @a_feature_file, problem: 'FakeLinter problem' },
|
93
|
-
{ linter: 'FakeLinter', location: "#{@a_feature_file}:2", problem: 'FakeLinter problem' }])
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'with both model trees and file paths' do
|
99
|
-
|
100
|
-
before(:each) do
|
101
|
-
a_model = CukeLinter::ModelFactory.generate_lintable_model(source_line: 3)
|
102
|
-
@a_feature_file = CukeLinter::FileHelper::create_file(text: 'Feature:', extension: '.feature')
|
103
|
-
|
104
|
-
linting_options[:model_trees] = [a_model]
|
105
|
-
linting_options[:file_paths] = [@a_feature_file]
|
106
|
-
end
|
107
|
-
|
108
|
-
|
109
|
-
it 'lints every model in each model tree and file path' do
|
110
|
-
results = subject.lint(linting_options)
|
111
|
-
|
112
|
-
expect(results).to match_array([{ linter: 'FakeLinter', location: 'path_to_file:3', problem: 'FakeLinter problem' },
|
113
|
-
{ linter: 'FakeLinter', location: @a_feature_file, problem: 'FakeLinter problem' },
|
114
|
-
{ linter: 'FakeLinter', location: "#{@a_feature_file}:1", problem: 'FakeLinter problem' }])
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'with neither model trees or file paths' do
|
120
|
-
|
121
|
-
before(:each) do
|
122
|
-
linting_options.delete(:model_trees)
|
123
|
-
linting_options.delete(:file_paths)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'models the current directory' do
|
127
|
-
test_dir = CukeLinter::FileHelper::create_directory
|
128
|
-
File.write("#{test_dir}/test_feature.feature", "Feature:")
|
129
|
-
|
130
|
-
Dir.chdir(test_dir) do
|
131
|
-
@results = subject.lint(linting_options)
|
132
|
-
end
|
133
|
-
|
134
|
-
# There should be 3 models to lint: the directory, the feature file, and the feature
|
135
|
-
expect(@results.count).to eq(3)
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'uses evey linter provided' do
|
141
|
-
linting_options[:linters] = [CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter1'),
|
142
|
-
CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter2')]
|
143
|
-
|
144
|
-
results = subject.lint(linting_options)
|
145
|
-
|
146
|
-
expect(results).to match_array([{ linter: 'FakeLinter1', location: 'path_to_file:1', problem: 'FakeLinter1 problem' },
|
147
|
-
{ linter: 'FakeLinter2', location: 'path_to_file:1', problem: 'FakeLinter2 problem' }])
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'uses all registered linters if none are provided', :linter_registration do
|
151
|
-
CukeLinter.clear_registered_linters
|
152
|
-
CukeLinter.register_linter(linter: CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter1'), name: 'FakeLinter1')
|
153
|
-
CukeLinter.register_linter(linter: CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter2'), name: 'FakeLinter2')
|
154
|
-
CukeLinter.register_linter(linter: CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter3'), name: 'FakeLinter3')
|
155
|
-
|
156
|
-
begin
|
157
|
-
linting_options.delete(:linters)
|
158
|
-
results = subject.lint(linting_options)
|
159
|
-
|
160
|
-
expect(results).to match_array([{ linter: 'FakeLinter1', location: 'path_to_file:1', problem: 'FakeLinter1 problem' },
|
161
|
-
{ linter: 'FakeLinter2', location: 'path_to_file:1', problem: 'FakeLinter2 problem' },
|
162
|
-
{ linter: 'FakeLinter3', location: 'path_to_file:1', problem: 'FakeLinter3 problem' }])
|
163
|
-
ensure
|
164
|
-
CukeLinter.reset_linters
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'includes the name of the linter in the linting data' do
|
169
|
-
linting_options[:linters] = [CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter1'),
|
170
|
-
CukeLinter::LinterFactory.generate_fake_linter(name: 'FakeLinter2')]
|
171
|
-
|
172
|
-
results = subject.lint(linting_options)
|
173
|
-
|
174
|
-
expect(results).to match_array([{ linter: 'FakeLinter1', location: 'path_to_file:1', problem: 'FakeLinter1 problem' },
|
175
|
-
{ linter: 'FakeLinter2', location: 'path_to_file:1', problem: 'FakeLinter2 problem' }])
|
176
|
-
end
|
177
|
-
|
178
|
-
it 'has a default set of registered linters' do
|
179
|
-
subject.reset_linters
|
180
|
-
|
181
|
-
default_linter_classes = ['BackgroundDoesMoreThanSetupLinter',
|
182
|
-
'ElementWithCommonTagsLinter',
|
183
|
-
'ElementWithDuplicateTagsLinter',
|
184
|
-
'ElementWithTooManyTagsLinter',
|
185
|
-
'ExampleWithoutNameLinter',
|
186
|
-
'FeatureFileWithInvalidNameLinter',
|
187
|
-
'FeatureFileWithMismatchedNameLinter',
|
188
|
-
'FeatureWithTooManyDifferentTagsLinter',
|
189
|
-
'FeatureWithoutDescriptionLinter',
|
190
|
-
'FeatureWithoutNameLinter',
|
191
|
-
'FeatureWithoutScenariosLinter',
|
192
|
-
'OutlineWithSingleExampleRowLinter',
|
193
|
-
'SingleTestBackgroundLinter',
|
194
|
-
'StepWithEndPeriodLinter',
|
195
|
-
'StepWithTooManyCharactersLinter',
|
196
|
-
'TestShouldUseBackgroundLinter',
|
197
|
-
'TestWithActionStepAsFinalStepLinter',
|
198
|
-
'TestWithBadNameLinter',
|
199
|
-
'TestWithNoActionStepLinter',
|
200
|
-
'TestWithNoNameLinter',
|
201
|
-
'TestWithNoVerificationStepLinter',
|
202
|
-
'TestWithSetupStepAfterActionStepLinter',
|
203
|
-
'TestWithSetupStepAfterVerificationStepLinter',
|
204
|
-
'TestWithSetupStepAsFinalStepLinter',
|
205
|
-
'TestWithTooManyStepsLinter']
|
206
|
-
|
207
|
-
expect(subject.registered_linters.keys).to eq(default_linter_classes)
|
208
|
-
|
209
|
-
default_linter_classes.each do |clazz|
|
210
|
-
expect(subject.registered_linters[clazz]).to be_a(CukeLinter.const_get(clazz))
|
211
|
-
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
it 'returns to its default set of linters after being reset' do
|
216
|
-
original_names = CukeLinter.registered_linters.keys
|
217
|
-
original_linter_types = CukeLinter.registered_linters.values.map(&:class)
|
218
|
-
new_linter = CukeLinter::LinterFactory.generate_fake_linter
|
219
|
-
|
220
|
-
CukeLinter.register_linter(linter: new_linter, name: 'FakeLinter')
|
221
|
-
CukeLinter.reset_linters
|
222
|
-
|
223
|
-
expect(CukeLinter.registered_linters.keys).to eq(original_names)
|
224
|
-
expect(CukeLinter.registered_linters.values.map(&:class)).to eq(original_linter_types)
|
225
|
-
end
|
226
|
-
|
227
|
-
# To protect against someone modifying them
|
228
|
-
it 'does not reuse the old linting objects when resetting to the default linters' do
|
229
|
-
original_linter_ids = CukeLinter.registered_linters.values.map(&:object_id)
|
230
|
-
|
231
|
-
CukeLinter.reset_linters
|
232
|
-
|
233
|
-
expect(CukeLinter.registered_linters.values.map(&:object_id)).to_not match_array(original_linter_ids)
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'can handle a mixture of problematic and non-problematic models' do
|
237
|
-
linting_options[:linters] = [CukeLinter::LinterFactory.generate_fake_linter(finds_problems: true),
|
238
|
-
CukeLinter::LinterFactory.generate_fake_linter(finds_problems: false)]
|
239
|
-
|
240
|
-
expect { subject.lint(linting_options) }.to_not raise_error
|
241
|
-
end
|
242
|
-
|
243
|
-
end
|