Class: Cucumber::Gherkin::StepsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/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/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/gherkin/steps_parser.rb', line 9

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

Instance Method Details

#feature_header(dialect) ⇒ Object



35
36
37
38
39
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/gherkin/steps_parser.rb', line 35

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

#gherkin_optionsObject



26
27
28
29
30
31
32
33
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/gherkin/steps_parser.rb', line 26

def gherkin_options
  {
    default_dialect: @language,
    include_source: false,
    include_gherkin_document: true,
    include_pickles: false
  }
end

#parse(text) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/gherkin/steps_parser.rb', line 14

def parse(text)
  dialect = ::Gherkin::Dialect.for(@language)
  gherkin_document = nil
  messages = ::Gherkin.from_source('dummy', feature_header(dialect) + text, gherkin_options)

  messages.each do |message|
    gherkin_document = message.gherkin_document.to_h unless message.gherkin_document.nil?
  end

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