gherkin_lint 0.0.12 → 0.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e189dc06dc67de9babbb162719f6a6076e7fdca
4
- data.tar.gz: 67b05bc5a362173d4224a851a2bf9e4fb7dd0717
3
+ metadata.gz: 9f6a87e94f184beadb3e93477e179de06cabd490
4
+ data.tar.gz: 051d3c873a7089ff9981738391a848cb8b77f7f2
5
5
  SHA512:
6
- metadata.gz: c26e21bf005148159ce63c68f66528bd4778727cc78fad916ff05af61229fba638b108ddaa0c88f5c2fab7313e25f262ea95d04a7b01d15f138977d0707b91b8
7
- data.tar.gz: e995a0d94ee6ad6199ea24461c89f53c4f2dea05b640bc2da542a227c949f8fce361cd743bcf07045ffd06834d0f786dafcec82bd65ad48e5bc248513edd0487
6
+ metadata.gz: 8b13bf8e881f58d0e5a53d72c5449c4feb17272f065b60d807887047af1a6aba8ebba2ff41692eafe9e76cd6805b97398758048a1ec67ed2f2f597921eee8493
7
+ data.tar.gz: b96ccffdae892aae560a77c5bc4c4ca9f5ecaa556dbbb46478c1ca775f1bf0f95182c85996f05b939f9268a1608f0df24857f0dec235b574e1606694a07773a8
data/Dockerfile ADDED
@@ -0,0 +1,5 @@
1
+ FROM ruby
2
+ MAINTAINER think@hotmail.de
3
+
4
+ RUN gem install gherkin_lint --no-format-exec
5
+ CMD gherkin_lint
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
  gem 'aruba'
3
3
  gem 'amatch'
4
- gem 'gherkin'
4
+ gem 'gherkin', '=2.12.2'
5
5
  gem 'gherkin_format'
6
6
  gem 'gherkin_language'
7
7
  gem 'rake'
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Lint Gherkin Files
2
2
 
