Sha256: 5ccd97eead26c7c3b260d5de2e7238dc8e64f77b5aa4330fe5a68e023facc0fd

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

require 'pact/shared/active_support_support'
require 'pact/mock_service/request_decorator'
require 'pact/mock_service/response_decorator'

# 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 MockService
    class InteractionDecorator

      include ActiveSupportSupport

      def initialize interaction
        @interaction = interaction
      end

      def as_json options = {}
        fix_all_the_things to_hash
      end

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

      def to_hash
        hash = { :description => interaction.description }
        hash[:providerState] = interaction.provider_state if interaction.provider_state
        hash[:request] = decorate_request.as_json
        hash[:response] = decorate_response.as_json
        hash[:metadata] = interaction.metadata
        hash
      end

      private

      attr_reader :interaction

      def decorate_request
        RequestDecorator.new(interaction.request)
      end

      def decorate_response
        ResponseDecorator.new(interaction.response)
      end

    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
pact-mock_service-3.12.3 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.12.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.12.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.12.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.11.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.11.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.11.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.10.0 lib/pact/mock_service/interaction_decorator.rb
hs-pact-mock_service-3.9.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.9.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.9.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.8.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.7.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.6.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.6.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.6.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.5.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.4.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-3.3.1 lib/pact/mock_service/interaction_decorator.rb