gherkin_lint 0.0.9 → 0.0.10

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 +27 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11cc0a47c8a7370b13d39e6d4dc5fcaa3b053107
4
- data.tar.gz: f6bb350fc776da6541e866596f431335d77421c5
3
+ metadata.gz: 2e4d03b90d6a2f4bd7636cac2dd5431826c9d24d
4
+ data.tar.gz: 2aedfa50a7bf08385172fa3aa0be2abf10b678a2
5
5
  SHA512:
6
- metadata.gz: 529b9779a5e7e05269b6bf41dd06a4b8cc47f11f5a175a3d7631fc5b54e8d6346adc7c2e204cdac94a4b0c7a1077408b7fa0329fb8f71bb267a9987f0d0844a5
7
- data.tar.gz: 51c2705c48aa1f5b6d0336a3070abeedc7dc0a63273818f47f61c9090a5a635b86dc27342720f26df95e6e3062805f3c733ba3141cc1ebdece99234d317d9516
6
+ metadata.gz: 0b83df2773e425662bd91751a4fc4e69cf537c8818cf006807d9cee20d8f8d95dbb15473fe45e53ed67748989025e9aeea12fcc86ff3abde9fdba45cfa9be795
7
+ data.tar.gz: 907364cb9b95b90dc1d1a1beaa0c2a03a6ba9d6366d44a724d5398192d862a1c3df4ea6c8bdba7f8f8086cc0d1d032ca46abf99d73e0ad331275bd6d7f9692f3
data/lib/gherkin_lint.rb CHANGED
@@ -521,6 +521,22 @@ class GherkinLint
521
521
  end
522
522
  end
523
523
 
524
+ # service class to lint for avoiding outline for single example
525
+ class AvoidOutlineForSingleExample < Linter
526
+ def lint
527
+ scenarios do |file, feature, scenario|
528
+ next unless scenario['keyword'] == 'Scenario Outline'
529
+
530
+ next unless scenario.key? 'examples'
531
+ next if scenario['examples'].length > 1
532
+ next if scenario['examples'].first['rows'].length > 2
533
+
534
+ references = [reference(file, feature, scenario)]
535
+ add_issue(references, 'Better write a scenario')
536
+ end
537
+ end
538
+ end
539
+
524
540
  # service class to lint for using same tag on all scenarios
525
541
  class SameTagForAllScenarios < Linter
526
542
  def lint
@@ -554,6 +570,7 @@ class GherkinLint
554
570
  class UseBackground < Linter
555
571
  def lint
556
572
  features do |file, feature|
573
+ next if scenarios_with_steps(feature) <= 1
557
574
  givens = gather_givens feature
558
575
  next if givens.nil?
559
576
  next if givens.length <= 1
@@ -563,17 +580,23 @@ class GherkinLint
563
580
  end
564
581
  end
565
582
 
583
+ def scenarios_with_steps(feature)
584
+ scenarios = 0
585
+ feature['elements'].each do |scenario|
586
+ next unless scenario.include? 'steps'
587
+ scenarios += 1
588
+ end
589
+ scenarios
590
+ end
591
+
566
592
  def gather_givens(feature)
567
593
  return unless feature.include? 'elements'
568
594
  has_non_given_step = false
569
- scenarios = 0
570
595
  feature['elements'].each do |scenario|
571
596
  next unless scenario.include? 'steps'
572
- scenarios += 1
573
597
  has_non_given_step = true unless scenario['steps'].first['keyword'] == 'Given '
574
598
  end
575
599
  return if has_non_given_step
576
- return if scenarios <= 1
577
600
 
578
601
  result = []
579
602
  expanded_steps(feature) { |given| result.push given }
@@ -654,6 +677,7 @@ class GherkinLint
654
677
 
655
678
  LINTER = [
656
679
  AvoidPeriod,
680
+ AvoidOutlineForSingleExample,
657
681
  BackgroundDoesMoreThanSetup,
658
682
  BackgroundRequiresMultipleScenarios,
659
683
  BadScenarioName,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rohe