Sha256: fd13d1821f2df439b0454625d13ed3c612c0ef4d9eac887510b7829c1d338478

Contents?: true

Size: 714 Bytes

Versions: 2

Compression:

Stored size: 714 Bytes

Contents

require 'net/http'

module Pact
  module Messages
    module Consumer
      class InteractionBuilder
        attr_reader :interaction

        def initialize(&block)
          @interaction         = Pact::Messages::Consumer::Interaction.new
          @interaction.request = Pact::Request::Expected.from_hash(method: 'MESSAGE', path: '/')
          @callback            = block
        end

        def given(provider_state)
          interaction.provider_state = provider_state.nil? ? nil : provider_state.to_s
          self
        end

        def provide(response)
          interaction.response = Pact::Response.new(body: response)
          @callback.call interaction
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-messages-0.1.1 lib/pact/messages/consumer/interaction_builder.rb
pact-messages-0.1.0 lib/pact/messages/consumer/interaction_builder.rb