Sha256: 34aa896d72db842f10e68aff23c4041f43b2227626ed1ff1230481b39254f773

Contents?: true

Size: 1.01 KB

Versions: 100

Compression:

Stored size: 1.01 KB

Contents

require 'pact/shared/dsl'

module Pact
  module Consumer
    module Configuration
      class ServiceConsumer

        extend Pact::DSL

        attr_accessor :app, :port, :name

        def initialize name
          @name = name
          @app = nil
          @port = nil
        end

        dsl do
          def app app
            self.app = app
          end

          def port port
            self.port = port
          end

          def has_pact_with service_provider_name, &block
            ServiceProvider.build(service_provider_name, name, &block)
          end
        end

        def finalize
          validate
          register_consumer_app if @app
        end

        private

        def validate
          raise "Please provide a consumer name" unless (name && !name.empty?)
          raise "Please provide a port for the consumer app" if app && !port
        end


        def register_consumer_app
          Pact::MockService::AppManager.instance.register app, port
        end
      end
    end
  end
end

Version data entries

100 entries across 100 versions & 1 rubygems

Version Path
pact-1.65.3 lib/pact/consumer/configuration/service_consumer.rb
pact-1.65.2 lib/pact/consumer/configuration/service_consumer.rb
pact-1.65.1 lib/pact/consumer/configuration/service_consumer.rb
pact-1.65.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.64.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.63.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.62.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.61.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.60.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.59.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.58.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.57.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.56.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.7 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.6 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.5 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.4 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.3 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.2 lib/pact/consumer/configuration/service_consumer.rb
pact-1.55.1 lib/pact/consumer/configuration/service_consumer.rb