Sha256: b05b9cc64aef27f68fe17a2d4289ef8dde3689963fdab0bbb015d975ea4e85f4

Contents?: true

Size: 495 Bytes

Versions: 2

Compression:

Stored size: 495 Bytes

Contents

require_relative '../erb_processor'

module Pacto
  module Hooks
    class ERBHook < Pacto::Hook
      def initialize
        @processor = ERBProcessor.new
      end

      def process(contracts, request_signature, response)
        bound_values = contracts.empty? ? {} : contracts.first.values
        bound_values.merge!(:req => { 'HEADERS' => request_signature.headers})
        response.body = @processor.process response.body, bound_values
        response.body
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pacto-0.3.1 lib/pacto/hooks/erb_hook.rb
pacto-0.3.0 lib/pacto/hooks/erb_hook.rb