Sha256: 2f8a262b305ffc6929c020e1ac918e1c12f5ffc9905fe6406f6ec764238a73c0

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true
module Minitest
  class Test
    def add_hash_entry(source, target, from, to)
      target[to] = source[from] if source[from]
    end

    def register_uri(http_method, url, options = {})
      body = options.fetch(:body, '')
      status = options.fetch(:status, 200)
      headers = options.fetch(:headers, {})

      add_hash_entry(options, headers, :location, 'Location')
      add_hash_entry(options, headers, :content_type, 'Content-Type')
      add_hash_entry(options, headers, :content_encoding, 'Content-Encoding')

      stub_request(http_method, url)
        .to_return(status: status, body: body, headers: headers)
    end

    def last_request
      WebMock.requests.last
    end

    def build_request(options = {})
      Aitch::Request.new({
        request_method: "get",
        url: "http://example.org",
        options: {}
      }.merge(options))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aitch-1.0.2 test/support/helpers.rb
aitch-1.0.1 test/support/helpers.rb
aitch-1.0.0 test/support/helpers.rb