gherkin_lint 0.0.7 → 0.0.8
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/lib/gherkin_lint.rb +35 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8076c8d55f8396863b12cd5f41ae2737c9e13007
|
4
|
+
data.tar.gz: 8f1d14cddf05a316880920cfb5cc9bc00e3f939e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06aa964f50585bc3e19d1aea1aeb24a1c5e09d82f20207231d5186619cd333bd7f30581faeee47b219be2248e75e80be507fbffd735779490ab11ce670d1b548
|
7
|
+
data.tar.gz: b8748e0175df611f152a221074385709bfae1a120262603129572114a59e77f9bd32ac6854b7b4c09c1a7764c2962a0709f6b82cb0bdf37aede13dbc64a7533c
|
data/lib/gherkin_lint.rb
CHANGED
@@ -555,6 +555,7 @@ class GherkinLint
|
|
555
555
|
def lint
|
556
556
|
features do |file, feature|
|
557
557
|
givens = gather_givens feature
|
558
|
+
next if givens.nil?
|
558
559
|
next if givens.length <= 1
|
559
560
|
next if givens.uniq.length > 1
|
560
561
|
references = [reference(file, feature)]
|
@@ -563,13 +564,43 @@ class GherkinLint
|
|
563
564
|
end
|
564
565
|
|
565
566
|
def gather_givens(feature)
|
567
|
+
return unless feature.include? 'elements'
|
568
|
+
has_non_given_step = false
|
569
|
+
feature['elements'].each do |scenario|
|
570
|
+
next unless scenario.include? 'steps'
|
571
|
+
has_non_given_step = true unless scenario['steps'].first['keyword'] == 'Given '
|
572
|
+
end
|
573
|
+
return if has_non_given_step
|
574
|
+
|
566
575
|
result = []
|
567
|
-
|
576
|
+
expanded_steps(feature) { |given| result.push given }
|
577
|
+
result
|
578
|
+
end
|
579
|
+
|
580
|
+
def expanded_steps(feature)
|
568
581
|
feature['elements'].each do |scenario|
|
569
|
-
next
|
582
|
+
next unless scenario['keyword'] != 'Background'
|
570
583
|
next unless scenario.include? 'steps'
|
571
|
-
|
572
|
-
|
584
|
+
prototypes = [render_step(scenario['steps'].first)]
|
585
|
+
prototypes = expand_examples(scenario['examples'], prototypes) if scenario.key? 'examples'
|
586
|
+
prototypes.each { |prototype| yield prototype }
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
590
|
+
def expand_examples(examples, prototypes)
|
591
|
+
examples.each do |example|
|
592
|
+
prototypes = prototypes.map { |prototype| expand_outlines(prototype, example) }.flatten
|
593
|
+
end
|
594
|
+
prototypes
|
595
|
+
end
|
596
|
+
|
597
|
+
def expand_outlines(sentence, example)
|
598
|
+
result = []
|
599
|
+
headers = example['rows'][0]['cells']
|
600
|
+
example['rows'].slice(1, example['rows'].length).each do |row|
|
601
|
+
modified_sentence = sentence.dup
|
602
|
+
headers.zip(row['cells']).map { |key, value| modified_sentence.gsub!("<#{key}>", value) }
|
603
|
+
result.push modified_sentence
|
573
604
|
end
|
574
605
|
result
|
575
606
|
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.
|
4
|
+
version: 0.0.8
|
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-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|