Sha256: 00ff0a95ceba6aaba2d1c4eeb6f61f4aabb4a97f8c71316ae336f879a20378e5

Contents?: true

Size: 1018 Bytes

Versions: 12

Compression:

Stored size: 1018 Bytes

Contents

class MockRequester
  def initialize
    @connection = nil
  end

  def send_request(host, method, path, _body, headers, _timeout, _connect_timeout)
    connection = get_connection(host)
    response   = {
      connection: connection,
      host: host,
      path: path,
      headers: headers,
      method: method,
      status: 200,
      body: '{"hits":[],"nbHits":0,"page":0,"nbPages":1,"hitsPerPage":20,"exhaustiveNbHits":true,"query":"test","params":"query=test","processingTimeMS":1}',
      success: true
    }

    Algolia::Http::Response.new(
      status: response[:status],
      body: response[:body],
      headers: response[:headers]
    )
  end

  # Retrieve the connection from the @connections
  #
  # @param host [StatefulHost]
  #
  # @return [Faraday::Connection]
  #
  def get_connection(host)
    @connection = host
  end

  # Build url from host, path and parameters
  #
  # @param host [StatefulHost]
  #
  # @return [String]
  #
  def build_url(host)
    host.protocol + host.url
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
algolia-2.1.1 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.4 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.3 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.2 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.1 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.beta.3 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.beta.2 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.beta.1 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.alpha.4 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.alpha.3 test/algolia/integration/mocks/mock_requester.rb
algolia-2.0.0.pre.alpha.2 test/algolia/integration/mocks/mock_requester.rb