Sha256: 1151dc22cdafeacde970341983786e384a490d97e97d380cdfab9b2c896dae31

Contents?: true

Size: 1.47 KB

Versions: 26

Compression:

Stored size: 1.47 KB

Contents

require 'cucumber/formatter/errors'

module Cucumber
  module Formatter
    module Query
      class StepDefinitionsByTestStep
        def initialize(config)
          @step_definition_ids_by_test_step_id = {}
          @step_match_arguments_by_test_step_id = {}

          config.on_event :test_step_created, &method(:on_test_step_created)
          config.on_event :step_activated, &method(:on_step_activated)
        end

        def step_definition_ids(test_step)
          return @step_definition_ids_by_test_step_id[test_step.id] if @step_definition_ids_by_test_step_id.key?(test_step.id)

          raise TestStepUnknownError, "No step definition found for #{test_step.id} }. Known: #{@step_definition_ids_by_test_step_id.keys}"
        end

        def step_match_arguments(test_step)
          return @step_match_arguments_by_test_step_id[test_step.id] if @step_match_arguments_by_test_step_id.key?(test_step.id)

          raise TestStepUnknownError, "No step match arguments found for #{test_step.id} }. Known: #{@step_match_arguments_by_test_step_id.keys}"
        end

        private

        def on_test_step_created(event)
          @step_definition_ids_by_test_step_id[event.test_step.id] = []
        end

        def on_step_activated(event)
          @step_definition_ids_by_test_step_id[event.test_step.id] << event.step_match.step_definition.id
          @step_match_arguments_by_test_step_id[event.test_step.id] = event.step_match.step_arguments
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
cucumber-9.0.1 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-9.0.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/query/step_definitions_by_test_step.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/query/step_definitions_by_test_step.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/query/step_definitions_by_test_step.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-8.0.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-8.0.0.rc.1 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-7.1.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-7.0.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-6.1.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-6.0.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.3.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.2.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.1.3 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.1.2 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.1.1 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.1.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb
cucumber-5.0.0 lib/cucumber/formatter/query/step_definitions_by_test_step.rb