cuke_linter 0.13.0 → 1.0.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.
- 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,84 +0,0 @@
|
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RSpec.describe CukeLinter::FeatureWithoutNameLinter 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('FeatureWithoutNameLinter')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe 'linting' do
|
|
16
|
-
|
|
17
|
-
context 'with a feature that has no name' do
|
|
18
|
-
|
|
19
|
-
context 'because its name is empty' do
|
|
20
|
-
|
|
21
|
-
let(:test_model) do
|
|
22
|
-
model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path)
|
|
23
|
-
model.name = ''
|
|
24
|
-
|
|
25
|
-
model
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
it 'records a problem' do
|
|
32
|
-
result = subject.lint(test_model)
|
|
33
|
-
|
|
34
|
-
expect(result[:problem]).to eq('Feature does not have a name.')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'because its name is nil' do
|
|
40
|
-
|
|
41
|
-
let(:test_model) do
|
|
42
|
-
model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path)
|
|
43
|
-
model.name = nil
|
|
44
|
-
|
|
45
|
-
model
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
49
|
-
|
|
50
|
-
it 'records a problem' do
|
|
51
|
-
result = subject.lint(test_model)
|
|
52
|
-
|
|
53
|
-
expect(result[:problem]).to eq('Feature does not have a name.')
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'with a feature that does have a name' do
|
|
61
|
-
|
|
62
|
-
let(:test_model) do
|
|
63
|
-
model = CukeLinter::ModelFactory.generate_feature_model
|
|
64
|
-
model.name = 'foo'
|
|
65
|
-
|
|
66
|
-
model
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it_should_behave_like 'a linter linting a good model'
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
context 'a non-feature model' do
|
|
75
|
-
|
|
76
|
-
let(:test_model) { CukeModeler::Model.new }
|
|
77
|
-
|
|
78
|
-
it_should_behave_like 'a linter linting a good model'
|
|
79
|
-
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
end
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RSpec.describe CukeLinter::FeatureWithoutScenariosLinter 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('FeatureWithoutScenariosLinter')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe 'linting' do
|
|
16
|
-
|
|
17
|
-
context 'a feature with no tests' do
|
|
18
|
-
|
|
19
|
-
context 'because the tests are empty' do
|
|
20
|
-
|
|
21
|
-
let(:test_model) do
|
|
22
|
-
model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path)
|
|
23
|
-
model.tests = []
|
|
24
|
-
|
|
25
|
-
model
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
29
|
-
|
|
30
|
-
it 'records a problem' do
|
|
31
|
-
result = subject.lint(test_model)
|
|
32
|
-
|
|
33
|
-
expect(result[:problem]).to eq('Feature has no scenarios')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
context 'because the tests are nil' do
|
|
39
|
-
|
|
40
|
-
let(:test_model) do
|
|
41
|
-
model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path)
|
|
42
|
-
model.tests = nil
|
|
43
|
-
|
|
44
|
-
model
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
48
|
-
|
|
49
|
-
it 'records a problem' do
|
|
50
|
-
result = subject.lint(test_model)
|
|
51
|
-
|
|
52
|
-
expect(result[:problem]).to eq('Feature has no scenarios')
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context 'a feature with tests' do
|
|
60
|
-
|
|
61
|
-
context 'with a scenario' do
|
|
62
|
-
|
|
63
|
-
let(:test_model) do
|
|
64
|
-
gherkin = 'Feature:
|
|
65
|
-
|
|
66
|
-
Scenario:'
|
|
67
|
-
|
|
68
|
-
CukeLinter::ModelFactory.generate_feature_model(source_text: gherkin)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it_should_behave_like 'a linter linting a good model'
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'with an outline' do
|
|
76
|
-
|
|
77
|
-
let(:test_model) do
|
|
78
|
-
gherkin = 'Feature:
|
|
79
|
-
|
|
80
|
-
Scenario Outline:
|
|
81
|
-
* a step
|
|
82
|
-
Examples:
|
|
83
|
-
| param |'
|
|
84
|
-
|
|
85
|
-
CukeLinter::ModelFactory.generate_feature_model(source_text: gherkin)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it_should_behave_like 'a linter linting a good model'
|
|
89
|
-
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context 'a non-feature model' do
|
|
95
|
-
|
|
96
|
-
let(:test_model) { CukeModeler::Model.new }
|
|
97
|
-
|
|
98
|
-
it_should_behave_like 'a linter linting a good model'
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RSpec.describe CukeLinter::Linter do
|
|
5
|
-
|
|
6
|
-
let(:model_file_path) { 'some_file_path' }
|
|
7
|
-
|
|
8
|
-
let(:linter_name) { 'FooLinter' }
|
|
9
|
-
let(:linter_message) { 'Foo!' }
|
|
10
|
-
let(:linter_rule) { lambda { |model| !model.is_a?(CukeModeler::Example) } }
|
|
11
|
-
let(:linter_options) { { name: linter_name, message: linter_message, rule: linter_rule } }
|
|
12
|
-
|
|
13
|
-
let(:good_data) { CukeLinter::ModelFactory.generate_example_model }
|
|
14
|
-
let(:bad_data) { CukeLinter::ModelFactory.generate_outline_model }
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
it_should_behave_like 'a linter at the unit level'
|
|
18
|
-
|
|
19
|
-
context 'with a linting rule' do
|
|
20
|
-
|
|
21
|
-
subject { CukeLinter::Linter.new(linter_options.merge({ rule: linter_rule })) }
|
|
22
|
-
|
|
23
|
-
context 'with a good model' do
|
|
24
|
-
|
|
25
|
-
let(:test_model) { CukeLinter::ModelFactory.generate_example_model }
|
|
26
|
-
|
|
27
|
-
it_should_behave_like 'a linter linting a good model'
|
|
28
|
-
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context 'with a bad model' do
|
|
32
|
-
|
|
33
|
-
let(:test_model) { CukeLinter::ModelFactory.generate_outline_model(parent_file_path: model_file_path) }
|
|
34
|
-
|
|
35
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
36
|
-
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
context 'with custom values' do
|
|
43
|
-
|
|
44
|
-
subject { CukeLinter::Linter.new(linter_options) }
|
|
45
|
-
|
|
46
|
-
it 'uses the provided name' do
|
|
47
|
-
expect(subject.name).to eq(linter_name)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'uses the provided rule' do
|
|
51
|
-
expect(subject.lint(good_data)).to be_nil
|
|
52
|
-
expect(subject.lint(bad_data)).to_not be_nil
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'uses the provided message' do
|
|
56
|
-
result = subject.lint(bad_data)
|
|
57
|
-
|
|
58
|
-
expect(result[:problem]).to eq(linter_message)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context 'with custom methods' do
|
|
64
|
-
|
|
65
|
-
subject { linter = CukeLinter::Linter.new
|
|
66
|
-
|
|
67
|
-
linter.define_singleton_method('rule') do |model|
|
|
68
|
-
!model.is_a?(CukeModeler::Example)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
linter.define_singleton_method('name') do
|
|
72
|
-
'FooLinter'
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
linter.define_singleton_method('message') do
|
|
76
|
-
'Foo!'
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
linter }
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
it 'uses the provided #name' do
|
|
84
|
-
expect(subject.name).to eq(linter_name)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it 'uses the provided #rule' do
|
|
88
|
-
expect(subject.lint(good_data)).to be_nil
|
|
89
|
-
expect(subject.lint(bad_data)).to_not be_nil
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'uses the provided #message' do
|
|
93
|
-
result = subject.lint(bad_data)
|
|
94
|
-
|
|
95
|
-
expect(result[:problem]).to eq(linter_message)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context 'with both custom values and methods' do
|
|
101
|
-
|
|
102
|
-
let(:good_data) do
|
|
103
|
-
CukeLinter::ModelFactory.generate_outline_model
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
let(:bad_data) do
|
|
107
|
-
CukeLinter::ModelFactory.generate_example_model
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
subject { linter = CukeLinter::Linter.new(linter_options)
|
|
111
|
-
|
|
112
|
-
linter.define_singleton_method('rule') do |model|
|
|
113
|
-
model.is_a?(CukeModeler::Example)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
linter.define_singleton_method('name') do
|
|
117
|
-
'Method Linter'
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
linter.define_singleton_method('message') do
|
|
121
|
-
'Method Foo!'
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
linter }
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
it 'uses #name instead of the provided name' do
|
|
129
|
-
expect(subject.name).to eq('Method Linter')
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
it 'uses #rule instead of the provided rule' do
|
|
133
|
-
expect(subject.lint(good_data)).to be_nil
|
|
134
|
-
expect(subject.lint(bad_data)).to_not be_nil
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it 'uses #message instead of the provided message' do
|
|
138
|
-
result = subject.lint(bad_data)
|
|
139
|
-
|
|
140
|
-
expect(result[:problem]).to eq('Method Foo!')
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context 'with neither custom values nor methods' do
|
|
146
|
-
|
|
147
|
-
subject { CukeLinter::Linter.new }
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
it 'complains if not provided with a rule' do
|
|
151
|
-
expect { subject.lint('Anything') }.to raise_error('No linting rule provided!')
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
it 'has a default name based on its class' do
|
|
156
|
-
expect(subject.name).to eq('Linter')
|
|
157
|
-
|
|
158
|
-
class CustomLinter < CukeLinter::Linter;
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
expect(CustomLinter.new.name).to eq('CustomLinter')
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it 'has a default message based on its name' do
|
|
165
|
-
linter_options[:message] = nil
|
|
166
|
-
|
|
167
|
-
# Default name
|
|
168
|
-
linter_options[:name] = nil
|
|
169
|
-
linter = CukeLinter::Linter.new(linter_options)
|
|
170
|
-
result = linter.lint(bad_data)
|
|
171
|
-
|
|
172
|
-
expect(result[:problem]).to eq('Linter problem detected')
|
|
173
|
-
|
|
174
|
-
# Value name
|
|
175
|
-
linter_options[:name] = 'Value name'
|
|
176
|
-
linter = CukeLinter::Linter.new(linter_options)
|
|
177
|
-
result = linter.lint(bad_data)
|
|
178
|
-
|
|
179
|
-
expect(result[:problem]).to eq('Value name problem detected')
|
|
180
|
-
|
|
181
|
-
# Method name
|
|
182
|
-
class CustomLinter < CukeLinter::Linter;
|
|
183
|
-
def name
|
|
184
|
-
'Method name'
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
linter_options[:name] = nil
|
|
189
|
-
linter = CustomLinter.new(linter_options)
|
|
190
|
-
result = linter.lint(bad_data)
|
|
191
|
-
|
|
192
|
-
expect(result[:problem]).to eq('Method name problem detected')
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
end
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
shared_examples_for 'a linter at the unit level' do
|
|
2
|
-
|
|
3
|
-
it 'is named' do
|
|
4
|
-
expect(subject).to respond_to(:name)
|
|
5
|
-
expect(subject.name).to be_a_kind_of(String)
|
|
6
|
-
expect(subject.name).to_not be_empty
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it 'can lint' do
|
|
10
|
-
expect(subject).to respond_to(:lint)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'lints a model' do
|
|
14
|
-
expect(subject.method(:lint).arity).to eq(1)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
shared_examples_for 'a linter linting a good model' do
|
|
21
|
-
|
|
22
|
-
it 'returns no problem' do
|
|
23
|
-
expect(subject.lint(test_model)).to be_nil
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
shared_examples_for 'a linter linting a bad model' do
|
|
30
|
-
|
|
31
|
-
it 'returns a detected problem' do
|
|
32
|
-
expect(subject.lint(test_model)).to_not be_nil
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'includes the problem and its location in its result' do
|
|
36
|
-
result = subject.lint(test_model)
|
|
37
|
-
|
|
38
|
-
expect(result).to_not be_nil
|
|
39
|
-
expect(result.keys).to match_array([:problem, :location])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'correctly records the location of the problem' do
|
|
43
|
-
if test_model.is_a?(CukeModeler::FeatureFile)
|
|
44
|
-
result = subject.lint(test_model)
|
|
45
|
-
expect(result[:location]).to eq("#{model_file_path}")
|
|
46
|
-
else
|
|
47
|
-
test_model.source_line = 1
|
|
48
|
-
result = subject.lint(test_model)
|
|
49
|
-
expect(result[:location]).to eq("#{model_file_path}:1")
|
|
50
|
-
|
|
51
|
-
test_model.source_line = 3
|
|
52
|
-
result = subject.lint(test_model)
|
|
53
|
-
expect(result[:location]).to eq("#{model_file_path}:3")
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
end
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
RSpec.describe CukeLinter::OutlineWithSingleExampleRowLinter 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('OutlineWithSingleExampleRowLinter')
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe 'linting' do
|
|
16
|
-
|
|
17
|
-
context 'an outline with only one example row' do
|
|
18
|
-
|
|
19
|
-
context 'with only one example set' do
|
|
20
|
-
|
|
21
|
-
let(:test_model) do
|
|
22
|
-
gherkin = 'Scenario Outline:
|
|
23
|
-
* a step
|
|
24
|
-
Examples:
|
|
25
|
-
| param |
|
|
26
|
-
| value |'
|
|
27
|
-
|
|
28
|
-
CukeLinter::ModelFactory.generate_outline_model(parent_file_path: model_file_path,
|
|
29
|
-
source_text: gherkin)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
it 'records a problem' do
|
|
36
|
-
result = subject.lint(test_model)
|
|
37
|
-
|
|
38
|
-
expect(result[:problem]).to eq('Outline has only one example row')
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context 'with multiple example sets' do
|
|
44
|
-
|
|
45
|
-
let(:test_model) do
|
|
46
|
-
gherkin = 'Scenario Outline:
|
|
47
|
-
* a step
|
|
48
|
-
Examples:
|
|
49
|
-
| param |
|
|
50
|
-
Examples:
|
|
51
|
-
| param |
|
|
52
|
-
| value |'
|
|
53
|
-
|
|
54
|
-
CukeLinter::ModelFactory.generate_outline_model(parent_file_path: model_file_path,
|
|
55
|
-
source_text: gherkin)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it_should_behave_like 'a linter linting a bad model'
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
it 'records a problem' do
|
|
62
|
-
result = subject.lint(test_model)
|
|
63
|
-
|
|
64
|
-
expect(result[:problem]).to eq('Outline has only one example row')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
context 'an outline with more than one example row' do
|
|
72
|
-
|
|
73
|
-
context 'with only one example set' do
|
|
74
|
-
|
|
75
|
-
let(:test_model) do
|
|
76
|
-
gherkin = 'Scenario Outline:
|
|
77
|
-
* a step
|
|
78
|
-
Examples:
|
|
79
|
-
| param |
|
|
80
|
-
| value 1 |
|
|
81
|
-
| value 2 |'
|
|
82
|
-
|
|
83
|
-
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it_should_behave_like 'a linter linting a good model'
|
|
87
|
-
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context 'with multiple example sets' do
|
|
91
|
-
|
|
92
|
-
let(:test_model) do
|
|
93
|
-
gherkin = 'Scenario Outline:
|
|
94
|
-
* a step
|
|
95
|
-
Examples:
|
|
96
|
-
| param |
|
|
97
|
-
| value 1 |
|
|
98
|
-
Examples:
|
|
99
|
-
| param |
|
|
100
|
-
| value 1 |'
|
|
101
|
-
|
|
102
|
-
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it_should_behave_like 'a linter linting a good model'
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context 'an outline with no example rows' do
|
|
112
|
-
|
|
113
|
-
context 'because it has no example sets' do
|
|
114
|
-
|
|
115
|
-
context 'because its examples are nil' do
|
|
116
|
-
|
|
117
|
-
let(:test_model) do
|
|
118
|
-
model = CukeLinter::ModelFactory.generate_outline_model
|
|
119
|
-
model.examples = nil
|
|
120
|
-
|
|
121
|
-
model
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it_should_behave_like 'a linter linting a good model'
|
|
125
|
-
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context 'because its examples are empty' do
|
|
129
|
-
let(:test_model) do
|
|
130
|
-
model = CukeLinter::ModelFactory.generate_outline_model
|
|
131
|
-
model.examples = []
|
|
132
|
-
|
|
133
|
-
model
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it_should_behave_like 'a linter linting a good model'
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context 'with only one example set' do
|
|
143
|
-
|
|
144
|
-
let(:test_model) do
|
|
145
|
-
gherkin = 'Scenario Outline:
|
|
146
|
-
* a step
|
|
147
|
-
Examples:
|
|
148
|
-
| param |'
|
|
149
|
-
|
|
150
|
-
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it_should_behave_like 'a linter linting a good model'
|
|
154
|
-
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context 'with multiple example sets' do
|
|
158
|
-
|
|
159
|
-
let(:test_model) do
|
|
160
|
-
gherkin = 'Scenario Outline:
|
|
161
|
-
* a step
|
|
162
|
-
Examples:
|
|
163
|
-
| param |
|
|
164
|
-
Examples:
|
|
165
|
-
| param |'
|
|
166
|
-
|
|
167
|
-
CukeLinter::ModelFactory.generate_outline_model(source_text: gherkin)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it_should_behave_like 'a linter linting a good model'
|
|
171
|
-
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context 'a non-outline model' do
|
|
177
|
-
|
|
178
|
-
let(:test_model) { CukeModeler::Model.new }
|
|
179
|
-
|
|
180
|
-
it_should_behave_like 'a linter linting a good model'
|
|
181
|
-
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|