cuke_linter 0.9.0 → 0.10.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 +17 -1
- data/CONTRIBUTING.md +26 -0
- data/README.md +2 -15
- data/lib/cuke_linter.rb +36 -18
- data/lib/cuke_linter/linters/example_without_name_linter.rb +1 -1
- data/lib/cuke_linter/linters/feature_with_too_many_different_tags_linter.rb +38 -0
- data/lib/cuke_linter/linters/test_should_use_background_linter.rb +28 -0
- data/lib/cuke_linter/linters/test_with_action_step_as_final_step_linter.rb +23 -0
- data/lib/cuke_linter/linters/test_with_setup_step_after_action_step_linter.rb +31 -0
- data/lib/cuke_linter/linters/test_with_setup_step_after_verification_step_linter.rb +31 -0
- data/lib/cuke_linter/linters/test_with_setup_step_as_final_step_linter.rb +23 -0
- data/lib/cuke_linter/version.rb +1 -1
- data/testing/cucumber/features/default_linters.feature +20 -14
- data/testing/cucumber/features/linters/example_without_name.feature +8 -6
- data/testing/cucumber/features/linters/feature_with_too_many_different_tags.feature +56 -0
- data/testing/cucumber/features/linters/step_with_end_period.feature +1 -1
- data/testing/cucumber/features/linters/test_should_use_background.feature +29 -0
- data/testing/cucumber/features/linters/test_with_action_as_final_step.feature +28 -0
- data/testing/cucumber/features/linters/test_with_setup_step_after_action_step.feature +30 -0
- data/testing/cucumber/features/linters/test_with_setup_step_after_verification_step.feature +30 -0
- data/testing/cucumber/features/linters/test_with_setup_step_as_final_step.feature +28 -0
- data/testing/cucumber/features/linters/test_with_too_many_steps.feature +5 -0
- data/testing/cucumber/step_definitions/setup_steps.rb +28 -0
- data/testing/model_factory.rb +1 -1
- data/testing/rspec/spec/integration/cuke_linter_integration_spec.rb +12 -0
- data/testing/rspec/spec/integration/linters/feature_with_too_many_different_tags_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_should_use_background_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_action_step_as_final_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_action_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_after_verification_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/integration/linters/test_with_setup_step_as_final_step_linter_integration_spec.rb +8 -0
- data/testing/rspec/spec/unit/linters/background_does_more_than_setup_linter_unit_spec.rb +20 -57
- data/testing/rspec/spec/unit/linters/element_with_too_many_tags_linter_unit_spec.rb +18 -52
- data/testing/rspec/spec/unit/linters/example_without_name_linter_unit_spec.rb +41 -43
- data/testing/rspec/spec/unit/linters/feature_with_too_many_different_tags_linter_unit_spec.rb +293 -0
- data/testing/rspec/spec/unit/linters/feature_without_description_linter_unit_spec.rb +25 -42
- data/testing/rspec/spec/unit/linters/feature_without_name_linter_unit_spec.rb +10 -38
- data/testing/rspec/spec/unit/linters/feature_without_scenarios_linter_unit_spec.rb +32 -52
- data/testing/rspec/spec/unit/linters/linter_unit_spec.rb +27 -10
- data/testing/rspec/spec/unit/linters/linter_unit_specs.rb +26 -12
- data/testing/rspec/spec/unit/linters/outline_with_single_example_row_linter_unit_spec.rb +19 -66
- data/testing/rspec/spec/unit/linters/single_test_background_linter_unit_spec.rb +12 -39
- data/testing/rspec/spec/unit/linters/step_with_end_period_linter_unit_spec.rb +9 -28
- data/testing/rspec/spec/unit/linters/step_with_too_many_characters_linter_unit_spec.rb +19 -45
- data/testing/rspec/spec/unit/linters/test_should_use_background_linter_unit_spec.rb +226 -0
- data/testing/rspec/spec/unit/linters/test_with_action_step_as_final_step_linter_unit_spec.rb +98 -0
- data/testing/rspec/spec/unit/linters/test_with_no_action_step_linter_unit_spec.rb +10 -51
- data/testing/rspec/spec/unit/linters/test_with_no_name_linter_unit_spec.rb +11 -38
- data/testing/rspec/spec/unit/linters/test_with_no_verification_step_linter_unit_spec.rb +16 -54
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_action_step_linter_unit_spec.rb +124 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_after_verification_step_linter_unit_spec.rb +125 -0
- data/testing/rspec/spec/unit/linters/test_with_setup_step_as_final_step_linter_unit_spec.rb +98 -0
- data/testing/rspec/spec/unit/linters/test_with_too_many_steps_linter_unit_spec.rb +9 -49
- metadata +27 -2
@@ -0,0 +1,56 @@
|
|
1
|
+
Feature: Feature with too many different tags linter
|
2
|
+
|
3
|
+
As a writer of documentation
|
4
|
+
I want features to not contain too many different tags
|
5
|
+
So that readers do not need to know too many different contexts
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
Given a linter for features with too many different tags
|
10
|
+
And the following feature:
|
11
|
+
"""
|
12
|
+
# Total tag count doesn't matter. The count of unique tags is what matters.
|
13
|
+
@tag_A @tag_A @tag_A @tag_A
|
14
|
+
Feature:
|
15
|
+
|
16
|
+
@tag_B @tag_C
|
17
|
+
Scenario:
|
18
|
+
* a step
|
19
|
+
|
20
|
+
@tag_D @tag_E @tag_F @tag_G
|
21
|
+
Scenario:
|
22
|
+
* a step
|
23
|
+
|
24
|
+
@tag_H @tag_I @tag_J
|
25
|
+
Scenario:
|
26
|
+
* a step
|
27
|
+
|
28
|
+
@K
|
29
|
+
Scenario:
|
30
|
+
* a step
|
31
|
+
"""
|
32
|
+
When it is linted
|
33
|
+
Then an error is reported:
|
34
|
+
| linter | problem | location |
|
35
|
+
| FeatureWithTooManyDifferentTagsLinter | Feature contains too many different tags. 11 tags found (max 10). | <path_to_file>:3 |
|
36
|
+
|
37
|
+
Scenario: Configuration of tag count threshold
|
38
|
+
Given a linter for features with too many different tags has been registered
|
39
|
+
And the following configuration file:
|
40
|
+
"""
|
41
|
+
FeatureWithTooManyDifferentTagsLinter:
|
42
|
+
TagCountThreshold: 2
|
43
|
+
"""
|
44
|
+
And the following feature:
|
45
|
+
"""
|
46
|
+
@tag_A @tag_B @tag_C
|
47
|
+
Feature:
|
48
|
+
|
49
|
+
Scenario:
|
50
|
+
* a step
|
51
|
+
"""
|
52
|
+
When the configuration file is loaded
|
53
|
+
And it is linted
|
54
|
+
Then an error is reported:
|
55
|
+
| linter | problem | location |
|
56
|
+
| FeatureWithTooManyDifferentTagsLinter | Feature contains too many different tags. 3 tags found (max 2). | <path_to_file>:2 |
|
@@ -2,7 +2,7 @@ Feature: Step that ends with a period linter
|
|
2
2
|
|
3
3
|
As a writer of documentation
|
4
4
|
I want to avoid periods at the end of steps
|
5
|
-
So that readability is not impacted when
|
5
|
+
So that readability is not impacted when the steps are used in other contexts
|
6
6
|
|
7
7
|
|
8
8
|
Scenario: Linting
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: Test should use background linter
|
2
|
+
|
3
|
+
As a writer of documentation
|
4
|
+
I want to know if I am including the same steps in every use case
|
5
|
+
So that I can use a background to make it clear that a common context exists
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
|
10
|
+
Note: Also works on outlines.
|
11
|
+
|
12
|
+
Given a linter for tests that should use a background
|
13
|
+
And the following feature:
|
14
|
+
"""
|
15
|
+
Feature:
|
16
|
+
|
17
|
+
Scenario:
|
18
|
+
* a common step
|
19
|
+
* a different step
|
20
|
+
|
21
|
+
Scenario:
|
22
|
+
* a common step
|
23
|
+
* a more different step
|
24
|
+
"""
|
25
|
+
When it is linted
|
26
|
+
Then an error is reported:
|
27
|
+
| linter | problem | location |
|
28
|
+
| TestShouldUseBackgroundLinter | Test shares steps with all other tests in feature. Use a background. | <path_to_file>:3 |
|
29
|
+
| TestShouldUseBackgroundLinter | Test shares steps with all other tests in feature. Use a background. | <path_to_file>:7 |
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Test with action step as final step linter
|
2
|
+
|
3
|
+
As a tester
|
4
|
+
I want to be warned about abnormal step flows
|
5
|
+
So that the tests make sense
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
|
10
|
+
Note: Also works on outlines.
|
11
|
+
|
12
|
+
Given a linter for tests with an action step as the final step
|
13
|
+
And the following feature:
|
14
|
+
"""
|
15
|
+
Feature:
|
16
|
+
|
17
|
+
Scenario: Action as final step
|
18
|
+
When the last step
|
19
|
+
"""
|
20
|
+
When it is linted
|
21
|
+
Then an error is reported:
|
22
|
+
| linter | problem | location |
|
23
|
+
| TestWithActionStepAsFinalStepLinter | Test has 'When' as the final step. | <path_to_file>:3 |
|
24
|
+
|
25
|
+
@wip
|
26
|
+
Scenario: Configuration
|
27
|
+
|
28
|
+
Configure the keyword(s) that count as action steps?
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Test with setup step after action step linter
|
2
|
+
|
3
|
+
As a tester
|
4
|
+
I want to be warned about abnormal step flows
|
5
|
+
So that the tests make sense
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
|
10
|
+
Note: Also works on outlines. Does not include steps inherited from backgrounds.
|
11
|
+
|
12
|
+
Given a linter for tests with a setup step after an action step
|
13
|
+
And the following feature:
|
14
|
+
"""
|
15
|
+
Feature:
|
16
|
+
|
17
|
+
Scenario:
|
18
|
+
When action step
|
19
|
+
Given an out of place setup step
|
20
|
+
"""
|
21
|
+
When it is linted
|
22
|
+
Then an error is reported:
|
23
|
+
| linter | problem | location |
|
24
|
+
| TestWithSetupStepAfterActionStepLinter | Test has 'Given' step after 'When' step. | <path_to_file>:3 |
|
25
|
+
|
26
|
+
@wip
|
27
|
+
Scenario: Configuration
|
28
|
+
|
29
|
+
Configure the keyword(s) that count as setup/action/verification steps?
|
30
|
+
Configure whether or not to include background steps?
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Feature: Test with setup step after verification step linter
|
2
|
+
|
3
|
+
As a tester
|
4
|
+
I want to be warned about abnormal step flows
|
5
|
+
So that the tests make sense
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
|
10
|
+
Note: Also works on outlines. Does not include steps inherited from backgrounds.
|
11
|
+
|
12
|
+
Given a linter for tests with a setup step after a verification step
|
13
|
+
And the following feature:
|
14
|
+
"""
|
15
|
+
Feature:
|
16
|
+
|
17
|
+
Scenario:
|
18
|
+
Then verification step
|
19
|
+
Given an out of place setup step
|
20
|
+
"""
|
21
|
+
When it is linted
|
22
|
+
Then an error is reported:
|
23
|
+
| linter | problem | location |
|
24
|
+
| TestWithSetupStepAfterVerificationStepLinter | Test has 'Given' step after 'Then' step. | <path_to_file>:3 |
|
25
|
+
|
26
|
+
@wip
|
27
|
+
Scenario: Configuration
|
28
|
+
|
29
|
+
Configure the keyword(s) that count as verification steps?
|
30
|
+
Configure whether or not to include background steps?
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Feature: Test with setup step as final step linter
|
2
|
+
|
3
|
+
As a tester
|
4
|
+
I want to be warned about abnormal step flows
|
5
|
+
So that the tests make sense
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Linting
|
9
|
+
|
10
|
+
Note: Also works on outlines.
|
11
|
+
|
12
|
+
Given a linter for tests with a setup step as the final step
|
13
|
+
And the following feature:
|
14
|
+
"""
|
15
|
+
Feature:
|
16
|
+
|
17
|
+
Scenario:
|
18
|
+
Given the last step
|
19
|
+
"""
|
20
|
+
When it is linted
|
21
|
+
Then an error is reported:
|
22
|
+
| linter | problem | location |
|
23
|
+
| TestWithSetupStepAsFinalStepLinter | Test has 'Given' as the final step. | <path_to_file>:3 |
|
24
|
+
|
25
|
+
@wip
|
26
|
+
Scenario: Configuration
|
27
|
+
|
28
|
+
Configure the keyword(s) that count as setup steps?
|
@@ -54,3 +54,8 @@ Feature: Test with too many steps linter
|
|
54
54
|
Then an error is reported:
|
55
55
|
| linter | problem | location |
|
56
56
|
| TestWithTooManyStepsLinter | Test has too many steps. 4 steps found (max 3). | <path_to_file>:3 |
|
57
|
+
|
58
|
+
@wip
|
59
|
+
Scenario: Configuration
|
60
|
+
|
61
|
+
Ideas: Configure whether or not the linter includes steps from backgrounds
|
@@ -73,6 +73,10 @@ Given(/^a linter for elements with too many tags$/) do
|
|
73
73
|
@linter = CukeLinter::ElementWithTooManyTagsLinter.new
|
74
74
|
end
|
75
75
|
|
76
|
+
Given(/^a linter for features with too many different tags$/) do
|
77
|
+
@linter = CukeLinter::FeatureWithTooManyDifferentTagsLinter.new
|
78
|
+
end
|
79
|
+
|
76
80
|
Given(/^a linter for elements with too many tags has been registered$/) do
|
77
81
|
CukeLinter.register_linter(linter: CukeLinter::ElementWithTooManyTagsLinter.new, name: 'ElementWithTooManyTagsLinter')
|
78
82
|
end
|
@@ -89,10 +93,34 @@ Given(/^a linter for tests with no name$/) do
|
|
89
93
|
@linter = CukeLinter::TestWithNoNameLinter.new
|
90
94
|
end
|
91
95
|
|
96
|
+
Given(/^a linter for tests that should use a background$/) do
|
97
|
+
@linter = CukeLinter::TestShouldUseBackgroundLinter.new
|
98
|
+
end
|
99
|
+
|
100
|
+
Given(/^a linter for tests with a setup step after an action step$/) do
|
101
|
+
@linter = CukeLinter::TestWithSetupStepAfterActionStepLinter.new
|
102
|
+
end
|
103
|
+
|
104
|
+
Given(/^a linter for tests with a setup step after a verification step$/) do
|
105
|
+
@linter = CukeLinter::TestWithSetupStepAfterVerificationStepLinter.new
|
106
|
+
end
|
107
|
+
|
108
|
+
Given(/^a linter for tests with a setup step as the final step$/) do
|
109
|
+
@linter = CukeLinter::TestWithSetupStepAsFinalStepLinter.new
|
110
|
+
end
|
111
|
+
|
112
|
+
Given(/^a linter for tests with an action step as the final step$/) do
|
113
|
+
@linter = CukeLinter::TestWithActionStepAsFinalStepLinter.new
|
114
|
+
end
|
115
|
+
|
92
116
|
Given(/^a linter for test steps with too many characters has been registered$/) do
|
93
117
|
CukeLinter.register_linter(linter: CukeLinter::StepWithTooManyCharactersLinter.new, name: 'StepWithTooManyCharactersLinter')
|
94
118
|
end
|
95
119
|
|
120
|
+
Given(/^a linter for features with too many different tags has been registered$/) do
|
121
|
+
CukeLinter.register_linter(linter: CukeLinter::FeatureWithTooManyDifferentTagsLinter.new, name: 'FeatureWithTooManyDifferentTagsLinter')
|
122
|
+
end
|
123
|
+
|
96
124
|
Given(/^the following configuration file(?: "([^"]*)")?:$/) do |file_name, text|
|
97
125
|
file_name ||= '.cuke_linter'
|
98
126
|
|
data/testing/model_factory.rb
CHANGED
@@ -72,7 +72,7 @@ module CukeLinter
|
|
72
72
|
model
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.generate_lintable_model(parent_file_path: 'path_to_file', source_line:
|
75
|
+
def self.generate_lintable_model(parent_file_path: 'path_to_file', source_line: 1, children: [])
|
76
76
|
fake_file_model = CukeModeler::FeatureFile.new
|
77
77
|
fake_file_model.path = parent_file_path
|
78
78
|
|
@@ -180,6 +180,8 @@ RSpec.describe CukeLinter do
|
|
180
180
|
expect(subject.registered_linters['ElementWithTooManyTagsLinter']).to be_a(CukeLinter::ElementWithTooManyTagsLinter)
|
181
181
|
expect(subject.registered_linters.keys).to include('ExampleWithoutNameLinter')
|
182
182
|
expect(subject.registered_linters['ExampleWithoutNameLinter']).to be_a(CukeLinter::ExampleWithoutNameLinter)
|
183
|
+
expect(subject.registered_linters.keys).to include('FeatureWithTooManyDifferentTagsLinter')
|
184
|
+
expect(subject.registered_linters['FeatureWithTooManyDifferentTagsLinter']).to be_a(CukeLinter::FeatureWithTooManyDifferentTagsLinter)
|
183
185
|
expect(subject.registered_linters.keys).to include('FeatureWithoutDescriptionLinter')
|
184
186
|
expect(subject.registered_linters['FeatureWithoutDescriptionLinter']).to be_a(CukeLinter::FeatureWithoutDescriptionLinter)
|
185
187
|
expect(subject.registered_linters.keys).to include('FeatureWithoutNameLinter')
|
@@ -194,12 +196,22 @@ RSpec.describe CukeLinter do
|
|
194
196
|
expect(subject.registered_linters['StepWithEndPeriodLinter']).to be_a(CukeLinter::StepWithEndPeriodLinter)
|
195
197
|
expect(subject.registered_linters.keys).to include('StepWithTooManyCharactersLinter')
|
196
198
|
expect(subject.registered_linters['StepWithTooManyCharactersLinter']).to be_a(CukeLinter::StepWithTooManyCharactersLinter)
|
199
|
+
expect(subject.registered_linters.keys).to include('TestShouldUseBackgroundLinter')
|
200
|
+
expect(subject.registered_linters['TestShouldUseBackgroundLinter']).to be_a(CukeLinter::TestShouldUseBackgroundLinter)
|
201
|
+
expect(subject.registered_linters.keys).to include('TestWithActionStepAsFinalStepLinter')
|
202
|
+
expect(subject.registered_linters['TestWithActionStepAsFinalStepLinter']).to be_a(CukeLinter::TestWithActionStepAsFinalStepLinter)
|
197
203
|
expect(subject.registered_linters.keys).to include('TestWithNoActionStepLinter')
|
198
204
|
expect(subject.registered_linters['TestWithNoActionStepLinter']).to be_a(CukeLinter::TestWithNoActionStepLinter)
|
199
205
|
expect(subject.registered_linters.keys).to include('TestWithNoNameLinter')
|
200
206
|
expect(subject.registered_linters['TestWithNoNameLinter']).to be_a(CukeLinter::TestWithNoNameLinter)
|
201
207
|
expect(subject.registered_linters.keys).to include('TestWithNoVerificationStepLinter')
|
202
208
|
expect(subject.registered_linters['TestWithNoVerificationStepLinter']).to be_a(CukeLinter::TestWithNoVerificationStepLinter)
|
209
|
+
expect(subject.registered_linters.keys).to include('TestWithSetupStepAfterActionStepLinter')
|
210
|
+
expect(subject.registered_linters['TestWithSetupStepAfterActionStepLinter']).to be_a(CukeLinter::TestWithSetupStepAfterActionStepLinter)
|
211
|
+
expect(subject.registered_linters.keys).to include('TestWithSetupStepAfterVerificationStepLinter')
|
212
|
+
expect(subject.registered_linters['TestWithSetupStepAfterVerificationStepLinter']).to be_a(CukeLinter::TestWithSetupStepAfterVerificationStepLinter)
|
213
|
+
expect(subject.registered_linters.keys).to include('TestWithSetupStepAsFinalStepLinter')
|
214
|
+
expect(subject.registered_linters['TestWithSetupStepAsFinalStepLinter']).to be_a(CukeLinter::TestWithSetupStepAsFinalStepLinter)
|
203
215
|
expect(subject.registered_linters.keys).to include('TestWithTooManyStepsLinter')
|
204
216
|
expect(subject.registered_linters['TestWithTooManyStepsLinter']).to be_a(CukeLinter::TestWithTooManyStepsLinter)
|
205
217
|
end
|
@@ -3,16 +3,7 @@ require_relative '../../../../../environments/rspec_env'
|
|
3
3
|
|
4
4
|
RSpec.describe CukeLinter::BackgroundDoesMoreThanSetupLinter do
|
5
5
|
|
6
|
-
let(:
|
7
|
-
CukeLinter::ModelFactory.generate_background_model(source_text: 'Background:
|
8
|
-
Given something')
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:bad_data) do
|
12
|
-
CukeLinter::ModelFactory.generate_background_model(source_text: 'Background:
|
13
|
-
When something')
|
14
|
-
end
|
15
|
-
|
6
|
+
let(:model_file_path) { 'some_file_path' }
|
16
7
|
|
17
8
|
it_should_behave_like 'a linter at the unit level'
|
18
9
|
|
@@ -26,88 +17,60 @@ RSpec.describe CukeLinter::BackgroundDoesMoreThanSetupLinter do
|
|
26
17
|
context 'a background with action steps' do
|
27
18
|
|
28
19
|
let(:test_model) do
|
29
|
-
CukeLinter::ModelFactory.generate_background_model(
|
30
|
-
|
20
|
+
CukeLinter::ModelFactory.generate_background_model(parent_file_path: model_file_path,
|
21
|
+
source_text: 'Background:
|
22
|
+
When something')
|
31
23
|
end
|
32
24
|
|
25
|
+
it_should_behave_like 'a linter linting a bad model'
|
26
|
+
|
27
|
+
|
33
28
|
it 'records a problem' do
|
34
29
|
result = subject.lint(test_model)
|
35
30
|
|
36
31
|
expect(result[:problem]).to eq('Background has non-setup steps')
|
37
32
|
end
|
38
33
|
|
39
|
-
it 'records the location of the problem' do
|
40
|
-
model = CukeLinter::ModelFactory.generate_background_model(parent_file_path: 'path_to_file',
|
41
|
-
source_text: 'Background:
|
42
|
-
When something')
|
43
|
-
|
44
|
-
model.source_line = 1
|
45
|
-
result = subject.lint(model)
|
46
|
-
expect(result[:location]).to eq('path_to_file:1')
|
47
|
-
|
48
|
-
model.source_line = 3
|
49
|
-
result = subject.lint(model)
|
50
|
-
expect(result[:location]).to eq('path_to_file:3')
|
51
|
-
end
|
52
|
-
|
53
34
|
end
|
54
35
|
|
55
36
|
context 'a background with verification steps' do
|
56
37
|
|
57
38
|
let(:test_model) do
|
58
|
-
CukeLinter::ModelFactory.generate_background_model(
|
59
|
-
|
39
|
+
CukeLinter::ModelFactory.generate_background_model(parent_file_path: model_file_path,
|
40
|
+
source_text: 'Background:
|
41
|
+
Then something')
|
60
42
|
end
|
61
43
|
|
44
|
+
it_should_behave_like 'a linter linting a bad model'
|
45
|
+
|
46
|
+
|
62
47
|
it 'records a problem' do
|
63
48
|
result = subject.lint(test_model)
|
64
49
|
|
65
50
|
expect(result[:problem]).to eq('Background has non-setup steps')
|
66
51
|
end
|
67
52
|
|
68
|
-
it 'records the location of the problem' do
|
69
|
-
model = CukeLinter::ModelFactory.generate_background_model(parent_file_path: 'path_to_file',
|
70
|
-
source_text: 'Background:
|
71
|
-
Then something')
|
72
|
-
|
73
|
-
model.source_line = 1
|
74
|
-
result = subject.lint(model)
|
75
|
-
expect(result[:location]).to eq('path_to_file:1')
|
76
|
-
|
77
|
-
model.source_line = 3
|
78
|
-
result = subject.lint(model)
|
79
|
-
expect(result[:location]).to eq('path_to_file:3')
|
80
|
-
end
|
81
|
-
|
82
53
|
end
|
83
54
|
|
84
55
|
context 'a background with only setup steps' do
|
85
56
|
|
86
|
-
|
87
|
-
|
88
|
-
let(:test_model) do
|
89
|
-
gherkin = 'Background:
|
57
|
+
let(:test_model) do
|
58
|
+
gherkin = 'Background:
|
90
59
|
Given something
|
91
60
|
* (plus something)'
|
92
61
|
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'does not record a problem' do
|
97
|
-
expect(subject.lint(test_model)).to eq(nil)
|
98
|
-
end
|
99
|
-
|
62
|
+
CukeLinter::ModelFactory.generate_background_model(source_text: gherkin)
|
100
63
|
end
|
101
64
|
|
65
|
+
it_should_behave_like 'a linter linting a good model'
|
66
|
+
|
102
67
|
end
|
103
68
|
|
104
69
|
context 'a non-background model' do
|
105
70
|
|
106
|
-
|
107
|
-
result = subject.lint(CukeModeler::Model.new)
|
71
|
+
let(:test_model) { CukeModeler::Model.new }
|
108
72
|
|
109
|
-
|
110
|
-
end
|
73
|
+
it_should_behave_like 'a linter linting a good model'
|
111
74
|
|
112
75
|
end
|
113
76
|
end
|