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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gherkin_lint.rb +35 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9e8a5aaa0c37236e2c5570757cbd5aeb5436fb0
4
- data.tar.gz: 5eb318102e3fbafc07e20be4df639b44a9a93d6b
3
+ metadata.gz: 8076c8d55f8396863b12cd5f41ae2737c9e13007
4
+ data.tar.gz: 8f1d14cddf05a316880920cfb5cc9bc00e3f939e
5
5
  SHA512:
6
- metadata.gz: 0eaca00ca42656f88f8a62b4a60a3d2f7b1155c1803ee59dfeaa6b0d9d6f63d508e2fac3ff970b54c4a0ce22ef73a69dc8c44365e6a265c1ab57c772a822eb1a
7
- data.tar.gz: 154f3faf5dad974270909cfe7971044543f9ba25d0e1ab44a6ad42a7c58e658ca1a41576e4ad57c82c47910f3aa9a3966b23416e224fd9864075f2628f2a0984
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
- return result unless feature.include? 'elements'
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 if scenario['keyword'] == 'Background'
582
+ next unless scenario['keyword'] != 'Background'
570
583
  next unless scenario.include? 'steps'
571
- return [] unless scenario['steps'].first['keyword'] == 'Given '
572
- result.push render_step scenario['steps'].first
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.7
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-21 00:00:00.000000000 Z
11
+ date: 2015-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin