Class: PactBroker::Pacts::VerifiablePactMessages

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pact_broker/pacts/verifiable_pact_messages.rb

Constant Summary collapse

READ_MORE_PENDING =
"Read more at https://pact.io/pending"
READ_MORE_WIP =
"Read more at https://pact.io/wip"

Instance Method Summary collapse

Constructor Details

#initialize(verifiable_pact) ⇒ VerifiablePactMessages

Returns a new instance of VerifiablePactMessages.



11
12
13
# File 'lib/pact_broker/pacts/verifiable_pact_messages.rb', line 11

def initialize(verifiable_pact)
  @verifiable_pact = verifiable_pact
end

Instance Method Details

#inclusion_reasonObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pact_broker/pacts/verifiable_pact_messages.rb', line 15

def inclusion_reason
  version_text = head_consumer_tags.size == 1 ? "version" : "versions"
  if wip?
    # WIP pacts will always have tags, because it is part of the definition of being a WIP pact
    "This pact is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest #{version_text} of Foo tagged with #{joined_head_consumer_tags} and is still in pending state). #{READ_MORE_WIP}"
  else
    if head_consumer_tags.any?
      "This pact is being verified because it is the pact for the latest #{version_text} of Foo tagged with #{joined_head_consumer_tags}"
    else
      "This pact is being verified because it is the latest pact between #{consumer_name} and #{provider_name}."
    end
  end
end

#pending_reasonObject



29
30
31
32
33
34
35
# File 'lib/pact_broker/pacts/verifiable_pact_messages.rb', line 29

def pending_reason
  if pending?
    "This pact is in pending state because it has not yet been successfully verified by #{pending_provider_tags_description}. If this verification fails, it will not cause the overall build to fail. #{READ_MORE_PENDING}"
  else
    "This pact has previously been successfully verified by #{non_pending_provider_tags_description}. If this verification fails, it will fail the build. #{READ_MORE_PENDING}"
  end
end