Sha256: 572e14047b48547b14c9f28858a66d7913923ed343379de19eaffd94d35a476e

Contents?: true

Size: 1.44 KB

Versions: 13

Compression:

Stored size: 1.44 KB

Contents

require 'spec_helper'

RSpec.describe RDStation::Client do
  context "when access_token is given" do
    let(:access_token) { 'access_token' }
    let(:client) { described_class.new(access_token: access_token) }
    let(:mock_authorization) { double(RDStation::Authorization) }

    before { allow(RDStation::Authorization).to receive(:new).and_return mock_authorization }

    it 'returns Contacts endpoint' do
      expect(RDStation::Contacts).to receive(:new).with({ authorization: mock_authorization }).and_call_original
      expect(client.contacts).to be_instance_of RDStation::Contacts
    end

    it 'returns Events endpoint' do
      expect(RDStation::Events).to receive(:new).with({ authorization: mock_authorization }).and_call_original
      expect(client.events).to be_instance_of RDStation::Events
    end

    it 'returns Fields endpoint' do
      expect(RDStation::Fields).to receive(:new).with({ authorization: mock_authorization }).and_call_original
      expect(client.fields).to be_instance_of RDStation::Fields
    end

    it 'returns Webhooks endpoint' do
      expect(RDStation::Webhooks).to receive(:new).with({ authorization: mock_authorization }).and_call_original
      expect(client.webhooks).to be_instance_of RDStation::Webhooks
    end
  end

  context "when access_token isn't given" do
    it "raises an ArgumentError exception" do
      expect{ described_class.new(access_token: nil) }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rdstation-ruby-client-2.8.2 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.8.1 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.8.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.7.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.6.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.5.3 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.5.2 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.5.1 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.5.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.4.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.3.1 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.3.0 spec/lib/rdstation/client_spec.rb
rdstation-ruby-client-2.2.0 spec/lib/rdstation/client_spec.rb