class Pact::Provider::Configuration::PactVerificationFromBroker

Attributes

_basic_auth_options[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_consumer_version_selectors[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_consumer_version_tags[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_enable_pending[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_fail_if_no_pacts_found[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_include_wip_pacts_since[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_pact_broker_base_url[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_provider_name[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_provider_version_branch[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_provider_version_tags[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

_verbose[RW]

If user declares a variable with the same name as one of these attributes in parent scope, it will clash with these ones, so put an underscore in front of the name to be safer.

Public Class Methods

new(provider_name, provider_version_branch, provider_version_tags) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 20
def initialize(provider_name, provider_version_branch, provider_version_tags)
  @_provider_name = provider_name
  @_provider_version_branch = provider_version_branch
  @_provider_version_tags = provider_version_tags
  @_consumer_version_tags = []
  @_consumer_version_selectors = []
  @_enable_pending = false
  @_include_wip_pacts_since = nil
  @_verbose = false
  @_fail_if_no_pacts_found = true # CLI defaults to false, unfortunately for consistency
end

Public Instance Methods

consumer_version_selectors(consumer_version_selectors) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 42
def consumer_version_selectors consumer_version_selectors
  self._consumer_version_selectors = *consumer_version_selectors
end
consumer_version_tags(consumer_version_tags) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 38
def consumer_version_tags consumer_version_tags
  self._consumer_version_tags = *consumer_version_tags
end
enable_pending(enable_pending) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 46
def enable_pending enable_pending
  self._enable_pending = enable_pending
end
fail_if_no_pacts_found(fail_if_no_pacts_found) click to toggle source

Underlying code defaults to true if not specified

# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 51
def fail_if_no_pacts_found fail_if_no_pacts_found
  self._fail_if_no_pacts_found = fail_if_no_pacts_found
end
finalize() click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 68
def finalize
  validate
  create_pact_verification
end
include_wip_pacts_since(since) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 55
def include_wip_pacts_since since
  self._include_wip_pacts_since = if since.respond_to?(:xmlschema)
    since.xmlschema
  else
    since
  end
end
pact_broker_base_url(pact_broker_base_url, basic_auth_options = {}) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 33
def pact_broker_base_url pact_broker_base_url, basic_auth_options = {}
  self._pact_broker_base_url = pact_broker_base_url
  self._basic_auth_options = basic_auth_options
end
verbose(verbose) click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 63
def verbose verbose
  self._verbose = verbose
end

Private Instance Methods

convert_consumer_version_selectors() click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 112
def convert_consumer_version_selectors
  _consumer_version_selectors.collect do | selector |
    selector.each_with_object({}) do | (key, value), new_selector |
      new_selector[Pact::Utils::String.camelcase(key.to_s).to_sym] = value
    end
  end
end
convert_tags_to_selectors() click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 93
def convert_tags_to_selectors
  _consumer_version_tags.collect do | tag |
    if tag.is_a?(Hash)
      {
        tag: tag.fetch(:name),
        latest: !tag[:all],
        fallbackTag: tag[:fallback]
      }
    elsif tag.is_a?(String)
      {
        tag: tag,
        latest: true
      }
    else
      raise Pact::Error.new("The value supplied for consumer_version_tags must be a String or a Hash. Found #{tag.class}")
    end
  end
end
create_pact_verification() click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 75
def create_pact_verification
  fetch_pacts = Pact::PactBroker::FetchPactURIsForVerification.new(
    _provider_name,
    consumer_version_selectors,
    _provider_version_branch,
    _provider_version_tags,
    _pact_broker_base_url,
    _basic_auth_options.merge(verbose: _verbose),
    { include_pending_status: _enable_pending, include_wip_pacts_since: _include_wip_pacts_since, fail_if_no_pacts_found: _fail_if_no_pacts_found }
  )

  Pact.provider_world.add_pact_uri_source fetch_pacts
end
validate() click to toggle source
# File lib/pact/provider/configuration/pact_verification_from_broker.rb, line 120
def validate
  raise Pact::Error.new("Please provide a pact_broker_base_url from which to retrieve the pacts") unless _pact_broker_base_url
end