Sha256: c6cf62b9ad67a1b611f810742ab5da7734f242851f71877a460633c616ce0387

Contents?: true

Size: 1.72 KB

Versions: 31

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe GroupDocs::Api::Helpers::Credentials do

  subject do
    GroupDocs::Api::Request.new(method: :GET)
  end

  describe '#client_id' do
    it 'returns passed to method client ID' do
      subject.options[:access] = { client_id: 'method_client_id' }
      subject.options[:access].should_receive(:[]).with(:client_id).and_return('method_client_id')
      subject.send(:client_id).should == 'method_client_id'
    end

    it 'returns GroupDocs.client_id if access has not been passed to method' do
      subject.options[:access] = {}
      GroupDocs.should_receive(:client_id).and_return('static_client_id')
      subject.send(:client_id).should == 'static_client_id'
    end

    it 'raises error if client ID has not been set' do
      subject.options[:access] = {}
      GroupDocs.client_id = nil
      -> { subject.send(:client_id) }.should raise_error(GroupDocs::NoClientIdError)
    end
  end

  describe '#private_key' do
    it 'returns passed to method private key' do
      subject.options[:access] = { private_key: 'method_private_key' }
      subject.options[:access].should_receive(:[]).with(:private_key).and_return('method_private_key')
      subject.send(:private_key).should == 'method_private_key'
    end

    it 'returns GroupDocs.private_key if access has not been passed to method' do
      subject.options[:access] = {}
      GroupDocs.should_receive(:private_key).and_return('static_private_key')
      subject.send(:private_key).should == 'static_private_key'
    end

    it 'raises error if private key has not been set' do
      subject.options[:access] = {}
      GroupDocs.private_key = nil
      -> { subject.send(:private_key) }.should raise_error(GroupDocs::NoPrivateKeyError)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
groupdocs-1.2.11 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.10 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.9 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.8 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.7 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.6 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.3 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.2 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.1 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.2.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.1.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.0.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.11 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.10 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.9 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.8 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.7 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.6 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.5 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-0.3.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb