cucumber_lint 0.0.3 → 0.0.4
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/.rubocop.yml +0 -4
- data/.travis.yml +9 -0
- data/Gemfile +7 -5
- data/Gemfile.lock +3 -1
- data/README.md +28 -40
- data/Rakefile +12 -6
- data/cucumber_lint.gemspec +2 -0
- data/features/cucumber_lint/fix/nothing.feature +12 -0
- data/features/cucumber_lint/fix/repeating_steps.feature +25 -0
- data/features/cucumber_lint/fix/table_whitespace.feature +25 -0
- data/features/cucumber_lint/fix/uppercase_table_headers.feature +25 -0
- data/features/cucumber_lint/lint/nothing.feature +12 -0
- data/features/cucumber_lint/lint/repeating_steps.feature +31 -0
- data/features/cucumber_lint/lint/table_whitespace.feature +27 -0
- data/features/cucumber_lint/lint/uppercase_table_headers.feature +30 -0
- data/features/step_definitions/cli_steps.rb +9 -6
- data/features/step_definitions/fixtures/repeating_steps/bad.feature.example +12 -0
- data/features/step_definitions/fixtures/repeating_steps/good.feature.example +12 -0
- data/features/step_definitions/fixtures/table_whitespace/bad.feature.example +20 -0
- data/features/step_definitions/fixtures/table_whitespace/good.feature.example +20 -0
- data/features/step_definitions/fixtures/uppercase_table_headers/bad.feature.example +20 -0
- data/features/step_definitions/fixtures/uppercase_table_headers/good.feature.example +20 -0
- data/lib/core_ext/hash.rb +29 -0
- data/lib/cucumber_lint/cli.rb +50 -38
- data/lib/cucumber_lint/fix_list.rb +37 -0
- data/lib/cucumber_lint/linter/feature_linter.rb +92 -0
- data/lib/cucumber_lint/linter/scenario_outline_linter.rb +34 -0
- data/lib/cucumber_lint/linter/steps_linter.rb +49 -0
- data/lib/cucumber_lint/linter/table_linter.rb +70 -0
- data/lib/cucumber_lint/linter.rb +21 -0
- data/lib/cucumber_lint/version.rb +2 -2
- data/lib/cucumber_lint.rb +7 -4
- metadata +64 -16
- data/features/cucumber_lint/cli_fix.feature +0 -51
- data/features/cucumber_lint/cli_lint.feature +0 -55
- data/features/cucumber_lint/feature_formatter.feature +0 -106
- data/features/cucumber_lint/steps_formatter.feature +0 -30
- data/features/cucumber_lint/table_formatter.feature +0 -45
- data/features/step_definitions/fixtures/formatted.feature.example +0 -9
- data/features/step_definitions/fixtures/unformatted.feature.example +0 -9
- data/features/step_definitions/steps_formatter_steps.rb +0 -15
- data/features/step_definitions/table_formatter_steps.rb +0 -15
- data/lib/core_ext/array.rb +0 -22
- data/lib/cucumber_lint/feature_formatter.rb +0 -48
- data/lib/cucumber_lint/steps_formatter.rb +0 -50
- data/lib/cucumber_lint/table_formatter.rb +0 -65
- data/spec/core_ext/array_spec.rb +0 -19
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'gherkin/formatter/pretty_formatter'
|
2
|
+
|
3
|
+
module CucumberLint
|
4
|
+
# A linter for a series of table rows (as parsed by Gherkin)
|
5
|
+
class TableLinter < Linter
|
6
|
+
|
7
|
+
def initialize rows:, file_lines:, fix:, parent:
|
8
|
+
super(fix: fix, parent: parent)
|
9
|
+
|
10
|
+
@rows = rows
|
11
|
+
@file_lines = file_lines
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def lint
|
16
|
+
bad_whitespace unless actual_table_lines == expected_table_lines
|
17
|
+
bad_table_headers unless actual_table_lines[0] == actual_table_lines[0].upcase
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
|
24
|
+
def bad_table_headers
|
25
|
+
if @fix
|
26
|
+
fix_list.add @rows[0].line, -> (line) { line.upcase }
|
27
|
+
else
|
28
|
+
errors << "#{@rows[0].line}: Make table headers uppercase"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def actual_table_lines
|
34
|
+
@actual_table_lines ||= determine_actual_table_lines
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def bad_whitespace
|
39
|
+
if @fix
|
40
|
+
@rows.each_with_index.map do |row, index|
|
41
|
+
fix_list.add row.line, -> (line) { line.gsub(/\|.+?\n/, expected_table_lines[index]) }
|
42
|
+
end
|
43
|
+
else
|
44
|
+
errors << "#{@rows[0].line}: Fix table whitespace"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def determine_actual_table_lines
|
50
|
+
@rows.map { |row| @file_lines[row.line - 1].lstrip }
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def determine_expected_table_lines
|
55
|
+
@rows.each { |row| row.comments = [] }
|
56
|
+
|
57
|
+
io = StringIO.new
|
58
|
+
formatter = Gherkin::Formatter::PrettyFormatter.new(io, false, false)
|
59
|
+
formatter.table(@rows)
|
60
|
+
formatter.done
|
61
|
+
io.string.lines.map(&:lstrip)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def expected_table_lines
|
66
|
+
@expected_table_lines ||= determine_expected_table_lines
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CucumberLint
|
2
|
+
# A base linter, not meant to be instantiated
|
3
|
+
class Linter
|
4
|
+
|
5
|
+
attr_reader :errors, :fix_list
|
6
|
+
|
7
|
+
|
8
|
+
def initialize fix:, parent: nil
|
9
|
+
@fix = fix
|
10
|
+
|
11
|
+
if parent
|
12
|
+
@errors = parent.errors
|
13
|
+
@fix_list = parent.fix_list
|
14
|
+
else
|
15
|
+
@errors = []
|
16
|
+
@fix_list = FixList.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module CucumberLint
|
2
|
-
VERSION = '0.0.
|
1
|
+
module CucumberLint # rubocop:disable Style/Documentation
|
2
|
+
VERSION = '0.0.4'
|
3
3
|
end
|
data/lib/cucumber_lint.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'cucumber_lint/cli'
|
2
|
-
require 'cucumber_lint/
|
3
|
-
require 'cucumber_lint/
|
4
|
-
require 'cucumber_lint/
|
2
|
+
require 'cucumber_lint/fix_list'
|
3
|
+
require 'cucumber_lint/linter'
|
4
|
+
require 'cucumber_lint/linter/feature_linter'
|
5
|
+
require 'cucumber_lint/linter/scenario_outline_linter'
|
6
|
+
require 'cucumber_lint/linter/steps_linter'
|
7
|
+
require 'cucumber_lint/linter/table_linter'
|
5
8
|
|
6
|
-
module CucumberLint
|
9
|
+
module CucumberLint # rubocop:disable Style/Documentation
|
7
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- charlierudolph
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -24,6 +24,46 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.7.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gherkin
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.12.2
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.12.2
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.12.2
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.12.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.10.1
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.10.1
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.10.1
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.10.1
|
27
67
|
description:
|
28
68
|
email:
|
29
69
|
- charles.w.rudolph@gmail.com
|
@@ -34,6 +74,7 @@ extra_rdoc_files: []
|
|
34
74
|
files:
|
35
75
|
- ".gitignore"
|
36
76
|
- ".rubocop.yml"
|
77
|
+
- ".travis.yml"
|
37
78
|
- Gemfile
|
38
79
|
- Gemfile.lock
|
39
80
|
- LICENSE
|
@@ -42,27 +83,34 @@ files:
|
|
42
83
|
- bin/cucumber_lint
|
43
84
|
- cucumber.yml
|
44
85
|
- cucumber_lint.gemspec
|
45
|
-
- features/cucumber_lint/
|
46
|
-
- features/cucumber_lint/
|
47
|
-
- features/cucumber_lint/
|
48
|
-
- features/cucumber_lint/
|
49
|
-
- features/cucumber_lint/
|
86
|
+
- features/cucumber_lint/fix/nothing.feature
|
87
|
+
- features/cucumber_lint/fix/repeating_steps.feature
|
88
|
+
- features/cucumber_lint/fix/table_whitespace.feature
|
89
|
+
- features/cucumber_lint/fix/uppercase_table_headers.feature
|
90
|
+
- features/cucumber_lint/lint/nothing.feature
|
91
|
+
- features/cucumber_lint/lint/repeating_steps.feature
|
92
|
+
- features/cucumber_lint/lint/table_whitespace.feature
|
93
|
+
- features/cucumber_lint/lint/uppercase_table_headers.feature
|
50
94
|
- features/step_definitions/cli_steps.rb
|
51
95
|
- features/step_definitions/env.rb
|
52
96
|
- features/step_definitions/feature_formatter_steps.rb
|
53
|
-
- features/step_definitions/fixtures/
|
54
|
-
- features/step_definitions/fixtures/
|
55
|
-
- features/step_definitions/
|
97
|
+
- features/step_definitions/fixtures/repeating_steps/bad.feature.example
|
98
|
+
- features/step_definitions/fixtures/repeating_steps/good.feature.example
|
99
|
+
- features/step_definitions/fixtures/table_whitespace/bad.feature.example
|
100
|
+
- features/step_definitions/fixtures/table_whitespace/good.feature.example
|
101
|
+
- features/step_definitions/fixtures/uppercase_table_headers/bad.feature.example
|
102
|
+
- features/step_definitions/fixtures/uppercase_table_headers/good.feature.example
|
56
103
|
- features/step_definitions/support/run_helpers.rb
|
57
|
-
-
|
58
|
-
- lib/core_ext/array.rb
|
104
|
+
- lib/core_ext/hash.rb
|
59
105
|
- lib/cucumber_lint.rb
|
60
106
|
- lib/cucumber_lint/cli.rb
|
61
|
-
- lib/cucumber_lint/
|
62
|
-
- lib/cucumber_lint/
|
63
|
-
- lib/cucumber_lint/
|
107
|
+
- lib/cucumber_lint/fix_list.rb
|
108
|
+
- lib/cucumber_lint/linter.rb
|
109
|
+
- lib/cucumber_lint/linter/feature_linter.rb
|
110
|
+
- lib/cucumber_lint/linter/scenario_outline_linter.rb
|
111
|
+
- lib/cucumber_lint/linter/steps_linter.rb
|
112
|
+
- lib/cucumber_lint/linter/table_linter.rb
|
64
113
|
- lib/cucumber_lint/version.rb
|
65
|
-
- spec/core_ext/array_spec.rb
|
66
114
|
homepage: https://github.com/charlierudolph/cucumber_lint
|
67
115
|
licenses:
|
68
116
|
- MIT
|
@@ -1,51 +0,0 @@
|
|
1
|
-
Feature: cli format
|
2
|
-
|
3
|
-
Scenario: no files
|
4
|
-
Given I have no files
|
5
|
-
When I run `cucumber_lint --fix`
|
6
|
-
Then I see the output
|
7
|
-
"""
|
8
|
-
|
9
|
-
|
10
|
-
0 files inspected (0 written)
|
11
|
-
"""
|
12
|
-
And it exits with status 0
|
13
|
-
|
14
|
-
|
15
|
-
Scenario: formatted file
|
16
|
-
Given I have a formatted file at "features/formatted.feature"
|
17
|
-
When I run `cucumber_lint --fix`
|
18
|
-
Then I see the output
|
19
|
-
"""
|
20
|
-
.
|
21
|
-
|
22
|
-
1 file inspected (0 written)
|
23
|
-
"""
|
24
|
-
And it exits with status 0
|
25
|
-
|
26
|
-
|
27
|
-
Scenario: unformatted file
|
28
|
-
Given I have an unformatted file at "features/unformatted.feature"
|
29
|
-
When I run `cucumber_lint --fix`
|
30
|
-
Then I see the output
|
31
|
-
"""
|
32
|
-
W
|
33
|
-
|
34
|
-
1 file inspected (1 written)
|
35
|
-
"""
|
36
|
-
And it exits with status 0
|
37
|
-
And the file "features/unformatted.feature" in now formatted
|
38
|
-
|
39
|
-
|
40
|
-
Scenario: formatted file and unformatted file
|
41
|
-
Given I have an formatted file at "features/formatted.feature"
|
42
|
-
And I have an unformatted file at "features/unformatted.feature"
|
43
|
-
When I run `cucumber_lint --fix`
|
44
|
-
Then I see the output
|
45
|
-
"""
|
46
|
-
.W
|
47
|
-
|
48
|
-
2 files inspected (1 written)
|
49
|
-
"""
|
50
|
-
And it exits with status 0
|
51
|
-
And the file "features/unformatted.feature" in now formatted
|
@@ -1,55 +0,0 @@
|
|
1
|
-
Feature: cli lint
|
2
|
-
|
3
|
-
Scenario: no files
|
4
|
-
Given I have no files
|
5
|
-
When I run `cucumber_lint`
|
6
|
-
Then I see the output
|
7
|
-
"""
|
8
|
-
|
9
|
-
|
10
|
-
0 files inspected (0 passed)
|
11
|
-
"""
|
12
|
-
And it exits with status 0
|
13
|
-
|
14
|
-
|
15
|
-
Scenario: formatted file
|
16
|
-
Given I have a formatted file at "features/formatted.feature"
|
17
|
-
When I run `cucumber_lint`
|
18
|
-
Then I see the output
|
19
|
-
"""
|
20
|
-
.
|
21
|
-
|
22
|
-
1 file inspected (1 passed)
|
23
|
-
"""
|
24
|
-
And it exits with status 0
|
25
|
-
|
26
|
-
|
27
|
-
Scenario: unformatted file
|
28
|
-
Given I have an unformatted file at "features/unformatted.feature"
|
29
|
-
When I run `cucumber_lint`
|
30
|
-
Then I see the output
|
31
|
-
"""
|
32
|
-
F
|
33
|
-
|
34
|
-
Files with errors:
|
35
|
-
./features/unformatted.feature
|
36
|
-
|
37
|
-
1 file inspected (0 passed, 1 failed)
|
38
|
-
"""
|
39
|
-
And it exits with status 1
|
40
|
-
|
41
|
-
|
42
|
-
Scenario: formatted file and unformatted file
|
43
|
-
Given I have an formatted file at "features/formatted.feature"
|
44
|
-
And I have an unformatted file at "features/unformatted.feature"
|
45
|
-
When I run `cucumber_lint`
|
46
|
-
Then I see the output
|
47
|
-
"""
|
48
|
-
.F
|
49
|
-
|
50
|
-
Files with errors:
|
51
|
-
./features/unformatted.feature
|
52
|
-
|
53
|
-
2 files inspected (1 passed, 1 failed)
|
54
|
-
"""
|
55
|
-
And it exits with status 1
|
@@ -1,106 +0,0 @@
|
|
1
|
-
Feature: feature formatter
|
2
|
-
|
3
|
-
Scenario: feature with single unformatted table
|
4
|
-
Given feature content
|
5
|
-
"""
|
6
|
-
Feature: Test Feature
|
7
|
-
|
8
|
-
Scenario: Test Scenario
|
9
|
-
Given a table
|
10
|
-
|header_column1|header_column2|
|
11
|
-
|row1_column1|row1_column2|
|
12
|
-
|row2_column1|row2_column2|
|
13
|
-
|row3_column1|row3_column2|
|
14
|
-
Given other stuff
|
15
|
-
When I do things
|
16
|
-
Then my tests pass
|
17
|
-
Then I am happy
|
18
|
-
"""
|
19
|
-
Then the formatted feature content is
|
20
|
-
"""
|
21
|
-
Feature: Test Feature
|
22
|
-
|
23
|
-
Scenario: Test Scenario
|
24
|
-
Given a table
|
25
|
-
| header_column1 | header_column2 |
|
26
|
-
| row1_column1 | row1_column2 |
|
27
|
-
| row2_column1 | row2_column2 |
|
28
|
-
| row3_column1 | row3_column2 |
|
29
|
-
And other stuff
|
30
|
-
When I do things
|
31
|
-
Then my tests pass
|
32
|
-
And I am happy
|
33
|
-
"""
|
34
|
-
|
35
|
-
|
36
|
-
Scenario: feature with mutliple unformatted tables
|
37
|
-
Given feature content
|
38
|
-
"""
|
39
|
-
Feature: Test Feature
|
40
|
-
|
41
|
-
Scenario: Test Scenario
|
42
|
-
Given a table
|
43
|
-
|header_column1|header_column2|
|
44
|
-
|row1_column1|row1_column2|
|
45
|
-
|row2_column1|row2_column2|
|
46
|
-
|row3_column1|row3_column2|
|
47
|
-
Then my tests pass
|
48
|
-
|
49
|
-
Scenario Outline: Test Scenario Outline
|
50
|
-
Given <a> and <b>
|
51
|
-
Then I expect <c>
|
52
|
-
|
53
|
-
Examples:
|
54
|
-
|a | b | c |
|
55
|
-
|a1 | b1| c1 |
|
56
|
-
|a2 | b2 | c2 |
|
57
|
-
|a3 | b3 | c3 |
|
58
|
-
"""
|
59
|
-
Then the formatted feature content is
|
60
|
-
"""
|
61
|
-
Feature: Test Feature
|
62
|
-
|
63
|
-
Scenario: Test Scenario
|
64
|
-
Given a table
|
65
|
-
| header_column1 | header_column2 |
|
66
|
-
| row1_column1 | row1_column2 |
|
67
|
-
| row2_column1 | row2_column2 |
|
68
|
-
| row3_column1 | row3_column2 |
|
69
|
-
Then my tests pass
|
70
|
-
|
71
|
-
Scenario Outline: Test Scenario Outline
|
72
|
-
Given <a> and <b>
|
73
|
-
Then I expect <c>
|
74
|
-
|
75
|
-
Examples:
|
76
|
-
| a | b | c |
|
77
|
-
| a1 | b1 | c1 |
|
78
|
-
| a2 | b2 | c2 |
|
79
|
-
| a3 | b3 | c3 |
|
80
|
-
"""
|
81
|
-
|
82
|
-
|
83
|
-
Scenario: feature with formatted tables
|
84
|
-
Given feature content
|
85
|
-
"""
|
86
|
-
Feature: Test Feature
|
87
|
-
|
88
|
-
Scenario: Test Scenario
|
89
|
-
Given a table
|
90
|
-
| header_column1 | header_column2 |
|
91
|
-
| row1_column1 | row1_column2 |
|
92
|
-
| row2_column1 | row2_column2 |
|
93
|
-
| row3_column1 | row3_column2 |
|
94
|
-
Then my tests pass
|
95
|
-
|
96
|
-
Scenario Outline: Test Scenario Outline
|
97
|
-
Given <a> and <b>
|
98
|
-
Then I expect <c>
|
99
|
-
|
100
|
-
Examples:
|
101
|
-
| a | b | c |
|
102
|
-
| a1 | b1 | c1 |
|
103
|
-
| a2 | b2 | c2 |
|
104
|
-
| a3 | b3 | c3 |
|
105
|
-
"""
|
106
|
-
Then the feature is formatted
|