Sha256: 0f9138f86999d0d77d6d8524f718072e73fcf77c882f7176bbf95ac1a2ec395b

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 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

        def description(description)
          interaction.description = description.nil? ? "" : description.to_s
          self
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-messages-0.2.0 lib/pact/messages/consumer/interaction_builder.rb