Class: Pact::Message::Consumer::ConsumerContractBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/message/consumer/consumer_contract_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ ConsumerContractBuilder

Returns a new instance of ConsumerContractBuilder.



9
10
11
12
13
14
# 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

Instance Method Details

#given(provider_state) ⇒ Object



16
17
18
# 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) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 28

def handle_interaction_fully_defined(interaction)
  @contents = interaction.contents
  @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) ⇒ Object



20
21
22
# 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_string {|contents.reified_contents_string| ... } ⇒ Object

Yields:

  • (contents.reified_contents_string)


24
25
26
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 24

def send_message_string
  yield contents.reified_contents_string if block_given?
end

#verify(example_description) ⇒ Object



37
38
39
40
# File 'lib/pact/message/consumer/consumer_contract_builder.rb', line 37

def verify example_description
  #
  # TODO check that message was actually yielded
end