Sha256: 286338bd6c021fa0244ef427ad010ad54978d4ac4666662ac24452eea6a08b9c

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe TokyoApi::Identity do
  subject { TokyoApi.new(host: 'test.com') }

  describe 'configuration' do
    it 'should propagate the host' do
      expect(subject.identity.client.connection.configuration.host).to eq('test.com')
    end
  end

  describe 'full_user' do
    let(:body) { fixture('responses/full_user_success') }
    let(:request_path) { '/identity/full_user/1' }
    let(:status) { 200 }

    before(:each) do
      stub_get(request_path).to_return(:body => body, :status => status,
                                       :headers => { content_type: "application/json; charset=utf-8"})
    end

    describe 'error' do
      let(:body) { fixture('responses/full_user_error') }

      it 'should return an error hash' do
        expect(subject.identity.full_user('1')).to eq({'error' => 'Connection refused'})
      end
    end

    describe 'success' do
      let(:body) { fixture('responses/identity/full_user_success') }

      it 'should return a hash' do
        expect(subject.identity.full_user('1')).to eq({'first_name' => 'Homer', 'last_name' => 'Simpson',
                                                       'country' => 'GB', 'postal' => '12345', 'email' => 'foo@bar.com' })
      end
    end
  end

  describe 'tokyo_identity_user_path' do
    context 'phone not required' do
      it 'should return rooted relative path to tokyo user API endpoint' do
        expect(subject.identity.tokyo_identity_user_path('-123456', false)).to eq('/identity/user/-123456?phone_required=false')
      end
    end

    context 'phone required' do
      it 'should return rooted relative path to tokyo user API endpoint' do
        expect(subject.identity.tokyo_identity_user_path('-123456', true)).to eq('/identity/user/-123456?phone_required=true')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tokyo_api-0.6.1 spec/identity_spec.rb