Sha256: 18bbaea71a88da7612015abf503985ec4792e818311e704a113a6777d513dcf7

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

module Pact
  module Consumer
    class Verification

      def initialize expected_interactions, actual_interactions
        @expected_interactions = expected_interactions
        @actual_interactions = actual_interactions
      end

      def all_matched?
        interaction_diffs.empty?
      end

      def interaction_diffs
        {
          :missing_interactions => missing_interactions_summaries,
          :interaction_mismatches => interaction_mismatches_summaries,
          :unexpected_requests => unexpected_requests_summaries
        }.each_with_object({}) do | (key, value), hash |
          hash[key] = value if value.any?
        end
      end

      def missing_interactions_summaries
        missing_interactions.collect(&:request).collect(&:method_and_path)
      end

      def interaction_mismatches_summaries
        actual_interactions.interaction_mismatches.collect(&:short_summary)
      end

      def unexpected_requests_summaries
        actual_interactions.unexpected_requests.collect(&:method_and_path)
      end

      def missing_interactions
        expected_interactions - actual_interactions.matched_interactions - @actual_interactions.interaction_mismatches.collect(&:candidate_interactions).flatten
      end

      private

      attr_reader :expected_interactions, :actual_interactions

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact-mock_service-0.2.4 lib/pact/consumer/mock_service/verification.rb
pact-mock_service-0.2.3 lib/pact/consumer/mock_service/verification.rb
pact-mock_service-0.2.3.pre.rc2 lib/pact/consumer/mock_service/verification.rb
pact-mock_service-0.2.3.pre.rc1 lib/pact/consumer/mock_service/verification.rb