Sha256: 984f76a9dad4907b0f10b9ba18221b66f79350b4b2680afe83eeb98847adfe48

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true
require 'cucumber/core/event_bus'
require 'cucumber/core/gherkin/parser'
require 'cucumber/core/gherkin/document'
require 'cucumber/core/compiler'
require 'cucumber/core/test/runner'

module Cucumber
  module Core

    def execute(gherkin_documents, filters = [], event_bus = EventBus.new)
      yield event_bus if block_given?
      receiver = Test::Runner.new(event_bus)
      compile gherkin_documents, receiver, filters
      self
    end

    def compile(gherkin_documents, last_receiver, filters = [], event_bus = EventBus.new)
      first_receiver = compose(filters, last_receiver)
      compiler = Compiler.new(first_receiver)
      parse gherkin_documents, compiler, event_bus
      self
    end

    private

    def parse(gherkin_documents, compiler, event_bus)
      parser = Core::Gherkin::Parser.new(compiler, event_bus)
      gherkin_documents.each do |document|
        parser.document document
      end
      parser.done
      self
    end

    def compose(filters, last_receiver)
      filters.reverse.reduce(last_receiver) do |receiver, filter|
        filter.with_receiver(receiver)
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb
cucumber-core-5.0.2 lib/cucumber/core.rb
cucumber-core-5.0.1 lib/cucumber/core.rb
cucumber-core-5.0.0 lib/cucumber/core.rb
cucumber-core-4.0.0 lib/cucumber/core.rb
cucumber-core-3.2.1 lib/cucumber/core.rb
cucumber-core-3.2.0 lib/cucumber/core.rb