Sha256: 58fae181d54498c1f2ff107ac39835a04cde79ac311dde241f8ae00b056c9bef

Contents?: true

Size: 1.84 KB

Versions: 3

Compression:

Stored size: 1.84 KB

Contents

# Code generated for API Clients. DO NOT EDIT.

require 'spec_helper'

RSpec.describe NgrokAPI::Services::EndpointsClient do
  let(:base_url) { 'https://api.ngrok.com' }
  let(:path) { '/endpoints' }
  let(:not_found) do
    NgrokAPI::Errors::NotFoundError.new(response: endpoint_result)
  end

  before(:each) do
    @client = class_double("HttpClient")
    @endpoints_client = NgrokAPI::Services::EndpointsClient.new(client: @client)
  end

  describe "#list" do
    it "will make a call to list (a GET request) and return a NgrokAPI::Models::Listable" do
      expect(@client).to receive(:list).
        and_return(endpoint_results)
      url = base_url + path + "?before_id=" + api_key_result["id"] + "&limit=1"
      result = @endpoints_client.list(url: url)
      expect(result.class).to eq(NgrokAPI::Models::Listable)
    end
  end

  describe "#get" do
    it "will make a get request and return an instance of NgrokAPI::Models::Endpoint" do
      path = '/endpoints/%{id}'
      replacements = {
        id: endpoint_result["id"],
      }
      data = {}
      expect(@client).to receive(:get).with(path % replacements, data: data).
        and_return(endpoint_result)
      result = @endpoints_client.get(
        id: endpoint_result["id"]
      )
      expect(result.class).to eq(NgrokAPI::Models::Endpoint)
    end
  end

  describe "#get!" do
    it "will make a get request and return an instance of NgrokAPI::Models::Endpoint" do
      path = '/endpoints/%{id}'
      replacements = {
        id: endpoint_result["id"],
      }
      data = {}
      expect(@client).to receive(:get).with(path % replacements, data: data).
        and_return(endpoint_result)
      result = @endpoints_client.get(
        id: endpoint_result["id"]
      )
      expect(result.class).to eq(NgrokAPI::Models::Endpoint)
      # expect(result.id).to eq(endpoint_result["id"])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ngrok-api-0.23.0 spec/ngrokapi/services/endpoints_client_spec.rb
ngrok-api-0.22.0 spec/ngrokapi/services/endpoints_client_spec.rb
ngrok-api-0.21.0 spec/ngrokapi/services/endpoints_client_spec.rb