Sha256: 5157fa93bff8879a569c180de7ea98efd411baf2640c9365bfa52b2afd400c21

Contents?: true

Size: 1.27 KB

Versions: 14

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe Aptible::Api do
  describe '#initialize' do
    it 'should be a HyperResource instance' do
      expect(subject).to be_a HyperResource
    end
  end

  describe '#bearer_token' do
    it 'should accept an Aptible::Auth::Token' do
      token = Aptible::Auth::Token.new
      token.stub(:access_token) { 'abtible_auth_token' }
      subject.stub(:token) { token }
      expect(subject.bearer_token).to eq token.access_token
    end

    it 'should accept an Fridge::AccessToken' do
      token = Fridge::AccessToken.new
      token.stub(:to_s) { 'fridge_access_token' }
      subject.stub(:token) { token }
      expect(subject.bearer_token).to eq token.to_s
    end

    it 'should accept a String' do
      subject.stub(:token) { 'token' }
      expect(subject.bearer_token).to eq 'token'
    end
  end

  it 'should have a configurable root_url' do
    config = described_class.configuration
    expect(config).to be_a GemConfig::Configuration
    expect(config.root_url).to eq 'https://api.aptible.com'
  end

  pending 'uses ENV["APTIBLE_API_ROOT_URL"] if defined' do
    config = described_class.configuration
    set_env 'APTIBLE_API_ROOT_URL', 'http://foobar.com' do
      config.reset
      expect(config.root_url).to eq 'http://foobar.com'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
aptible-api-0.4.8 spec/aptible/api_spec.rb
aptible-api-0.4.7 spec/aptible/api_spec.rb
aptible-api-0.4.6 spec/aptible/api_spec.rb
aptible-api-0.4.5 spec/aptible/api_spec.rb
aptible-api-0.4.4 spec/aptible/api_spec.rb
aptible-api-0.4.3 spec/aptible/api_spec.rb
aptible-api-0.4.2 spec/aptible/api_spec.rb
aptible-api-0.4.1 spec/aptible/api_spec.rb
aptible-api-0.4.0 spec/aptible/api_spec.rb
aptible-api-0.3.1 spec/aptible/api_spec.rb
aptible-api-0.3.0 spec/aptible/api_spec.rb
aptible-api-0.2.2 spec/aptible/api_spec.rb
aptible-api-0.2.1 spec/aptible/api_spec.rb
aptible-api-0.2.0 spec/aptible/api_spec.rb