Sha256: f00998422dc878378357115a90887c6d6e865d3e54f2df3f43d82606973dac95

Contents?: true

Size: 837 Bytes

Versions: 5

Compression:

Stored size: 837 Bytes

Contents

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

describe Typetalk::Api::User do

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

  describe '#get_profile', :vcr do
    it 'should get the correct resource' do
      response = api.get_profile
      expect(response).to be_a(Hashie::Mash)
      expect(response.account.name).to eq('typetalk-rubygem-tester')
      expect(response.account.fullName).to eq('Rubygem Tester')
    end

    it 'should raise error when access_token is wrong' do
      api.get_access_token
      expect{ api.get_profile(token: '(WRONG_ACCESS_TOKEN)') }.to raise_error(Typetalk::Unauthorized)
    end

    it 'should raise error when scope is wrong' do
      r = api.get_access_token(scope: 'topic.read,topic.post')
      expect{ api.get_profile(token: r.access_token) }.to raise_error(Typetalk::Unauthorized)
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
typetalk-0.1.1 spec/typetalk/api/user_spec.rb
typetalk-0.1.0 spec/typetalk/api/user_spec.rb
typetalk-0.0.6 spec/typetalk/api/user_spec.rb
typetalk-0.0.5 spec/typetalk/api/user_spec.rb
typetalk-0.0.4 spec/typetalk/api/user_spec.rb