Sha256: 3ae4f748ae23fea417c4151f974f5da7259d0ddbf11f8431718dd722eadd5ee2

Contents?: true

Size: 849 Bytes

Versions: 75

Compression:

Stored size: 849 Bytes

Contents

require 'net/http'
require 'pact/reification'
require 'pact/consumer_contract/interaction'

module Pact
  module Consumer
    class InteractionBuilder

      attr_reader :interaction

      def initialize &block
        @interaction = Interaction.new
        @callback = block
      end

      def upon_receiving description
        @interaction.description = description
        self
      end

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

      def with(request_details)
        interaction.request = Pact::Request::Expected.from_hash(request_details)
        self
      end

      def will_respond_with(response)
        interaction.response = Pact::Response.new(response)
        @callback.call interaction
        self
      end

    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
pact-1.49.3 lib/pact/consumer/interaction_builder.rb
pact-1.49.2 lib/pact/consumer/interaction_builder.rb
pact-1.49.1 lib/pact/consumer/interaction_builder.rb
pact-1.49.0 lib/pact/consumer/interaction_builder.rb
pact-1.48.0 lib/pact/consumer/interaction_builder.rb
pact-1.47.0 lib/pact/consumer/interaction_builder.rb
pact-1.46.1 lib/pact/consumer/interaction_builder.rb
pact-1.46.0 lib/pact/consumer/interaction_builder.rb
pact-1.45.0 lib/pact/consumer/interaction_builder.rb
pact-1.44.1 lib/pact/consumer/interaction_builder.rb
pact-1.44.0 lib/pact/consumer/interaction_builder.rb
pact-1.43.1 lib/pact/consumer/interaction_builder.rb
pact-1.43.0 lib/pact/consumer/interaction_builder.rb
pact-1.42.3 lib/pact/consumer/interaction_builder.rb
pact-1.42.2 lib/pact/consumer/interaction_builder.rb
pact-1.42.1 lib/pact/consumer/interaction_builder.rb
pact-1.42.0 lib/pact/consumer/interaction_builder.rb
pact-1.41.2 lib/pact/consumer/interaction_builder.rb
pact-1.41.1 lib/pact/consumer/interaction_builder.rb
pact-1.41.0 lib/pact/consumer/interaction_builder.rb