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,89 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::SingleTestBackgroundLinter 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('SingleTestBackgroundLinter')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'linting' do
|
16
|
-
|
17
|
-
context 'with a background that affects only one test' do
|
18
|
-
|
19
|
-
['scenario', 'outline'].each do |model_type|
|
20
|
-
|
21
|
-
context "and that test is a #{model_type}" do
|
22
|
-
|
23
|
-
let(:test_model) do
|
24
|
-
background_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
|
25
|
-
source_text: 'Feature:
|
26
|
-
Background:
|
27
|
-
* a step').background
|
28
|
-
|
29
|
-
background_model.parent_model.tests.clear
|
30
|
-
background_model.parent_model.tests << CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
31
|
-
|
32
|
-
background_model
|
33
|
-
end
|
34
|
-
|
35
|
-
it_should_behave_like 'a linter linting a bad model'
|
36
|
-
|
37
|
-
|
38
|
-
it 'records a problem' do
|
39
|
-
result = subject.lint(test_model)
|
40
|
-
|
41
|
-
expect(result[:problem]).to match('Background used with only one test')
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'with a background that affects multiple tests' do
|
51
|
-
|
52
|
-
let(:test_model) do
|
53
|
-
CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
|
54
|
-
Background:
|
55
|
-
* a step
|
56
|
-
Scenario:
|
57
|
-
Scenario Outline:
|
58
|
-
* a step
|
59
|
-
Examples:
|
60
|
-
|param|
|
61
|
-
|value|').background
|
62
|
-
end
|
63
|
-
|
64
|
-
it_should_behave_like 'a linter linting a good model'
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'with a background that affects no tests' do
|
69
|
-
|
70
|
-
let(:test_model) do
|
71
|
-
CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:
|
72
|
-
Background:
|
73
|
-
* a step').background
|
74
|
-
end
|
75
|
-
|
76
|
-
it_should_behave_like 'a linter linting a good model'
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'with a non-background model' do
|
81
|
-
|
82
|
-
let(:test_model) { CukeModeler::Model.new }
|
83
|
-
|
84
|
-
it_should_behave_like 'a linter linting a good model'
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::StepWithEndPeriodLinter 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('StepWithEndPeriodLinter')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'linting' do
|
16
|
-
|
17
|
-
context "with a step that ends with a period" do
|
18
|
-
|
19
|
-
let(:test_model) do
|
20
|
-
CukeLinter::ModelFactory.generate_step_model(parent_file_path: model_file_path,
|
21
|
-
source_text: '* with a period.')
|
22
|
-
end
|
23
|
-
|
24
|
-
it_should_behave_like 'a linter linting a bad model'
|
25
|
-
|
26
|
-
|
27
|
-
it 'records a problem' do
|
28
|
-
result = subject.lint(test_model)
|
29
|
-
|
30
|
-
expect(result[:problem]).to match('Step ends with a period')
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with a step that does not end with a period" do
|
36
|
-
|
37
|
-
let(:test_model) do
|
38
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: '* without a period')
|
39
|
-
end
|
40
|
-
|
41
|
-
it_should_behave_like 'a linter linting a good model'
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'with a non-step model' do
|
46
|
-
|
47
|
-
let(:test_model) { CukeModeler::Model.new }
|
48
|
-
|
49
|
-
it_should_behave_like 'a linter linting a good model'
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::StepWithTooManyCharactersLinter 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('StepWithTooManyCharactersLinter')
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'linting' do
|
17
|
-
|
18
|
-
let(:default_character_threshold) { 80 }
|
19
|
-
|
20
|
-
context 'when the step is too long' do
|
21
|
-
|
22
|
-
let(:test_model) do
|
23
|
-
step = 'x' * (default_character_threshold + 1)
|
24
|
-
CukeLinter::ModelFactory.generate_step_model(parent_file_path: model_file_path,
|
25
|
-
source_text: "* #{step}")
|
26
|
-
end
|
27
|
-
|
28
|
-
it_should_behave_like 'a linter linting a bad model'
|
29
|
-
|
30
|
-
|
31
|
-
it 'reports a problem' do
|
32
|
-
result = subject.lint(test_model)
|
33
|
-
|
34
|
-
expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'includes the number of characters found in the problem record' do
|
38
|
-
character_count = test_model.text.length
|
39
|
-
result = subject.lint(test_model)
|
40
|
-
expect(result[:problem]).to eq("Step is too long. #{character_count} characters found (max 80)")
|
41
|
-
|
42
|
-
test_model.text += 'x'
|
43
|
-
result = subject.lint(test_model)
|
44
|
-
expect(result[:problem]).to eq("Step is too long. #{character_count + 1} characters found (max 80)")
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'when the step is the maximum length' do
|
50
|
-
|
51
|
-
let(:test_model) do
|
52
|
-
step = 'x' * default_character_threshold
|
53
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
|
54
|
-
end
|
55
|
-
|
56
|
-
it_should_behave_like 'a linter linting a good model'
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when the step is below the maximum length' do
|
61
|
-
|
62
|
-
let(:test_model) do
|
63
|
-
step = 'x' * (default_character_threshold - 1)
|
64
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
|
65
|
-
end
|
66
|
-
|
67
|
-
it_should_behave_like 'a linter linting a good model'
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'when the step has no text' do
|
72
|
-
|
73
|
-
let(:test_model) do
|
74
|
-
model = CukeLinter::ModelFactory.generate_step_model
|
75
|
-
model.text = nil
|
76
|
-
|
77
|
-
model
|
78
|
-
end
|
79
|
-
|
80
|
-
it_should_behave_like 'a linter linting a good model'
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'a non-step model' do
|
85
|
-
|
86
|
-
let(:test_model) { CukeModeler::Model.new }
|
87
|
-
|
88
|
-
it_should_behave_like 'a linter linting a good model'
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
describe 'configuration' do
|
95
|
-
|
96
|
-
context 'with no configuration' do
|
97
|
-
|
98
|
-
let(:default_character_threshold) { 80 }
|
99
|
-
|
100
|
-
context 'because configuration never happened' do
|
101
|
-
|
102
|
-
let(:default_model) do
|
103
|
-
step = 'x' * (default_character_threshold + 1)
|
104
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'defaults to a maximum of 80 characters' do
|
108
|
-
result = subject.lint(default_model)
|
109
|
-
|
110
|
-
expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'because configuration did not set a step threshold' do
|
116
|
-
let(:configuration) { {} }
|
117
|
-
let(:configured_model) do
|
118
|
-
subject.configure(configuration)
|
119
|
-
step = 'x' * (default_character_threshold + 1)
|
120
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'defaults to a maximum of 80 characters' do
|
124
|
-
result = subject.lint(configured_model)
|
125
|
-
|
126
|
-
expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 80\)/)
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'when configured' do
|
134
|
-
let(:character_threshold) { 10 }
|
135
|
-
let(:configuration) { { 'StepLengthThreshold' => character_threshold } }
|
136
|
-
|
137
|
-
subject { linter = CukeLinter::StepWithTooManyCharactersLinter.new
|
138
|
-
linter.configure(configuration)
|
139
|
-
linter }
|
140
|
-
|
141
|
-
let(:test_model) do
|
142
|
-
step = 'x' * (character_threshold + 1)
|
143
|
-
CukeLinter::ModelFactory.generate_step_model(source_text: "* #{step}")
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'uses the maximum character length provided by configuration' do
|
147
|
-
result = subject.lint(test_model)
|
148
|
-
|
149
|
-
expect(result[:problem]).to match(/^Step is too long. \d+ characters found \(max 10\)/)
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
end
|
@@ -1,464 +0,0 @@
|
|
1
|
-
require_relative '../../../../../environments/rspec_env'
|
2
|
-
|
3
|
-
|
4
|
-
RSpec.describe CukeLinter::TestShouldUseBackgroundLinter 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('TestShouldUseBackgroundLinter')
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'linting' do
|
16
|
-
|
17
|
-
['scenario', 'outline'].each do |model_type|
|
18
|
-
|
19
|
-
context "with a #{model_type} that shares a first step with all other tests in the feature" do
|
20
|
-
|
21
|
-
let(:test_model) do
|
22
|
-
step_text = 'the step'
|
23
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
|
24
|
-
source_text: "Feature:
|
25
|
-
Scenario:
|
26
|
-
* #{step_text}
|
27
|
-
Scenario Outline:
|
28
|
-
* #{step_text}
|
29
|
-
Examples:
|
30
|
-
| param |
|
31
|
-
| value |")
|
32
|
-
|
33
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
34
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
35
|
-
|
36
|
-
model.parent_model = feature_model
|
37
|
-
feature_model.tests << model
|
38
|
-
|
39
|
-
model
|
40
|
-
end
|
41
|
-
|
42
|
-
it_should_behave_like 'a linter linting a bad model'
|
43
|
-
|
44
|
-
|
45
|
-
it 'records a problem' do
|
46
|
-
result = subject.lint(test_model)
|
47
|
-
|
48
|
-
expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'with parameters that are not really parameters' do
|
54
|
-
|
55
|
-
if (model_type == 'scenario')
|
56
|
-
|
57
|
-
# Scenarios don't actually have parameters, even if they look like they do
|
58
|
-
context 'because they are in scenarios' do
|
59
|
-
|
60
|
-
let(:test_model) do
|
61
|
-
step_text = 'the not really <parameterized> step'
|
62
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
|
63
|
-
source_text: "Feature:
|
64
|
-
Scenario:
|
65
|
-
* #{step_text}
|
66
|
-
Scenario:
|
67
|
-
* #{step_text}")
|
68
|
-
|
69
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
70
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
71
|
-
|
72
|
-
model.parent_model = feature_model
|
73
|
-
feature_model.tests << model
|
74
|
-
|
75
|
-
model
|
76
|
-
end
|
77
|
-
|
78
|
-
it_should_behave_like 'a linter linting a bad model'
|
79
|
-
|
80
|
-
|
81
|
-
it 'records a problem' do
|
82
|
-
result = subject.lint(test_model)
|
83
|
-
|
84
|
-
expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
if model_type == 'outline'
|
93
|
-
|
94
|
-
context 'because of extra whitespace' do
|
95
|
-
|
96
|
-
let(:test_model) do
|
97
|
-
# Whitespace is significant
|
98
|
-
step_text = "the step < param_foo >"
|
99
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(parent_file_path: model_file_path,
|
100
|
-
source_text: "Feature:
|
101
|
-
Scenario Outline:
|
102
|
-
* #{step_text}
|
103
|
-
Examples:
|
104
|
-
| param_foo |
|
105
|
-
| value |
|
106
|
-
Scenario Outline:
|
107
|
-
* #{step_text}
|
108
|
-
Examples:
|
109
|
-
| param_foo |
|
110
|
-
| value |")
|
111
|
-
|
112
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
113
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
114
|
-
|
115
|
-
model.parent_model = feature_model
|
116
|
-
feature_model.tests << model
|
117
|
-
|
118
|
-
model
|
119
|
-
end
|
120
|
-
|
121
|
-
it_should_behave_like 'a linter linting a bad model'
|
122
|
-
|
123
|
-
|
124
|
-
it 'records a problem' do
|
125
|
-
result = subject.lint(test_model)
|
126
|
-
|
127
|
-
expect(result[:problem]).to eq('Test shares steps with all other tests in feature. Use a background.')
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
|
137
|
-
context "with a #{model_type} that does not share a first step with all other tests in the feature" do
|
138
|
-
|
139
|
-
context 'because the steps are different' do
|
140
|
-
|
141
|
-
let(:test_model) do
|
142
|
-
step_text = 'the step'
|
143
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
144
|
-
Scenario:
|
145
|
-
* #{step_text}
|
146
|
-
Scenario Outline:
|
147
|
-
* #{step_text}
|
148
|
-
Examples:
|
149
|
-
| param |
|
150
|
-
| value |")
|
151
|
-
|
152
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
153
|
-
model.steps = [CukeModeler::Step.new("* #{step_text} plus extra")]
|
154
|
-
|
155
|
-
model.parent_model = feature_model
|
156
|
-
feature_model.tests << model
|
157
|
-
|
158
|
-
model
|
159
|
-
end
|
160
|
-
|
161
|
-
it_should_behave_like 'a linter linting a good model'
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
context 'because it has no steps' do
|
166
|
-
|
167
|
-
context 'because its steps are empty' do
|
168
|
-
|
169
|
-
let(:test_model) do
|
170
|
-
step_text = 'the step'
|
171
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
172
|
-
Scenario:
|
173
|
-
* #{step_text}
|
174
|
-
Scenario Outline:
|
175
|
-
* #{step_text}
|
176
|
-
Examples:
|
177
|
-
| param |
|
178
|
-
| value |")
|
179
|
-
|
180
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
181
|
-
model.steps = []
|
182
|
-
|
183
|
-
model.parent_model = feature_model
|
184
|
-
feature_model.tests << model
|
185
|
-
|
186
|
-
model
|
187
|
-
end
|
188
|
-
|
189
|
-
it_should_behave_like 'a linter linting a good model'
|
190
|
-
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'because its steps are nil' do
|
194
|
-
|
195
|
-
let(:test_model) do
|
196
|
-
step_text = 'the step'
|
197
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
198
|
-
Scenario:
|
199
|
-
* #{step_text}
|
200
|
-
Scenario Outline:
|
201
|
-
* #{step_text}
|
202
|
-
Examples:
|
203
|
-
| param |
|
204
|
-
| value |")
|
205
|
-
|
206
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
207
|
-
model.steps = nil
|
208
|
-
|
209
|
-
model.parent_model = feature_model
|
210
|
-
feature_model.tests << model
|
211
|
-
|
212
|
-
model
|
213
|
-
end
|
214
|
-
|
215
|
-
it_should_behave_like 'a linter linting a good model'
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
context 'because another test has no steps' do
|
222
|
-
|
223
|
-
context 'because its steps are empty' do
|
224
|
-
|
225
|
-
let(:test_model) do
|
226
|
-
step_text = 'the step'
|
227
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
228
|
-
Scenario:
|
229
|
-
* #{step_text}
|
230
|
-
Scenario Outline:
|
231
|
-
* #{step_text}
|
232
|
-
Examples:
|
233
|
-
| param |
|
234
|
-
| value |")
|
235
|
-
|
236
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
237
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
238
|
-
|
239
|
-
model.parent_model = feature_model
|
240
|
-
feature_model.tests.first.steps = []
|
241
|
-
feature_model.tests << model
|
242
|
-
|
243
|
-
model
|
244
|
-
end
|
245
|
-
|
246
|
-
it_should_behave_like 'a linter linting a good model'
|
247
|
-
|
248
|
-
end
|
249
|
-
|
250
|
-
context 'because its steps are nil' do
|
251
|
-
|
252
|
-
let(:test_model) do
|
253
|
-
step_text = 'the step'
|
254
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
255
|
-
Scenario:
|
256
|
-
* #{step_text}
|
257
|
-
Scenario Outline:
|
258
|
-
* #{step_text}
|
259
|
-
Examples:
|
260
|
-
| param |
|
261
|
-
| value |")
|
262
|
-
|
263
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
264
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
265
|
-
|
266
|
-
model.parent_model = feature_model
|
267
|
-
feature_model.tests.first.steps = nil
|
268
|
-
feature_model.tests << model
|
269
|
-
|
270
|
-
model
|
271
|
-
end
|
272
|
-
|
273
|
-
it_should_behave_like 'a linter linting a good model'
|
274
|
-
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
context 'because there are not other tests in the feature' do
|
280
|
-
|
281
|
-
let(:test_model) do
|
282
|
-
step_text = 'the step'
|
283
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: 'Feature:')
|
284
|
-
|
285
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
286
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
287
|
-
|
288
|
-
model.parent_model = feature_model
|
289
|
-
feature_model.tests << model
|
290
|
-
|
291
|
-
model
|
292
|
-
end
|
293
|
-
|
294
|
-
it_should_behave_like 'a linter linting a good model'
|
295
|
-
|
296
|
-
end
|
297
|
-
|
298
|
-
context 'because its first step contains a parameter' do
|
299
|
-
|
300
|
-
let(:test_model) do
|
301
|
-
step_text = 'the maybe <parameterized> step'
|
302
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
303
|
-
Scenario:
|
304
|
-
* #{step_text}
|
305
|
-
Scenario Outline:
|
306
|
-
* #{step_text}
|
307
|
-
Examples:
|
308
|
-
| parameterized |
|
309
|
-
| value |")
|
310
|
-
|
311
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
312
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
313
|
-
|
314
|
-
model.parent_model = feature_model
|
315
|
-
feature_model.tests << model
|
316
|
-
|
317
|
-
model
|
318
|
-
end
|
319
|
-
|
320
|
-
it_should_behave_like 'a linter linting a good model'
|
321
|
-
|
322
|
-
if model_type == 'outline'
|
323
|
-
|
324
|
-
context 'even with a bunch of parameterized outlines' do
|
325
|
-
|
326
|
-
context 'with a parameter in the text of the step' do
|
327
|
-
|
328
|
-
let(:test_model) do
|
329
|
-
step_text = 'the <parameterized> step'
|
330
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
331
|
-
Scenario Outline:
|
332
|
-
* #{step_text}
|
333
|
-
Examples:
|
334
|
-
| parameterized |
|
335
|
-
| value |
|
336
|
-
Scenario Outline:
|
337
|
-
* #{step_text}
|
338
|
-
Examples:
|
339
|
-
| parameterized |
|
340
|
-
| value |")
|
341
|
-
|
342
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
343
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
344
|
-
|
345
|
-
model.parent_model = feature_model
|
346
|
-
feature_model.tests << model
|
347
|
-
|
348
|
-
model
|
349
|
-
end
|
350
|
-
|
351
|
-
it_should_behave_like 'a linter linting a good model'
|
352
|
-
|
353
|
-
end
|
354
|
-
|
355
|
-
context 'with a parameter in the table of the step' do
|
356
|
-
|
357
|
-
let(:test_model) do
|
358
|
-
step_text = "the step\n | <param_foo> |"
|
359
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
360
|
-
Scenario Outline:
|
361
|
-
* #{step_text}
|
362
|
-
Examples:
|
363
|
-
| param_foo |
|
364
|
-
| value |
|
365
|
-
Scenario Outline:
|
366
|
-
* #{step_text}
|
367
|
-
Examples:
|
368
|
-
| param_foo |
|
369
|
-
| value |")
|
370
|
-
|
371
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
372
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
373
|
-
|
374
|
-
model.parent_model = feature_model
|
375
|
-
feature_model.tests << model
|
376
|
-
|
377
|
-
model
|
378
|
-
end
|
379
|
-
|
380
|
-
it_should_behave_like 'a linter linting a good model'
|
381
|
-
|
382
|
-
end
|
383
|
-
|
384
|
-
context 'with a parameter in the doc string of the step' do
|
385
|
-
|
386
|
-
let(:test_model) do
|
387
|
-
step_text = "the step\n \"\"\"\n <param_foo>\n \"\"\""
|
388
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
389
|
-
Scenario Outline:
|
390
|
-
* #{step_text}
|
391
|
-
Examples:
|
392
|
-
| param_foo |
|
393
|
-
| value |
|
394
|
-
Scenario Outline:
|
395
|
-
* #{step_text}
|
396
|
-
Examples:
|
397
|
-
| param_foo |
|
398
|
-
| value |")
|
399
|
-
|
400
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
401
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
402
|
-
|
403
|
-
model.parent_model = feature_model
|
404
|
-
feature_model.tests << model
|
405
|
-
|
406
|
-
model
|
407
|
-
end
|
408
|
-
|
409
|
-
it_should_behave_like 'a linter linting a good model'
|
410
|
-
|
411
|
-
end
|
412
|
-
|
413
|
-
context 'with inconsistent parameter usage' do
|
414
|
-
|
415
|
-
let(:test_model) do
|
416
|
-
step_text = "the step <param_foo>"
|
417
|
-
feature_model = CukeLinter::ModelFactory.generate_feature_model(source_text: "Feature:
|
418
|
-
Scenario Outline:
|
419
|
-
* #{step_text}
|
420
|
-
Examples:
|
421
|
-
| param_foo |
|
422
|
-
| value |
|
423
|
-
Scenario Outline:
|
424
|
-
* #{step_text}
|
425
|
-
Examples:
|
426
|
-
| param_bar |
|
427
|
-
| value |
|
428
|
-
Examples:
|
429
|
-
| param_foo |
|
430
|
-
| value |")
|
431
|
-
|
432
|
-
model = CukeLinter::ModelFactory.send("generate_#{model_type}_model")
|
433
|
-
model.steps = [CukeModeler::Step.new("* #{step_text}")]
|
434
|
-
|
435
|
-
model.parent_model = feature_model
|
436
|
-
feature_model.tests << model
|
437
|
-
|
438
|
-
model
|
439
|
-
end
|
440
|
-
|
441
|
-
it_should_behave_like 'a linter linting a good model'
|
442
|
-
|
443
|
-
end
|
444
|
-
|
445
|
-
# TODO: do outline parameters even get substituted in the doc string type?
|
446
|
-
end
|
447
|
-
|
448
|
-
end
|
449
|
-
|
450
|
-
end
|
451
|
-
|
452
|
-
end
|
453
|
-
|
454
|
-
end
|
455
|
-
|
456
|
-
context 'a non-test model' do
|
457
|
-
|
458
|
-
let(:test_model) { CukeModeler::Model.new }
|
459
|
-
|
460
|
-
it_should_behave_like 'a linter linting a good model'
|
461
|
-
|
462
|
-
end
|
463
|
-
end
|
464
|
-
end
|