Sha256: 5531a9a8a2a85369310f475f28131d4b6becef087b274ea88f7f7b81b847190a

Contents?: true

Size: 1.73 KB

Versions: 22

Compression:

Stored size: 1.73 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
      lambda { 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
      lambda { subject.send(:private_key) }.should raise_error(GroupDocs::NoPrivateKeyError)
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
groupdocs-2.2.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-2.1.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-2.0.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.9.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.8.1 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.8.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.7.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.6.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.9 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.8 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.7 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.6 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.5 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.4 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.3 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.2 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.1 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.5.0 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.4.2 spec/groupdocs/api/helpers/credentials_helpers_spec.rb
groupdocs-1.4.1 spec/groupdocs/api/helpers/credentials_helpers_spec.rb