Sha256: a01a74dc86edc1fc4c4e07b587431d99619974b91d87133cddc251d2be7a6b8a

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

RSpec.describe NgrokAPI::Models::ApiKey do
  before(:each) do
    @client = class_double("ApiKeysClient")
    @api_key = NgrokAPI::Models::ApiKey.new(client: @client, result: api_key_result)
  end

  describe "#==" do
    it "is equal if the results are the same" do
      key2 = NgrokAPI::Models::ApiKey.new(client: @client, result: api_key_result)
      expect(@api_key == key2).to eq true
    end
  end

  describe "#to_s" do
    it "stringifies as result.to_s" do
      expect(@api_key.to_s).to eq api_key_result.to_s
    end
  end

  describe "#delete" do
    it "calls delete on the client" do
      expect(@api_key.client).to receive(:delete)
      @api_key.delete
    end
  end

  describe "#update" do
    it "updates instance's description and metadata and call update on the client" do
      new_description = 'new description'
      new_metadata = 'new metadata'
      expect(@api_key.client).to receive(:update)

      @api_key.update(
        description: new_description,
        metadata: new_metadata,
      )
      expect(@api_key.description).to eq new_description
      expect(@api_key.metadata).to eq new_metadata
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ngrok-api-0.9.0 spec/ngrokapi/models/api_key_spec.rb