Sha256: 079188e4cb3c4952e7c45e7e9f94eabf249b7fa31ac152fe500afcf810333d9f

Contents?: true

Size: 1.01 KB

Versions: 28

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[:provider_state] = 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

28 entries across 28 versions & 1 rubygems

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