Sha256: 88a9955d2f9b8fd7abbd003619cd8c65a47492b79e2505639e45746e87b4f848

Contents?: true

Size: 1.8 KB

Versions: 4

Compression:

Stored size: 1.8 KB

Contents

# Code generated for API Clients. DO NOT EDIT.

require 'spec_helper'

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

  before(:each) do
    @client = class_double("HttpClient")
    @tunnels_client = NgrokAPI::Services::TunnelsClient.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(tunnel_results)
      url = base_url + path + "?before_id=" + api_key_result["id"] + "&limit=1"
      result = @tunnels_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::Tunnel" do
      path = '/tunnels/%{id}'
      replacements = {
        id: tunnel_result["id"],
      }
      data = {}
      expect(@client).to receive(:get).with(path % replacements, data: data).
        and_return(tunnel_result)
      result = @tunnels_client.get(
        id: tunnel_result["id"]
      )
      expect(result.class).to eq(NgrokAPI::Models::Tunnel)
    end
  end

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

Version data entries

4 entries across 4 versions & 1 rubygems

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