Sha256: 41b687165203da3920ea129a9644ec93912042296bb06bfa05f184a24bfb3d8c

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

module Pact
  module Messages
    def self.consumer_world
      @consumer_world ||= Pact::Messages::Consumer::World.new
    end

    # internal api, for testing only
    def self.clear_consumer_world
      @consumer_world = nil
    end

    def self.logger
      @logger ||= Logger.new(STDOUT)
    end

    module Consumer
      class World
        attr_reader :mock_services

        def initialize
          @mock_services = {}
        end

        def register_mock_service(mock_service_name, contract_builder)
          mock_services[mock_service_name] = contract_builder
        end

        def find_contract_builder(mock_service_name)
          mock_services[mock_service_name]
        end

        def find_contract(provider_name, consumer_name)
          contract_builder = mock_services.values.find do |builder|
            builder.provider_name == provider_name && builder.consumer_name == consumer_name
          end
          contract_builder&.consumer_contract
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-messages-0.2.0 lib/pact/messages/consumer/world.rb