3
3
  [![Build Status](https://travis-ci.org/funkwerk/gherkin_lint.svg)](https://travis-ci.org/funkwerk/gherkin_lint)
4
+ [![Code Climate](https://codeclimate.com/github/funkwerk/gherkin_lint/badges/gpa.svg)](https://codeclimate.com/github/funkwerk/gherkin_lint)
4
5
 
5
6
  This tool lints gherkin files.
6
7
 
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  desc 'Publishes the Gem'
13
13
  task :push do
14
- sh 'gem push gherkin_lint-0.0.11.gem'
14
+ sh 'gem push gherkin_lint-0.0.13.gem'
15
15
  end
16
16
 
17
17
  desc 'Checks ruby style'
@@ -1,5 +1,5 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
3
  Before do
4
- @aruba_timeout_seconds = 10 # too slow on sloppy machines
4
+ @aruba_timeout_seconds = 10 # too slow on sloppy machines
5
5
  end
@@ -35,6 +35,23 @@ Feature: Unknown Variable
35
35
 
36
36
  """
37
37
 
38
+ Scenario: Unknown Step Variable Even For Missing Examples
39
+ Given a file named "lint.feature" with:
40
+ """
41
+ Feature: Test
42
+ Scenario Outline: A
43
+ When <baz> and <bar>
44
+ """
45
+ When I run `ruby lint.rb`
46
+ Then it should fail with exactly:
47
+ """
48
+ UnknownVariable - '<baz>' is unknown
49
+ lint.feature (2): Test.A
50
+ UnknownVariable - '<bar>' is unknown
51
+ lint.feature (2): Test.A
52
+
53
+ """
54
+
38
55
  Scenario: Unknown Table Variable
39
56
  Given a file named "lint.feature" with:
40
57
  """
data/gherkin_lint.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_lint'
3
- s.version = '0.0.12'
4
- s.date = '2015-07-26'
3
+ s.version = '0.0.13'
4
+ s.date = '2016-01-17'
5
5
  s.summary = 'Gherkin Lint'
6
6
  s.description = 'Lint Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
data/lib/gherkin_lint.rb CHANGED
@@ -1,3 +1,5 @@
1
+ gem 'gherkin', '=2.12.2'
2
+
1
3
  require 'gherkin/formatter/json_formatter'
2
4
  require 'gherkin/parser/parser'
3
5
  require 'gherkin_lint/linter/avoid_outline_for_single_example'
@@ -58,7 +60,7 @@ module GherkinLint
58
60
  UnusedVariable,
59
61
  UseBackground,
60
62
  UseOutline
61
- ]
63
+ ].freeze
62
64
 
63
65
  def initialize
64
66
  @files = {}
@@ -71,29 +73,26 @@ module GherkinLint
71
73
  end
72
74
 
73
75
  def enable(enabled_linter)
74
- @linter = []
75
- enabled_linter = Set.new enabled_linter
76
- LINTER.each do |linter|
77
- new_linter = linter.new
78
- next unless enabled_linter.include? new_linter.class.name.split('::').last
79
- register_linter new_linter
80
- end
76
+ set_linter(enabled_linter)
81
77
  end
82
78
 
83
79
  def disable(disabled_linter)
80
+ set_linter([], disabled_linter)
81
+ end
82
+
83
+ def set_linter(enabled_linter, disabled_linter = [])
84
84
  @linter = []
85
+ enabled_linter = Set.new enabled_linter
85
86
  disabled_linter = Set.new disabled_linter
86
87
  LINTER.each do |linter|
87
88
  new_linter = linter.new
88
- next if disabled_linter.include? new_linter.class.name.split('::').last
89
- register_linter new_linter
89
+ name = new_linter.class.name.split('::').last
90
+ next unless enabled_linter.include? name
91
+ next if disabled_linter.include? name
92
+ @linter.push new_linter
90
93
  end
91
94
  end
92
95
 
93
- def register_linter(linter)
94
- @linter.push linter
95
- end
96
-
97
96
  def analyze(file)
98
97
  @files[file] = parse file
99
98
  end
@@ -24,42 +24,38 @@ module GherkinLint
24
24
  end
25
25
 
26
26
  def scenarios
27
- @files.each do |file, content|
28
- content.each do |feature|
29
- next unless feature.key? 'elements'
30
- feature['elements'].each do |scenario|
31
- next if scenario['keyword'] == 'Background'
32
- yield(file, feature, scenario)
33
- end
34
- end
27
+ elements do |file, feature, scenario|
28
+ next if scenario['keyword'] == 'Background'
29
+ yield(file, feature, scenario)
35
30
  end
36
31
  end
37
32
 
38
33
  def filled_scenarios
39
34
  scenarios do |file, feature, scenario|
40
35
  next unless scenario.include? 'steps'
41
- yield(file, feature, scenario)
36
+ yield(file, feature, scenario)
42
37
  end
43
38
  end
44
39
 
45
40
  def steps
46
- @files.each do |file, content|
47
- content.each do |feature|
48
- next unless feature.key? 'elements'
49
- feature['elements'].each do |scenario|
50
- next unless scenario.include? 'steps'
51
- scenario['steps'].each { |step| yield(file, feature, scenario, step) }
52
- end
53
- end
41
+ elements do |file, feature, scenario|
42
+ next unless scenario.include? 'steps'
43
+ scenario['steps'].each { |step| yield(file, feature, scenario, step) }
54
44
  end
55
45
  end
56
46
 
57
47
  def backgrounds
48
+ elements do |file, feature, scenario|
49
+ next unless scenario['keyword'] == 'Background'
50
+ yield(file, feature, scenario)
51
+ end
52
+ end
53
+
54
+ def elements
58
55
  @files.each do |file, content|
59
56
  content.each do |feature|
60
57
  next unless feature.key? 'elements'
61
58
  feature['elements'].each do |scenario|
62
- next unless scenario['keyword'] == 'Background'
63
59
  yield(file, feature, scenario)
64
60
  end
65
61
  end
@@ -5,7 +5,7 @@ module GherkinLint
5
5
  class UnknownVariable < Linter
6
6
  def lint
7
7
  filled_scenarios do |file, feature, scenario|
8
- known_vars = known_variables scenario
8
+ known_vars = Set.new known_variables scenario
9
9
  scenario['steps'].each do |step|
10
10
  step_vars(step).each do |used_var|
11
11
  next if known_vars.include? used_var
@@ -19,12 +19,9 @@ module GherkinLint
19
19
  def step_vars(step)
20
20
  vars = gather_vars step['name']
21
21
  vars += gather_vars step['doc_string']['value'] if step.key? 'doc_string'
22
- if step.key? 'rows'
23
- vars += step['rows'].map do |row|
24
- row['cells'].map { |value| gather_vars value }.flatten
25
- end.flatten
26
- end
27
- vars
22
+ vars + (step['rows'] || []).map do |row|
23
+ row['cells'].map { |value| gather_vars value }.flatten
24
+ end.flatten
28
25
  end
29
26
 
30
27
  def gather_vars(string)
@@ -32,11 +29,10 @@ module GherkinLint
32
29
  end
33
30
 
34
31
  def known_variables(scenario)
35
- return Set.new unless scenario.key? 'examples'
36
- Set.new(scenario['examples'].map do |example|
32
+ (scenario['examples'] || []).map do |example|
37
33
  next unless example.key? 'rows'
38
34
  example['rows'].first['cells'].map(&:strip)
39
- end.flatten)
35
+ end.flatten
40
36
  end
41
37
  end
42
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rohe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-26 00:00:00.000000000 Z
11
+ date: 2016-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - ".rubocop.yml"
77
77
  - ".travis.yml"
78
+ - Dockerfile
78
79
  - Gemfile
79
80
  - Guardfile
80
81
  - LICENSE
@@ -155,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  version: '0'
156
157
  requirements: []
157
158
  rubyforge_project:
158
- rubygems_version: 2.2.3
159
+ rubygems_version: 2.2.5
159
160
  signing_key:
160
161
  specification_version: 4
161
162
  summary: Gherkin Lint