Sha256: 1b0bbcc4367f097e54ab0d7e82f41288cec75b5d0e5c97380242e38ce61266ef

Contents?: true

Size: 916 Bytes

Versions: 18

Compression:

Stored size: 916 Bytes

Contents

require 'cucumber/formatter/errors'

module Cucumber
  module Formatter
    module Query
      class HookByTestStep
        def initialize(config)
          @hook_id_by_test_step_id = {}

          config.on_event :test_step_created, &method(:on_test_step_created)
          config.on_event :hook_test_step_created, &method(:on_hook_test_step_created)
        end

        def hook_id(test_step)
          return @hook_id_by_test_step_id[test_step.id] if @hook_id_by_test_step_id.key?(test_step.id)
          raise TestStepUnknownError, "No hook found for #{test_step.id} }. Known: #{@hook_id_by_test_step_id.keys}"
        end

        private

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

        def on_hook_test_step_created(event)
          @hook_id_by_test_step_id[event.test_step.id] = event.hook.id
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-7.1.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-7.0.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-6.1.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-6.0.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.3.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.2.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.1.3 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.1.2 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.1.1 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.1.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-5.0.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.1.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.0.1 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.0.0 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.0.0.rc.6 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.0.0.rc.5 lib/cucumber/formatter/query/hook_by_test_step.rb
cucumber-4.0.0.rc.4 lib/cucumber/formatter/query/hook_by_test_step.rb