Class: Cucumber::Gherkin::StepsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/gherkin/steps_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(builder, language) ⇒ StepsParser

Returns a new instance of StepsParser.


9
10
11
12
# File 'lib/cucumber/gherkin/steps_parser.rb', line 9

def initialize(builder, language)
  @builder = builder
  @language = language
end

Instance Method Details

#feature_header(dialect) ⇒ Object


25
26
27
28
29
# File 'lib/cucumber/gherkin/steps_parser.rb', line 25

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

#parse(text) ⇒ Object


14
15
16
17
18
19
20
21
22
23
# File 'lib/cucumber/gherkin/steps_parser.rb', line 14

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