class Pact::Messages::Consumer::ContractBuilder
Attributes
consumer_name[R]
interaction_builder[W]
mock_service_client[R]
provider_name[R]
Public Class Methods
new(attributes)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 16 def initialize(attributes) @consumer_name = attributes.fetch(:consumer_name) @provider_name = attributes.fetch(:provider_name) @consumer_contract_details = { consumer: { name: @consumer_name }, provider: { name: @provider_name }, pactfile_write_mode: attributes[:pactfile_write_mode].to_s, pact_dir: attributes.fetch(:pact_dir), } @interaction_builder = nil @interactions = [] end
Public Instance Methods
consumer_contract()
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 51 def consumer_contract @consumer_contract ||= Pact::ConsumerContract.new( consumer: Pact::ServiceConsumer.new(name: @consumer_name), provider: Pact::ServiceProvider.new(name: @provider_name), interactions: @interactions, ) end
given(provider_state)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 29 def given(provider_state) interaction_builder.given(provider_state) end
handle_interaction_fully_defined(interaction)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 59 def handle_interaction_fully_defined(interaction) @interactions << interaction @interaction_builder = nil end
log(msg)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 41 def log(msg) logger.log(msg) end
provide(message)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 33 def provide(message) interaction_builder.provide(message) end
verify(_example_description)
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 37 def verify(_example_description) true # TODO: find out how the verification works in original pact end
write_pact()
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 45 def write_pact consumer_contract_params = @consumer_contract_details.merge(interactions: @interactions) consumer_contract_writer = Pact::ConsumerContractWriter.new(consumer_contract_params, logger) consumer_contract_writer.write end
Private Instance Methods
interaction_builder()
click to toggle source
# File lib/pact/messages/consumer/contract_builder.rb, line 69 def interaction_builder @interaction_builder ||= begin interaction_builder = InteractionBuilder.new do |interaction| handle_interaction_fully_defined(interaction) self end interaction_builder end end