Sha256: 2fa90778e51a993d3a081b783ad89bfa2ce9f0bb5b24e6e703e7869102f33f1f

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'gherkin/gherkin'
require 'gherkin/dialect'

module Cucumber
  module Gherkin
    class StepsParser
      def initialize(builder, language)
        @builder = builder
        @language = language
      end

      def parse(text)
        dialect = ::Gherkin::Dialect.for(@language)
        gherkin_document = nil
        messages = ::Gherkin::Gherkin.from_source('dummy', feature_header(dialect) + text, default_dialect: @language, include_source: false, include_pickles: false)
        messages.each do |message|
          gherkin_document = message.gherkinDocument.to_hash unless message.gherkinDocument.nil?
        end

        @builder.steps(gherkin_document[:feature][:children][0][:scenario][:steps])
      end

      def feature_header(dialect)
        %(#{dialect.feature_keywords[0]}:
            #{dialect.scenario_keywords[0]}:
         )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-4.0.0.rc.1 lib/cucumber/gherkin/steps_parser.rb