Sha256: 22b50c1f4f3110ea06747f206e6386086885db9217349f0b7f776cd5b30f8107

Contents?: true

Size: 1.01 KB

Versions: 48

Compression:

Stored size: 1.01 KB

Contents

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

module Pact
  class InteractionDecorator

    include ActiveSupportSupport

    def initialize interaction, decorator_options = {}
      @interaction = interaction
      @decorator_options = decorator_options
    end

    def as_json options = {}
      hash = { :description => interaction.description }
      hash[:providerState] = interaction.provider_state if interaction.provider_state
      hash[:request] = decorate_request.as_json(options)
      hash[:response] = decorate_response.as_json(options)
      fix_all_the_things hash
    end

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

    private

    attr_reader :interaction

    def decorate_request
      RequestDecorator.new(interaction.request, @decorator_options)
    end

    def decorate_response
      ResponseDecorator.new(interaction.response, @decorator_options)
    end

  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

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