Sha256: ba1c2fb01c933c9d8f0dd424826ffb8b59e2202e1ef897f64ad69a2f09b5246d
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true require 'gherkin' require 'gherkin/dialect' module Cucumber module Gherkin class DataTableParser def initialize(builder) @builder = builder end def parse(text) gherkin_document = nil messages = ::Gherkin.from_source('dummy', feature_header + text, gherkin_options) messages.each do |message| gherkin_document = message.gherkinDocument.to_hash unless message.gherkinDocument.nil? end return if gherkin_document.nil? gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row| @builder.row(row[:cells].map { |cell| cell[:value] }) end end def gherkin_options { include_source: false, include_gherkin_document: true, include_pickles: false } end def feature_header dialect = ::Gherkin::Dialect.for('en') %(#{dialect.feature_keywords[0]}: #{dialect.scenario_keywords[0]}: #{dialect.given_keywords[0]} x ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cucumber-4.0.0.rc.3 | lib/cucumber/gherkin/data_table_parser.rb |
cucumber-4.0.0.rc.2 | lib/cucumber/gherkin/data_table_parser.rb |