lib/pact/mock_service/session.rb in pact-mock_service-2.2.0 vs lib/pact/mock_service/session.rb in pact-mock_service-2.3.0

- old
+ new

@@ -1,35 +1,42 @@ require 'pact/mock_service/interactions/expected_interactions' require 'pact/mock_service/interactions/actual_interactions' require 'pact/mock_service/interactions/verified_interactions' require 'pact/mock_service/interaction_decorator' require 'pact/mock_service/interactions/interaction_diff_message' +require 'pact/mock_service/errors' module Pact module MockService - - class AlmostDuplicateInteractionError < StandardError; end - class Session attr_reader :expected_interactions, :actual_interactions, :verified_interactions, :consumer_contract_details, :logger def initialize options + @pact_written = false @logger = options[:logger] @expected_interactions = Interactions::ExpectedInteractions.new @actual_interactions = Interactions::ActualInteractions.new @verified_interactions = Interactions::VerifiedInteractions.new @consumer_contract_details = { pact_dir: options[:pact_dir], - unique_pact_file_names: options[:unique_pact_file_names], consumer: {name: options[:consumer]}, provider: {name: options[:provider]}, interactions: verified_interactions, - pact_specification_version: options[:pact_specification_version] + pact_specification_version: options[:pact_specification_version], + pactfile_write_mode: options[:pactfile_write_mode] } end + def pact_written? + @pact_written + end + + def record_pact_written + @pact_written = true + end + def set_expected_interactions interactions clear_expected_and_actual_interactions interactions.each do | interaction | add_expected_interaction interaction end @@ -42,10 +49,11 @@ def clear_all expected_interactions.clear actual_interactions.clear verified_interactions.clear + @pact_written = false end def add_expected_interaction interaction if (previous_interaction = interaction_already_verified_with_same_description_and_provider_state_but_not_equal(interaction)) handle_almost_duplicate_interaction previous_interaction, interaction @@ -63,10 +71,10 @@ end def handle_almost_duplicate_interaction previous_interaction, interaction message = Interactions::InteractionDiffMessage.new(previous_interaction, interaction).to_s logger.error message - raise AlmostDuplicateInteractionError, message + raise SameSameButDifferentError, message end def interaction_already_verified_with_same_description_and_provider_state_but_not_equal interaction other = verified_interactions.find_matching_description_and_provider_state interaction other && other != interaction ? other : nil