Sha256: 9fb62ee4c638eb87ed0350c26e2233451b80f1ecc5ac6c5b0c3d583c3fc78669

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

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 if contract_builder
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-messages-0.1.1 lib/pact/messages/consumer/world.rb
pact-messages-0.1.0 lib/pact/messages/consumer/world.rb