Sha256: 715690d1958a7b36e00a9c1afe0d6792183ab2a2048c23ff1c006bb68071ae39

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 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::Consumer::AppManager.instance.register app, port
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pact-1.5.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.4.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.4.0.rc4 lib/pact/consumer/configuration/service_consumer.rb
pact-1.4.0.rc3 lib/pact/consumer/configuration/service_consumer.rb
pact-1.4.0.rc2 lib/pact/consumer/configuration/service_consumer.rb
pact-1.3.3 lib/pact/consumer/configuration/service_consumer.rb
pact-1.3.2 lib/pact/consumer/configuration/service_consumer.rb
pact-1.3.1 lib/pact/consumer/configuration/service_consumer.rb
pact-1.3.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.2.1.rc2 lib/pact/consumer/configuration/service_consumer.rb
pact-1.2.1.rc1 lib/pact/consumer/configuration/service_consumer.rb
pact-1.1.1 lib/pact/consumer/configuration/service_consumer.rb
pact-1.1.0 lib/pact/consumer/configuration/service_consumer.rb
pact-1.1.0.rc5 lib/pact/consumer/configuration/service_consumer.rb
pact-1.1.0.rc4 lib/pact/consumer/configuration/service_consumer.rb
pact-1.1.0.rc3 lib/pact/consumer/configuration/service_consumer.rb