cucumber_lint 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/features/cucumber_lint/consistent_empty_lines/between_description_and_element.feature +68 -0
- data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_docstring.feature +3 -1
- data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_examples.feature +3 -1
- data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_step.feature +3 -1
- data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_table.feature +3 -1
- data/features/cucumber_lint/consistent_empty_lines/between_feature_and_description.feature +3 -1
- data/features/cucumber_lint/consistent_empty_lines/{between_feature_and_scenario.feature → between_feature_and_element.feature} +4 -2
- data/features/cucumber_lint/consistent_table_headers/examples_table.feature +6 -2
- data/features/cucumber_lint/consistent_table_headers/step_table.feature +6 -2
- data/features/cucumber_lint/consistent_table_headers/unsupported_style.feature +3 -1
- data/features/step_definitions/cli_steps.rb +11 -5
- data/lib/cucumber_lint/linter/feature_empty_lines_linter.rb +19 -21
- data/lib/cucumber_lint/version.rb +1 -1
- metadata +3 -3
- data/features/cucumber_lint/consistent_empty_lines/between_description_and_scenario.feature +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c51a359d3dfd56d9e66c83eea181c6df770d78
|
4
|
+
data.tar.gz: 980e0c5a5cd2be86a3a2eec67e7cffe34749e2e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d64ab9a0d90ed805b7951b567aefa33bd1c29adcb736a9527716cf494e2f313b828118441e011fc629e8c32fe3e28d432b8d876e9d1b74fbe82ea0ff62173e93
|
7
|
+
data.tar.gz: 42b46b733869d0405a6de236fd5522c095f9d4f664123b49f83d81f121e1f10ee040d98f03b96f046380626e5f815e17e219c5a6b96a696ae4354430cd7bd10c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# cucumber_lint
|
2
2
|
[](http://badge.fury.io/rb/cucumber_lint)
|
3
|
-
[](https://circleci.com/gh/charlierudolph/cucumber_lint)
|
4
4
|
[](https://gemnasium.com/charlierudolph/cucumber_lint)
|
5
5
|
[](https://codeclimate.com/github/charlierudolph/cucumber_lint)
|
6
6
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
Feature: consistent_empty_lines between description and element
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have a feature with content
|
5
|
+
"""
|
6
|
+
Feature: Test Feature
|
7
|
+
As a user
|
8
|
+
When I have this
|
9
|
+
I expect that
|
10
|
+
Scenario: Test Scenario
|
11
|
+
Given this
|
12
|
+
Then that
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: disabled
|
16
|
+
Given I have "consistent_empty_lines" disabled
|
17
|
+
When I run `cucumber_lint`
|
18
|
+
Then it passes
|
19
|
+
|
20
|
+
Scenario: lint and fix
|
21
|
+
Given I have "consistent_empty_lines" enabled with
|
22
|
+
| KEY | VALUE |
|
23
|
+
| between_description_and_element | 1 |
|
24
|
+
When I run `cucumber_lint`
|
25
|
+
Then it fails with
|
26
|
+
| LINE | MESSAGE |
|
27
|
+
| 5 | Add empty line |
|
28
|
+
When I run `cucumber_lint --fix`
|
29
|
+
Then my feature now has content
|
30
|
+
"""
|
31
|
+
Feature: Test Feature
|
32
|
+
As a user
|
33
|
+
When I have this
|
34
|
+
I expect that
|
35
|
+
|
36
|
+
Scenario: Test Scenario
|
37
|
+
Given this
|
38
|
+
Then that
|
39
|
+
"""
|
40
|
+
When I run `cucumber_lint`
|
41
|
+
Then it passes
|
42
|
+
|
43
|
+
Scenario: lint and fix (with non-zero between feature and description)
|
44
|
+
Given I have "consistent_empty_lines" enabled with
|
45
|
+
| KEY | VALUE |
|
46
|
+
| between_description_and_element | 2 |
|
47
|
+
| between_feature_and_description | 1 |
|
48
|
+
When I run `cucumber_lint`
|
49
|
+
Then it fails with
|
50
|
+
| LINE | MESSAGE |
|
51
|
+
| 2 | Add empty line |
|
52
|
+
| 5 | Add 2 empty lines |
|
53
|
+
When I run `cucumber_lint --fix`
|
54
|
+
Then my feature now has content
|
55
|
+
"""
|
56
|
+
Feature: Test Feature
|
57
|
+
|
58
|
+
As a user
|
59
|
+
When I have this
|
60
|
+
I expect that
|
61
|
+
|
62
|
+
|
63
|
+
Scenario: Test Scenario
|
64
|
+
Given this
|
65
|
+
Then that
|
66
|
+
"""
|
67
|
+
When I run `cucumber_lint`
|
68
|
+
Then it passes
|
data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_docstring.feature
CHANGED
@@ -22,7 +22,9 @@ Feature: consistent_empty_lines between elements (ending with docstring)
|
|
22
22
|
Then it passes
|
23
23
|
|
24
24
|
Scenario: lint and fix
|
25
|
-
Given I have "consistent_empty_lines" enabled with
|
25
|
+
Given I have "consistent_empty_lines" enabled with
|
26
|
+
| KEY | VALUE |
|
27
|
+
| between_elements | 1 |
|
26
28
|
When I run `cucumber_lint`
|
27
29
|
Then it fails with
|
28
30
|
| LINE | MESSAGE |
|
data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_examples.feature
CHANGED
@@ -23,7 +23,9 @@ Feature: consistent_empty_lines between elements (ending with examples)
|
|
23
23
|
Then it passes
|
24
24
|
|
25
25
|
Scenario: lint and fix
|
26
|
-
Given I have "consistent_empty_lines" enabled with
|
26
|
+
Given I have "consistent_empty_lines" enabled with
|
27
|
+
| KEY | VALUE |
|
28
|
+
| between_elements | 1 |
|
27
29
|
When I run `cucumber_lint`
|
28
30
|
Then it fails with
|
29
31
|
| LINE | MESSAGE |
|
data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_step.feature
CHANGED
@@ -19,7 +19,9 @@ Feature: consistent_empty_lines between elements (ending with step)
|
|
19
19
|
Then it passes
|
20
20
|
|
21
21
|
Scenario: lint and fix
|
22
|
-
Given I have "consistent_empty_lines" enabled with
|
22
|
+
Given I have "consistent_empty_lines" enabled with
|
23
|
+
| KEY | VALUE |
|
24
|
+
| between_elements | 1 |
|
23
25
|
When I run `cucumber_lint`
|
24
26
|
Then it fails with
|
25
27
|
| LINE | MESSAGE |
|
data/features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_table.feature
CHANGED
@@ -20,7 +20,9 @@ Feature: consistent_empty_lines between elements (ending with table)
|
|
20
20
|
Then it passes
|
21
21
|
|
22
22
|
Scenario: lint and fix
|
23
|
-
Given I have "consistent_empty_lines" enabled with
|
23
|
+
Given I have "consistent_empty_lines" enabled with
|
24
|
+
| KEY | VALUE |
|
25
|
+
| elements | 1 |
|
24
26
|
When I run `cucumber_lint`
|
25
27
|
Then it fails with
|
26
28
|
| LINE | MESSAGE |
|
@@ -16,7 +16,9 @@ Feature: consistent_empty_lines between feature and description
|
|
16
16
|
Then it passes
|
17
17
|
|
18
18
|
Scenario: lint and fix
|
19
|
-
Given I have "consistent_empty_lines" enabled with
|
19
|
+
Given I have "consistent_empty_lines" enabled with
|
20
|
+
| KEY | VALUE |
|
21
|
+
| feature_and_description | 1 |
|
20
22
|
When I run `cucumber_lint`
|
21
23
|
Then it fails with
|
22
24
|
| LINE | MESSAGE |
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Feature: consistent_empty_lines between feature and
|
1
|
+
Feature: consistent_empty_lines between feature and element
|
2
2
|
|
3
3
|
Background:
|
4
4
|
Given I have a feature with content
|
@@ -15,7 +15,9 @@ Feature: consistent_empty_lines between feature and scenario
|
|
15
15
|
Then it passes
|
16
16
|
|
17
17
|
Scenario: lint and fix
|
18
|
-
Given I have "consistent_empty_lines" enabled with
|
18
|
+
Given I have "consistent_empty_lines" enabled with
|
19
|
+
| KEY | VALUE |
|
20
|
+
| between_feature_and_element | 1 |
|
19
21
|
When I run `cucumber_lint`
|
20
22
|
Then it fails with
|
21
23
|
| LINE | MESSAGE |
|
@@ -22,7 +22,9 @@ Feature: consistent_table_headers for an examples table
|
|
22
22
|
Then it passes
|
23
23
|
|
24
24
|
Scenario: uppercase - lint and fix
|
25
|
-
Given I have "consistent_table_headers" enabled with
|
25
|
+
Given I have "consistent_table_headers" enabled with
|
26
|
+
| KEY | VALUE |
|
27
|
+
| enforced_style | uppercase |
|
26
28
|
When I run `cucumber_lint`
|
27
29
|
Then it fails with
|
28
30
|
| LINE | MESSAGE |
|
@@ -48,7 +50,9 @@ Feature: consistent_table_headers for an examples table
|
|
48
50
|
Then it passes
|
49
51
|
|
50
52
|
Scenario: lowercase - lint and fix
|
51
|
-
Given I have "consistent_table_headers" enabled with
|
53
|
+
Given I have "consistent_table_headers" enabled with
|
54
|
+
| KEY | VALUE |
|
55
|
+
| enforced_style | lowercase |
|
52
56
|
When I run `cucumber_lint`
|
53
57
|
Then it fails with
|
54
58
|
| LINE | MESSAGE |
|
@@ -20,7 +20,9 @@ Feature: consistent_table_headers for a step table
|
|
20
20
|
Then it passes
|
21
21
|
|
22
22
|
Scenario: uppercase - lint and fix
|
23
|
-
Given I have "consistent_table_headers" enabled with
|
23
|
+
Given I have "consistent_table_headers" enabled with
|
24
|
+
| KEY | VALUE |
|
25
|
+
| enforced_style | uppercase |
|
24
26
|
When I run `cucumber_lint`
|
25
27
|
Then it fails with
|
26
28
|
| LINE | MESSAGE |
|
@@ -42,7 +44,9 @@ Feature: consistent_table_headers for a step table
|
|
42
44
|
Then it passes
|
43
45
|
|
44
46
|
Scenario: lowercase - lint and fix
|
45
|
-
Given I have "consistent_table_headers" enabled with
|
47
|
+
Given I have "consistent_table_headers" enabled with
|
48
|
+
| KEY | VALUE |
|
49
|
+
| enforced_style | lowercase |
|
46
50
|
When I run `cucumber_lint`
|
47
51
|
Then it fails with
|
48
52
|
| LINE | MESSAGE |
|
@@ -1,7 +1,9 @@
|
|
1
1
|
Feature: consistent_table_headers enforcing an unsupported style
|
2
2
|
|
3
3
|
Background:
|
4
|
-
Given I have "consistent_table_headers" enabled with
|
4
|
+
Given I have "consistent_table_headers" enabled with
|
5
|
+
| KEY | VALUE |
|
6
|
+
| enforced_style | invalid |
|
5
7
|
|
6
8
|
Scenario: lint
|
7
9
|
When I run `cucumber_lint`
|
@@ -6,14 +6,20 @@ Given(/^I have no files$/) do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
|
9
|
-
Given(/^I have "(.+?)" (enabled|disabled)$/) do |
|
10
|
-
update_config(
|
9
|
+
Given(/^I have "(.+?)" (enabled|disabled)$/) do |rule, status|
|
10
|
+
update_config(rule => { enabled: status == 'enabled' })
|
11
11
|
end
|
12
12
|
|
13
13
|
|
14
|
-
Given(/^I have "(.+?)" enabled with
|
15
|
-
|
16
|
-
|
14
|
+
Given(/^I have "(.+?)" enabled with$/) do |rule, settingsTable|
|
15
|
+
settings = {}
|
16
|
+
settingsTable.hashes.each do |row|
|
17
|
+
key = row['KEY']
|
18
|
+
value = row['VALUE']
|
19
|
+
value = value.to_i if value.match(/^\d*$/)
|
20
|
+
settings[key] = value
|
21
|
+
end
|
22
|
+
update_config(rule => settings.merge(enabled: true))
|
17
23
|
end
|
18
24
|
|
19
25
|
|
@@ -19,13 +19,26 @@ module CucumberLint
|
|
19
19
|
private
|
20
20
|
|
21
21
|
|
22
|
+
def config_value key
|
23
|
+
@config.consistent_empty_lines.send(key)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def element_end element
|
28
|
+
if element.type == 'scenario_outline'
|
29
|
+
element.examples.last.rows.last.line
|
30
|
+
else
|
31
|
+
step_end element.steps.last
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
22
36
|
def expected_first_element_start
|
23
37
|
spacing = if @description == ''
|
24
|
-
|
38
|
+
config_value(:between_feature_and_element)
|
25
39
|
else
|
26
|
-
get_config(:between_feature_and_description) +
|
27
40
|
@description.count("\n") +
|
28
|
-
|
41
|
+
config_value(:between_description_and_element) +
|
29
42
|
1
|
30
43
|
end
|
31
44
|
|
@@ -44,25 +57,11 @@ module CucumberLint
|
|
44
57
|
end
|
45
58
|
|
46
59
|
|
47
|
-
def get_config key
|
48
|
-
@config.consistent_empty_lines.send(key)
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def get_element_end element
|
53
|
-
if element.type == 'scenario_outline'
|
54
|
-
element.examples.last.rows.last.line
|
55
|
-
else
|
56
|
-
step_end element.steps.last
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
60
|
def lint_description
|
62
61
|
return if @description == ''
|
63
62
|
|
64
63
|
shared_lines = @feature.line + 1
|
65
|
-
expected_start = shared_lines +
|
64
|
+
expected_start = shared_lines + config_value(:between_feature_and_description)
|
66
65
|
actual_start = shared_lines + @description.match(/\n*/)[0].length
|
67
66
|
resolve_empty_line_difference actual_start, expected_start
|
68
67
|
end
|
@@ -75,15 +74,14 @@ module CucumberLint
|
|
75
74
|
@feature.elements.each do |element|
|
76
75
|
resolve_empty_line_difference element.line, expected_element_start
|
77
76
|
lint_scenario_outline_and_examples element if element.type == 'scenario_outline'
|
78
|
-
|
79
|
-
expected_element_start = element_end + get_config(:between_elements) + 1
|
77
|
+
expected_element_start = element_end(element) + config_value(:between_elements) + 1
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
|
84
82
|
def lint_scenario_outline_and_examples element
|
85
83
|
expected_start = step_end(element.steps.last) +
|
86
|
-
|
84
|
+
config_value(:between_scenario_outline_and_examples) +
|
87
85
|
1
|
88
86
|
actual_start = element.examples.first.line
|
89
87
|
resolve_empty_line_difference actual_start, expected_start
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- charlierudolph
|
@@ -73,13 +73,13 @@ files:
|
|
73
73
|
- config/default.yml
|
74
74
|
- cucumber.yml
|
75
75
|
- cucumber_lint.gemspec
|
76
|
-
- features/cucumber_lint/consistent_empty_lines/
|
76
|
+
- features/cucumber_lint/consistent_empty_lines/between_description_and_element.feature
|
77
77
|
- features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_docstring.feature
|
78
78
|
- features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_examples.feature
|
79
79
|
- features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_step.feature
|
80
80
|
- features/cucumber_lint/consistent_empty_lines/between_elements/ending_with_table.feature
|
81
81
|
- features/cucumber_lint/consistent_empty_lines/between_feature_and_description.feature
|
82
|
-
- features/cucumber_lint/consistent_empty_lines/
|
82
|
+
- features/cucumber_lint/consistent_empty_lines/between_feature_and_element.feature
|
83
83
|
- features/cucumber_lint/consistent_table_headers/examples_table.feature
|
84
84
|
- features/cucumber_lint/consistent_table_headers/step_table.feature
|
85
85
|
- features/cucumber_lint/consistent_table_headers/unsupported_style.feature
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Feature: consistent_empty_lines between description and scenario
|
2
|
-
|
3
|
-
Background:
|
4
|
-
Given I have a feature with content
|
5
|
-
"""
|
6
|
-
Feature: Test Feature
|
7
|
-
As a user
|
8
|
-
When I have this
|
9
|
-
I expect that
|
10
|
-
Scenario: Test Scenario
|
11
|
-
Given this
|
12
|
-
Then that
|
13
|
-
"""
|
14
|
-
|
15
|
-
Scenario: disabled
|
16
|
-
Given I have "consistent_empty_lines" disabled
|
17
|
-
When I run `cucumber_lint`
|
18
|
-
Then it passes
|
19
|
-
|
20
|
-
Scenario: lint and fix
|
21
|
-
Given I have "consistent_empty_lines" enabled with "between_description_and_scenario" as "1"
|
22
|
-
When I run `cucumber_lint`
|
23
|
-
Then it fails with
|
24
|
-
| LINE | MESSAGE |
|
25
|
-
| 5 | Add empty line |
|
26
|
-
When I run `cucumber_lint --fix`
|
27
|
-
Then my feature now has content
|
28
|
-
"""
|
29
|
-
Feature: Test Feature
|
30
|
-
As a user
|
31
|
-
When I have this
|
32
|
-
I expect that
|
33
|
-
|
34
|
-
Scenario: Test Scenario
|
35
|
-
Given this
|
36
|
-
Then that
|
37
|
-
"""
|
38
|
-
When I run `cucumber_lint`
|
39
|
-
Then it passes
|