Sha256: cf3914435ad8c50e7bea46f7536a8b4c82282f758c9475e1516e730309b834fa

Contents?: true

Size: 902 Bytes

Versions: 8

Compression:

Stored size: 902 Bytes

Contents

require 'gherkin/parser'
require 'gherkin/pickles/compiler'

def ensure_features_format files
  files.each do |file_path|
    ensure_feature_has_unique_tags file_path
  end
end

def ensure_feature_has_unique_tags file_path
  parser = Gherkin::Parser.new
  file = open(file_path)
  content = file.read
  gherkin_document = parser.parse(content)
  pickles = Gherkin::Pickles::Compiler.new.compile(gherkin_document)
  tag_hash = {}
  pickles.each do |scenario|
    raise "Scenario '#{scenario[:name]}' can't have more than one @user{int} tag." if scenario[:tags].select{ |tag| tag[:name].start_with? "@user" }.count > 1
    scenario[:tags].each do |tag|
      tag_name = tag[:name]
      if tag_hash[tag_name]
        raise "Tag #{tag_name} is duplicated. Each feature can only have one @user{:int} tag assigned to a scenario."
      else
        tag_hash[tag_name] = tag_name
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kraken-mobile-1.0.9 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.8 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.5 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.4 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.3 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.2 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.1 lib/kraken-mobile/helpers/feature_analyzer.rb
kraken-mobile-1.0.0 lib/kraken-mobile/helpers/feature_analyzer.rb