class Pact::Message::Consumer::ConsumerContractBuilder

Attributes

consumer_contract_details[RW]
consumer_name[RW]
interaction_builder[W]
provider_name[RW]

Public Class Methods

new(attributes) click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 9
def initialize(attributes)
  @interaction_builder = nil
  @consumer_name = attributes[:consumer_name]
  @provider_name = attributes[:provider_name]
  @interactions = []
end

Public Instance Methods

given(provider_state) click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 16
def given(provider_state)
  interaction_builder.given(provider_state)
end
handle_interaction_fully_defined(interaction) click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 29
def handle_interaction_fully_defined(interaction)
  @contents_string = interaction.contents.to_s
  @interactions << interaction
  @interaction_builder = nil
  # TODO pull these from pact config
  Pact::Message::Consumer::UpdatePact.call(interaction, "./spec/pacts", consumer_name, provider_name, "2.0.0")
end
is_expected_to_send(description) click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 20
def is_expected_to_send(description)
  interaction_builder.is_expected_to_send(provider_state)
end
send_message() { |contents_string| ... } click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 24
def send_message
  # TODO handle matchers
  yield @contents_string if block_given?
end
verify(example_description) click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 37
def verify example_description
  #
  # TODO check that message was actually yielded
end

Private Instance Methods

interaction_builder() click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 47
def interaction_builder
  @interaction_builder ||=
  begin
    interaction_builder = InteractionBuilder.new do | interaction |
      handle_interaction_fully_defined(interaction)
    end
    interaction_builder
  end
end