Sha256: da9091100edd4c9dda9c4b903ceb18f762acd30267763223a99a8a8efbe67bcf

Contents?: true

Size: 755 Bytes

Versions: 8

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

require 'cucumber/formatter/errors'

module Cucumber
  module Formatter
    module Query
      class PickleByTest
        def initialize(config)
          @pickle_id_by_test_case_id = {}
          config.on_event :test_case_created, &method(:on_test_case_created)
        end

        def pickle_id(test_case)
          return @pickle_id_by_test_case_id[test_case.id] if @pickle_id_by_test_case_id.key?(test_case.id)

          raise TestCaseUnknownError, "No pickle found for #{test_case.id} }. Known: #{@pickle_id_by_test_case_id.keys}"
        end

        private

        def on_test_case_created(event)
          @pickle_id_by_test_case_id[event.test_case.id] = event.pickle.id
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
cucumber-9.2.1 lib/cucumber/formatter/query/pickle_by_test.rb
cucumber-9.2.0 lib/cucumber/formatter/query/pickle_by_test.rb
cucumber-9.1.2 lib/cucumber/formatter/query/pickle_by_test.rb
cucumber-9.1.1 lib/cucumber/formatter/query/pickle_by_test.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/formatter/query/pickle_by_test.rb
cucumber-9.1.0 lib/cucumber/formatter/query/pickle_by_test.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/formatter/query/pickle_by_test.rb
cucumber-9.0.2 lib/cucumber/formatter/query/pickle_by_test.rb