greener 0.0.1.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a4c2f033e269791bfbef80978c096695c6847f2
4
- data.tar.gz: 7647963368a1e66d16664b7660c40979b5fb560e
3
+ metadata.gz: 82d715e2bc60c20c81addaf628e6261ce71fe7b3
4
+ data.tar.gz: 0a8b92e22438005651b5e3ac73106b784ea9f046
5
5
  SHA512:
6
- metadata.gz: 41e90af06a1f0355c7499a833aaf30bc1c30c633659b769f0dc8c102707916c199e5a4ba117d99c3ddb47fce7e8d3602629fce1898992c9f1539ba7bc9a18792
7
- data.tar.gz: 733319f7a35759b6017c23c7443dc9df85df46daafa862cc091bdaab7f3c3384f12696c286a28df33fccae7705d290b8d7622011635b85270f9357f23479412a
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
- [![Circle CI](https://circleci.com/gh/smoll/greener.svg?style=svg)](https://circleci.com/gh/smoll/greener) [![Code Climate](https://codeclimate.com/github/smoll/greener/badges/gpa.svg)](https://codeclimate.com/github/smoll/greener) [![Coverage Status](https://coveralls.io/repos/smoll/greener/badge.svg?branch=master)](https://coveralls.io/r/smoll/greener?branch=master)
4
+ [![Circle CI](https://circleci.com/gh/smoll/greener.svg?style=svg)](https://circleci.com/gh/smoll/greener) [![Code Climate](https://codeclimate.com/github/smoll/greener/badges/gpa.svg)](https://codeclimate.com/github/smoll/greener) [![Coverage Status](https://coveralls.io/repos/smoll/greener/badge.svg?branch=master)](https://coveralls.io/r/smoll/greener?branch=master) [![Gem Version](https://badge.fury.io/rb/greener.svg)](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
- # FileList:
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
@@ -1,4 +1,4 @@
1
1
  # Used by dogfood test, i.e. run greener against the .feature files in this repo!
2
- FileList:
2
+ AllCheckers:
3
3
  Include:
4
4
  - "features/**/*.feature"
@@ -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
+ """
@@ -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: feature text matches, with flexible capitalization
5
- Given a file named "foo/valid_title.feature" with:
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
- Feature: indentation
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 exactly "foo/indentation.feature:5\n Scenario: poorly indented\n ^^^ inconsistent indentation detected\n\n1 file(s) inspected, 1 offense(s) detected\n"
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
- Scenario: correctly indented
39
-
20
+ foo/multiple_issues.feature:5
40
21
  Scenario: poorly indented
41
- Then nothing
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"
@@ -3,5 +3,7 @@ require "aruba/cucumber"
3
3
  require "aruba/in_process"
4
4
  require "greener/runner"
5
5
 
6
+ SimpleCov.command_name "features"
7
+
6
8
  Aruba::InProcess.main_class = Greener::Runner
7
9
  Aruba.process = Aruba::InProcess
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"
@@ -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, raw_txt = nil, msg = nil)
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
- filename_without_extension = File.basename(@path, ".*")
18
- return if feature[:name].downcase.gsub(" ", "_") == filename_without_extension
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
@@ -66,13 +66,13 @@ module Greener
66
66
  end
67
67
 
68
68
  def set_files
69
- if @all["FileList"].nil?
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 == "FileList"
75
+ next unless k == "AllCheckers"
76
76
  discover_files(v)
77
77
  @all.delete(k)
78
78
  end
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module Greener
3
- VERSION = "0.0.1.2"
3
+ VERSION = "0.1.0"
4
4
  end
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.0.1.2
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-26 00:00:00.000000000 Z
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: gherkin3-pre-alpha
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.0.alpha.1
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.0.alpha.1
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.2.2
218
+ rubygems_version: 2.4.8
202
219
  signing_key:
203
220
  specification_version: 4
204
221
  summary: A Gherkin .feature file linter