Sha256: 31ade496a080a5430b01bd76e1164a619ee3d5d4995da9222b7d3a88d37500c6

Contents?: true

Size: 937 Bytes

Versions: 9

Compression:

Stored size: 937 Bytes

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
      @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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact-mock_service-0.3.0 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.4 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.3 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.3.pre.rc2 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.3.pre.rc1 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.2 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.1 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.2.0 lib/pact/consumer_contract/interaction_decorator.rb
pact-mock_service-0.1.0 lib/pact/consumer_contract/interaction_decorator.rb