Sha256: 90bad3ff86f08d6656c7711b7fb08a9eb0c0ee1e9e8cc7bf6f7c08c6ccae5e2b

Contents?: true

Size: 1.13 KB

Versions: 37

Compression:

Stored size: 1.13 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[:provider_state] = interaction.provider_state if interaction.provider_state
        hash[:request] = decorate_request.as_json
        hash[:response] = decorate_response.as_json
        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

37 entries across 37 versions & 1 rubygems

Version Path
pact-mock_service-2.0.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-2.0.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-1.2.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-1.1.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-1.0.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.12.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.12.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.11.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.10.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.10.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.10.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.9.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.8.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.8.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.8.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.7.2 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.7.1 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.7.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.6.0 lib/pact/mock_service/interaction_decorator.rb
pact-mock_service-0.5.5 lib/pact/mock_service/interaction_decorator.rb