class Pact::Message::Consumer::ConsumerContractBuilder
Attributes
consumer_contract_details[RW]
consumer_name[RW]
contents[RW]
interactions[RW]
pact_dir[RW]
pact_specification_version[RW]
provider_name[RW]
Public Class Methods
new(attributes)
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 10 def initialize(attributes) @interaction_builder = nil @consumer_name = attributes[:consumer_name] @provider_name = attributes[:provider_name] @pact_specification_version = attributes[:pact_specification_version] @pact_dir = attributes[:pact_dir] @interactions = [] @yielded_interaction = false end
Public Instance Methods
given(provider_state, params = {})
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 25 def given(provider_state, params = {}) interaction_builder.given(provider_state, params) end
handle_interaction_fully_defined(interaction)
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 55 def handle_interaction_fully_defined(interaction) @contents = interaction.contents @contents_string = interaction.contents.to_s end
is_expected_to_send(description)
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 29 def is_expected_to_send(description) interaction_builder.is_expected_to_send(provider_state) end
reset()
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 20 def reset @interaction_builder = nil @yielded_interaction = false end
send_message_hash() { |interaction.reified_contents_hash| ... }
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 44 def send_message_hash if interaction_builder? if block_given? @yielded_interaction = true yield interaction_builder.interaction.contents.reified_contents_hash end else raise Pact::Error.new("No message expectation has been defined") end end
send_message_string() { |interaction.reified_contents_string| ... }
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 33 def send_message_string if interaction_builder? if block_given? @yielded_interaction = true yield interaction_builder.interaction.contents.reified_contents_string end else raise Pact::Error.new("No message expectation has been defined") end end
verify(example_description)
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 60 def verify example_description # There may be multiple message providers defined, and not every one of them # has to define a message for every test. if interaction_builder? if yielded_interaction? interactions << interaction_builder.interaction else raise Pact::Error.new("`send_message_string` was not called for message \"#{interaction_builder.interaction.description}\"") end end end
write_pact()
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 72 def write_pact Pact::Message::Consumer::WritePact.call(interactions, pact_dir, consumer_name, provider_name, pact_specification_version, :overwrite) end
Private Instance Methods
interaction_builder()
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 88 def interaction_builder @interaction_builder ||= begin interaction_builder = InteractionBuilder.new do | interaction | handle_interaction_fully_defined(interaction) end interaction_builder end end
interaction_builder?()
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 80 def interaction_builder? !!@interaction_builder end
yielded_interaction?()
click to toggle source
# File lib/pact/message/consumer/consumer_contract_builder.rb, line 84 def yielded_interaction? @yielded_interaction end