greener 0.0.1.2 → 0.1.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 +7 -0
- data/README.md +12 -6
- data/config/defaults.yml +4 -1
- data/config/dogfood.yml +1 -1
- data/features/checker_feature_name.feature +60 -0
- data/features/checker_indentation_width.feature +21 -0
- data/features/lint.feature +10 -29
- data/features/support/env.rb +2 -0
- data/greener.gemspec +2 -1
- data/lib/greener/checker/base.rb +1 -1
- data/lib/greener/checker/style/feature_name.rb +28 -5
- data/lib/greener/config_store.rb +2 -2
- data/lib/greener/version.rb +1 -1
- metadata +23 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d715e2bc60c20c81addaf628e6261ce71fe7b3
|
4
|
+
data.tar.gz: 0a8b92e22438005651b5e3ac73106b784ea9f046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fdfa149aa9569cd11b86f02529a2c420b2561d701454eaedc9a24c9a3dba26bba1df53053d086cb0daea573e88814d67a8596af9a636d86a1763a5f6f9c0ccf
|
7
|
+
data.tar.gz: cc534b77ef04bc747d542cc353fd22bcc9f54d5f9dac3c8d0cf95511d2b51f163b0875a82d56475b54dbb9db6e3d92bae3f32e06cdea36b1390611a9b2a4fc05
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
## 0.1.0 (June 29, 2015)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- First minor version release
|
6
|
+
- 2 checkers are available, `Style/FeatureName` and `Style/IndentationWidth`
|
7
|
+
- By default, `greener` checks for .feature files recursively from the current working directory. This can be overridden via the `AllCheckers:` > `Include:` or `Exclude:` keys in the yml.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
greener
|
2
2
|
===
|
3
3
|
|
4
|
-
[](https://circleci.com/gh/smoll/greener) [](https://codeclimate.com/github/smoll/greener) [](https://coveralls.io/r/smoll/greener?branch=master)
|
4
|
+
[](https://circleci.com/gh/smoll/greener) [](https://codeclimate.com/github/smoll/greener) [](https://coveralls.io/r/smoll/greener?branch=master) [](http://badge.fury.io/rb/greener)
|
5
5
|
|
6
6
|
A Gherkin .feature file linter
|
7
7
|
|
@@ -14,6 +14,17 @@ A Gherkin .feature file linter
|
|
14
14
|
0. Create a RakeTask class for use in CI systems
|
15
15
|
0. Add coloring for formatters
|
16
16
|
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Install the gem
|
20
|
+
```
|
21
|
+
gem install greener
|
22
|
+
```
|
23
|
+
|
24
|
+
The `greener` binary takes a single argument, `-c path/to/config/greener.yml`. See the [defaults](./config/defaults.yml) for an example of this file.
|
25
|
+
|
26
|
+
View the [changelog](./CHANGELOG.md) for recent changes.
|
27
|
+
|
17
28
|
## Contributing
|
18
29
|
|
19
30
|
Install dev dependencies locally
|
@@ -31,11 +42,6 @@ View code coverage
|
|
31
42
|
rake && open coverage/index.html
|
32
43
|
```
|
33
44
|
|
34
|
-
View code coverage from RSpec unit tests only
|
35
|
-
```
|
36
|
-
rm -rf coverage && rspec && open coverage/index.html
|
37
|
-
```
|
38
|
-
|
39
45
|
## Testing
|
40
46
|
|
41
47
|
To test the `greener` binary locally, `cd` to the repo root and run
|
data/config/defaults.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# AllCheckers:
|
2
2
|
# Include:
|
3
3
|
# - "**/*.feature"
|
4
4
|
# Exclude:
|
@@ -6,6 +6,9 @@
|
|
6
6
|
|
7
7
|
Style/FeatureName:
|
8
8
|
Enabled: true
|
9
|
+
# Allow non-alphanumeric characters, e.g. filename test_thing.feature with text "Feature: (test) thing"
|
10
|
+
AllowPunctuation: true
|
11
|
+
EnforceTitleCase: false
|
9
12
|
|
10
13
|
Style/IndentationWidth:
|
11
14
|
Enabled: true
|
data/config/dogfood.yml
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: (checker) feature name
|
2
|
+
|
3
|
+
Scenario: feature text does not match filename
|
4
|
+
Given a file named "foo/mismatched_feature_title.feature" with:
|
5
|
+
"""
|
6
|
+
Feature: mismatched feature title LOL
|
7
|
+
"""
|
8
|
+
When I run `greener`
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
foo/mismatched_feature_title.feature:1
|
12
|
+
Feature: mismatched feature title LOL
|
13
|
+
^^^ feature title does not match file name
|
14
|
+
|
15
|
+
1 file(s) inspected, 1 offense(s) detected
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: capitalization allowed
|
19
|
+
Given a file named "foo/valid_title.feature" with:
|
20
|
+
"""
|
21
|
+
Feature: Valid Title
|
22
|
+
"""
|
23
|
+
When I run `greener`
|
24
|
+
Then the output should contain exactly "1 file(s) inspected, no offenses detected\n"
|
25
|
+
|
26
|
+
Scenario: punctuation allowed
|
27
|
+
Given a file named "foo/some_punctuation.feature" with:
|
28
|
+
"""
|
29
|
+
Feature: (some) punctuation
|
30
|
+
"""
|
31
|
+
And a file named "config/punctuation_allowed.yml" with:
|
32
|
+
"""
|
33
|
+
Style/FeatureName:
|
34
|
+
Enabled: true
|
35
|
+
AllowPunctuation: true
|
36
|
+
"""
|
37
|
+
When I run `greener --config config/punctuation_allowed.yml`
|
38
|
+
Then the output should contain exactly "1 file(s) inspected, no offenses detected\n"
|
39
|
+
|
40
|
+
Scenario: title case enforced
|
41
|
+
Given a file named "foo/this_isnt_title_case_yo.feature" with:
|
42
|
+
"""
|
43
|
+
Feature: this isn't Title Case, yo!
|
44
|
+
"""
|
45
|
+
And a file named "config/enforce_title_case.yml" with:
|
46
|
+
"""
|
47
|
+
Style/FeatureName:
|
48
|
+
Enabled: true
|
49
|
+
AllowPunctuation: true
|
50
|
+
EnforceTitleCase: true
|
51
|
+
"""
|
52
|
+
When I run `greener --config config/enforce_title_case.yml`
|
53
|
+
Then the output should contain:
|
54
|
+
"""
|
55
|
+
foo/this_isnt_title_case_yo.feature:1
|
56
|
+
Feature: this isn't Title Case, yo!
|
57
|
+
^^^ feature title is not title case. expected: This Isn't Title Case, Yo!
|
58
|
+
|
59
|
+
1 file(s) inspected, 1 offense(s) detected
|
60
|
+
"""
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: (checker) indentation width
|
2
|
+
|
3
|
+
Scenario: inconsistent indentation
|
4
|
+
Given a file named "foo/indentation.feature" with:
|
5
|
+
"""
|
6
|
+
Feature: indentation
|
7
|
+
|
8
|
+
Scenario: correctly indented
|
9
|
+
|
10
|
+
Scenario: poorly indented
|
11
|
+
Then nothing
|
12
|
+
"""
|
13
|
+
When I run `greener`
|
14
|
+
Then the output should contain:
|
15
|
+
"""
|
16
|
+
foo/indentation.feature:5
|
17
|
+
Scenario: poorly indented
|
18
|
+
^^^ inconsistent indentation detected
|
19
|
+
|
20
|
+
1 file(s) inspected, 1 offense(s) detected
|
21
|
+
"""
|
data/features/lint.feature
CHANGED
@@ -1,26 +1,9 @@
|
|
1
1
|
Feature: lint
|
2
|
-
* TODO: eventually, move most, if not all, of these to unit tests
|
3
2
|
|
4
|
-
Scenario:
|
5
|
-
Given a file named "foo/
|
6
|
-
"""
|
7
|
-
Feature: Valid Title
|
8
|
-
"""
|
9
|
-
When I run `greener`
|
10
|
-
Then the output should contain exactly "1 file(s) inspected, no offenses detected\n"
|
11
|
-
|
12
|
-
Scenario: feature text does not match filename
|
13
|
-
Given a file named "foo/mismatched_feature_title.feature" with:
|
14
|
-
"""
|
15
|
-
Feature: mismatched feature title LOL
|
16
|
-
"""
|
17
|
-
When I run `greener`
|
18
|
-
Then the output should contain exactly "foo/mismatched_feature_title.feature:1\nFeature: mismatched feature title LOL\n^^^ feature title does not match file name\n\n1 file(s) inspected, 1 offense(s) detected\n"
|
19
|
-
|
20
|
-
Scenario: inconsistent indentation
|
21
|
-
Given a file named "foo/indentation.feature" with:
|
3
|
+
Scenario: multiple issues
|
4
|
+
Given a file named "foo/multiple_issues.feature" with:
|
22
5
|
"""
|
23
|
-
|
6
|
+
Feature: multiple issues
|
24
7
|
|
25
8
|
Scenario: correctly indented
|
26
9
|
|
@@ -28,17 +11,15 @@ Feature: lint
|
|
28
11
|
Then nothing
|
29
12
|
"""
|
30
13
|
When I run `greener`
|
31
|
-
Then the output should contain
|
32
|
-
|
33
|
-
Scenario: multiple issues
|
34
|
-
Given a file named "foo/multiple_issues.feature" with:
|
14
|
+
Then the output should contain:
|
35
15
|
"""
|
16
|
+
foo/multiple_issues.feature:1
|
36
17
|
Feature: multiple issues
|
18
|
+
^^^ inconsistent indentation detected
|
37
19
|
|
38
|
-
|
39
|
-
|
20
|
+
foo/multiple_issues.feature:5
|
40
21
|
Scenario: poorly indented
|
41
|
-
|
22
|
+
^^^ inconsistent indentation detected
|
23
|
+
|
24
|
+
1 file(s) inspected, 2 offense(s) detected\n
|
42
25
|
"""
|
43
|
-
When I run `greener`
|
44
|
-
Then the output should contain "1 file(s) inspected, 2 offense(s) detected\n"
|
data/features/support/env.rb
CHANGED
data/greener.gemspec
CHANGED
@@ -31,9 +31,10 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
spec.add_dependency "thor", "~> 0.19.1"
|
35
34
|
# TODO: rip this out when gherkin3 has a release
|
36
35
|
spec.add_dependency "gherkin3-pre-alpha", "~> 3.0.0.alpha.1"
|
36
|
+
spec.add_dependency "thor", "~> 0.19.1"
|
37
|
+
spec.add_dependency "titleize", "~> 1.3.0"
|
37
38
|
|
38
39
|
spec.add_development_dependency "aruba", "~> 0.6.2"
|
39
40
|
spec.add_development_dependency "bundler", ">= 1.9.5"
|
data/lib/greener/checker/base.rb
CHANGED
@@ -22,7 +22,7 @@ module Greener
|
|
22
22
|
end
|
23
23
|
|
24
24
|
# Adds violation data to the @violations array
|
25
|
-
def log_violation(line, col,
|
25
|
+
def log_violation(line, col, msg = nil, raw_txt = nil)
|
26
26
|
# Set defaults for last 2 params if not overridden
|
27
27
|
raw_txt ||= raw_line(line)
|
28
28
|
msg ||= message
|
@@ -1,24 +1,47 @@
|
|
1
1
|
require "greener/checker/base"
|
2
|
+
require "titleize"
|
2
3
|
|
3
4
|
module Greener
|
4
5
|
module Checker
|
5
6
|
module Style
|
6
7
|
# Ensure .feature filename matches feature name in the Gherkin
|
7
8
|
# e.g. filename_of_feature.feature => "Feature: filename of feature"
|
8
|
-
# TODO: add config option for toggling flexible capitalization
|
9
9
|
class FeatureName < Base
|
10
10
|
MSG = "feature title does not match file name"
|
11
11
|
|
12
|
-
# Returns nil if no violation, or if there is one:
|
13
|
-
# { line: 1, column: 1, text_of_line: "Feature: thing", message: "feature title does not match file name" }
|
14
12
|
def run
|
15
13
|
return unless @config["Enabled"]
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
run_against_filename
|
16
|
+
run_against_titlecase
|
17
|
+
end
|
19
18
|
|
19
|
+
def run_against_filename
|
20
|
+
filename_without_extension = File.basename(@path, ".*")
|
21
|
+
expected = feature[:name]
|
22
|
+
expected = expected.gsub(/[^0-9a-z ]/i, "") if allow_punctuation?
|
23
|
+
expected = expected.downcase.gsub(" ", "_")
|
24
|
+
return if filename_without_extension == expected
|
20
25
|
log_violation(feature[:location][:line], feature[:location][:column])
|
21
26
|
end
|
27
|
+
|
28
|
+
def run_against_titlecase
|
29
|
+
return unless enforce_title_case?
|
30
|
+
return if feature[:name].titlecase == feature[:name]
|
31
|
+
log_violation(
|
32
|
+
feature[:location][:line],
|
33
|
+
feature[:location][:column],
|
34
|
+
"feature title is not title case. expected: #{feature[:name].titlecase}"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def allow_punctuation?
|
39
|
+
@config["AllowPunctuation"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def enforce_title_case?
|
43
|
+
@config["EnforceTitleCase"]
|
44
|
+
end
|
22
45
|
end
|
23
46
|
end
|
24
47
|
end
|
data/lib/greener/config_store.rb
CHANGED
@@ -66,13 +66,13 @@ module Greener
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def set_files
|
69
|
-
if @all["
|
69
|
+
if @all["AllCheckers"].nil?
|
70
70
|
# Default to all .feature files recursively
|
71
71
|
return @files = files_matching_glob("**/*.feature")
|
72
72
|
end
|
73
73
|
|
74
74
|
@all.each do |k, v|
|
75
|
-
next unless k == "
|
75
|
+
next unless k == "AllCheckers"
|
76
76
|
discover_files(v)
|
77
77
|
@all.delete(k)
|
78
78
|
end
|
data/lib/greener/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- smoll
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gherkin3-pre-alpha
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0.alpha.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0.alpha.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: thor
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -25,19 +39,19 @@ dependencies:
|
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: 0.19.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
42
|
+
name: titleize
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.0
|
47
|
+
version: 1.3.0
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.0
|
54
|
+
version: 1.3.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: aruba
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,11 +172,14 @@ executables:
|
|
158
172
|
extensions: []
|
159
173
|
extra_rdoc_files: []
|
160
174
|
files:
|
175
|
+
- CHANGELOG.md
|
161
176
|
- LICENSE.txt
|
162
177
|
- README.md
|
163
178
|
- bin/greener
|
164
179
|
- config/defaults.yml
|
165
180
|
- config/dogfood.yml
|
181
|
+
- features/checker_feature_name.feature
|
182
|
+
- features/checker_indentation_width.feature
|
166
183
|
- features/configuration.feature
|
167
184
|
- features/lint.feature
|
168
185
|
- features/support/env.rb
|
@@ -198,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
215
|
version: '0'
|
199
216
|
requirements: []
|
200
217
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.4.8
|
202
219
|
signing_key:
|
203
220
|
specification_version: 4
|
204
221
|
summary: A Gherkin .feature file linter
|