Sha256: 8df93598a872176cd00e9416e25d6f9b0d03ef71c9009bd889d8000ec1d4c507

Contents?: true

Size: 822 Bytes

Versions: 105

Compression:

Stored size: 822 Bytes

Contents

module ManticoreSpecHelper
  def http_request(method, uri, options = {})
    client = Manticore::Client.new

    if basic_auth = options[:basic_auth]
      options = options.merge(auth: {user: basic_auth[0], pass: basic_auth[1]})
    end

    response = client.http(method, uri, options)
    OpenStruct.new({
      body: response.body || '',
      headers: WebMock::Util::Headers.normalize_headers(join_array_values(response.headers)),
      status: response.code.to_s
    })
  end

  def join_array_values(hash)
    hash.reduce({}) do |h, (k,v)|
      v = v.join(', ') if v.is_a?(Array)
      h.merge(k => v)
    end
  end

  def client_timeout_exception_class
    Manticore::ConnectTimeout
  end

  def connection_refused_exception_class
    Manticore::SocketException
  end

  def http_library
    :manticore
  end
end

Version data entries

105 entries across 99 versions & 8 rubygems

Version Path
logstash-input-salesforce-3.0.0 vendor/jruby/1.9/gems/webmock-2.3.2/spec/acceptance/manticore/manticore_spec_helper.rb
webmock-2.3.2 spec/acceptance/manticore/manticore_spec_helper.rb
webmock-2.3.1 spec/acceptance/manticore/manticore_spec_helper.rb
webmock-2.2.0 spec/acceptance/manticore/manticore_spec_helper.rb
webmock-2.1.0 spec/acceptance/manticore/manticore_spec_helper.rb