Sha256: 9a89f659863ad69c02fb44e71e0aab6a3f9943ae31e8dc71c24d17c0022e3c68

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require_relative '../../../test_helper'

module Troo
  describe Adaptors::Member do
    let(:described_class) { Adaptors::Member }
    let(:resource) do
      OpenStruct.new(
        id:        '5195fdb5a8c01a2318004f5d',
        username:  'gavinlaking1',
        email:     'gavinlaking@gmail.com',
        full_name: 'Gavin Laking',
        initials:  'GL',
        avatar_id: 'some_avatar_id',
        bio:       'some bio',
        url:       'http://www.gavinlaking.name/')
    end

    describe '#initialize' do
      subject { described_class.new(resource) }

      it 'assigns the resource to an instance variable' do
        subject.instance_variable_get('@resource')
          .must_equal(resource)
      end
    end

    describe '#adapted' do
      subject { described_class.adapt(resource) }

      it 'returns an adapted resource for local persistence' do
        subject.must_equal(
          external_member_id: '5195fdb5a8c01a2318004f5d',
          username:           'gavinlaking1',
          email:              'gavinlaking@gmail.com',
          full_name:          'Gavin Laking',
          initials:           'GL',
          avatar_id:          'some_avatar_id',
          bio:                'some bio',
          url:                'http://www.gavinlaking.name/'
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 test/lib/troo/adaptors/member_test.rb