Sha256: 62e566286fe4d7c6ec1c5115ba1871fed715662bca63109e5105e8a679287585

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

class ClientStub
  attr_accessor :call_count, :requests

  def initialize response, &block
    @response = response
    @block = block
    @call_count = 0
    @requests = []
  end

  def make_get_request uri:, params: {}, options: {}
    make_http_request :get, uri: uri, body: nil, params: params, options: options
  end

  def make_delete_request uri:, params: {}, options: {}
    make_http_request :delete, uri: uri, body: nil, params: params, options: options
  end

  def make_post_request uri:, body: nil, params: {}, options: {}
    make_http_request :post, uri: uri, body: body, params: params, options: options
  end

  def make_patch_request uri:, body:, params: {}, options: {}
    make_http_request :patch, uri: uri, body: body, params: params, options: options
  end

  def make_put_request uri:, body:, params: {}, options: {}
    make_http_request :put, uri: uri, body: body, params: params, options: options
  end

  def make_http_request *args, **kwargs
    @call_count += 1

    @requests << @block&.call(*args, **kwargs)

    @response
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gapic-generator-0.11.0 templates/default/service/rest/test/method/_setup.erb
gapic-generator-0.10.1 templates/default/service/rest/test/method/_setup.erb
gapic-generator-0.10.0 templates/default/service/rest/test/method/_setup.erb
gapic-generator-0.9.1 templates/default/service/rest/test/method/_setup.erb
gapic-generator-0.9.0 templates/default/service/rest/test/method/_setup.erb
gapic-generator-0.8.0 templates/default/service/rest/test/method/_setup.erb