Sha256: 33a3208b16d821e60a0abf3bc7898e4b968415ee3a893ccbe497d83285aeb742

Contents?: true

Size: 952 Bytes

Versions: 29

Compression:

Stored size: 952 Bytes

Contents

require 'pact/reification'

# Represents the Interaction in the form required by the MockService
# The json generated will be posted to the MockService to register the expectation
module Pact
  module Consumer
    class MockServiceInteractionExpectation


      def initialize interaction
        @interaction = interaction
      end

      def to_hash
        hash = {:description => interaction.description}
        hash[:provider_state] = interaction.provider_state if interaction.provider_state
        options = interaction.request.options.empty? ? {} : { options: interaction.request.options}
        hash[:request] = interaction.request.as_json.merge(options)
        hash[:response] = Reification.from_term(interaction.response)
        hash
      end

      def as_json options = {}
        to_hash
      end

      def to_json opts = {}
        as_json.to_json(opts)
      end

      private

      attr_reader :interaction

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pact-1.1.1 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0.rc5 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0.rc4 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0.rc3 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.39 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0.rc2 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.38 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.1.0.rc1 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.37 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.36 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.35 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.34 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.33 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.32 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.31 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.30 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.29 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.28 lib/pact/consumer/mock_service_interaction_expectation.rb
pact-1.0.27 lib/pact/consumer/mock_service_interaction_expectation.rb