Sha256: f3b134cb353a7f400c3758e2c5b859eebca1b3ff16622f1a9bdf46500da7ab33

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

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

describe IdentityApiClient::Member do
  subject { IdentityApiClient.new(host: 'test.com', api_token: '1234567890abcdef') }

  let(:request_path) { '/api/member/details' }

  describe 'success' do
    let(:status) { 200 }

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

    context 'without load_current_consents' do
      let(:expected_request) { {'guid' => 'abcdef1234567890', 'api_token' => '1234567890abcdef'}.to_json }
      let(:body) { fixture('details.json') }

      it 'should get member details back from the API' do
        resp = subject.member.details('abcdef1234567890')

        expect(resp.first_name).to eq('Joe')
        expect(resp.last_name).to eq('Bloggs')
        expect(resp.email).to eq('joe@bloggs.com')
      end
    end

    context 'with load_current_consents' do
      let(:expected_request) { {'guid' => 'abcdef1234567890', 'api_token' => '1234567890abcdef', 'load_current_consents' => true}.to_json }
      let(:body) { fixture('details_with_consents.json') }

      it 'should get member details with consents back from the API' do
        resp = subject.member.details('abcdef1234567890', load_current_consents: true)

        expect(resp.first_name).to eq('Joe')
        expect(resp.last_name).to eq('Bloggs')
        expect(resp.email).to eq('joe@bloggs.com')

        expect(resp.consents.count).to eq 2
        expect(resp.consents[0].public_id).to eq 'terms_of_service_1.0'
      end
    end
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
identity-api-client-0.0.3 spec/member_spec.rb