Sha256: f8f9c63976f0b9b3a5f3f677b220b11e2742dc0afec0b08b25b0cb0c2f70cc92

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Typetalk::Api do

  let(:api) { Typetalk::Api.new }

  describe '#access_token', :vcr do
    it 'should get access_token' do
      expect(api.instance_variable_get(:@access_token)).to be_nil

      response = api.access_token
      expect(response).to eq('(ACCESS_TOKEN)')

      expect(api.instance_variable_get(:@access_token).expire_time).to eq(Time.now.to_i + 3600)
    end


    it 'should not update access_token' do
      expect(api.instance_variable_get(:@access_token)).to be_nil

      response = api.access_token
      expect(response).to eq('(ACCESS_TOKEN)')

      response = api.access_token
      expect(response).to eq('(ACCESS_TOKEN)')
    end


    it 'should update access_token when access_token is expired' do
      expect(api.instance_variable_get(:@access_token)).to be_nil

      response = api.access_token
      expect(response).to eq('(ACCESS_TOKEN)')

      at = api.instance_variable_get(:@access_token)
      at.expire_time = Time.now.to_i # expired
      api.instance_variable_set(:@access_token, at)

      response = api.access_token
      expect(response).to eq('(UPDATED_ACCESS_TOKEN)')
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
typetalk-0.1.1 spec/typetalk/api_spec.rb
typetalk-0.1.0 spec/typetalk/api_spec.rb
typetalk-0.0.6 spec/typetalk/api_spec.rb
typetalk-0.0.5 spec/typetalk/api_spec.rb
typetalk-0.0.4 spec/typetalk/api_spec.rb
typetalk-0.0.3 spec/typetalk/api_spec.rb
typetalk-0.0.2 spec/typetalk/api_spec.rb