Sha256: 80d3eb6f0e6c45fe208fee62cd86349b1c976842a3ae1163fc22a850b2f4b531
Contents?: true
Size: 1.95 KB
Versions: 9
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' describe Dossiers do let(:session) { Fabricate :roqua_core_api_oauth_session } let(:dossier_group_id) { 'some_dg_id' } let(:external_identifier) { 'some_eid' } let(:response) { {'headers' => %w(id birth_year gender firstname lastname), 'rows' => [[1, 1980, 'M', 'john', 'doe']]} } it 'performs a get on the /dossiers api path' do expect(session).to receive(:get).with('/dossiers', {}).and_return(response) Dossiers.run!(session: session) end it 'performs a get on /dossier_groups/:id/dossiers if a group is given' do expect(session).to receive(:get).with("/dossier_groups/#{dossier_group_id}/dossiers", {}).and_return(response) Dossiers.run!(session: session, dossier_group_id: dossier_group_id) end it 'performs a get on /dossier_groups/:id/dossiers?external_identifier=:eid if with_external_identifier is given' do expect(session).to receive(:get).with( "/dossier_groups/#{dossier_group_id}/dossiers", external_identifier: external_identifier).and_return(response) Dossiers.run!(session: session, dossier_group_id: dossier_group_id, with_external_identifier: external_identifier) end it 'performs a get on /dossier_groups/:id/dossiers?name=:foo+bar if with_name is given' do expect(session).to receive(:get).with( "/dossier_groups/#{dossier_group_id}/dossiers", name: 'foo bar').and_return(response) Dossiers.run!(session: session, dossier_group_id: dossier_group_id, with_name: 'foo bar') end it 'fails when a search is done for external_identifier without specifying a dossier_group_id' do op = Dossiers.run(session: session, with_external_identifier: external_identifier) expect(op).to be_invalid end it 'returns the results as an array of structs' do expect(session).to receive(:get).with('/dossiers', {}).and_return(response) dossiers = Dossiers.run!(session: session) expect(dossiers.first.firstname).to eq 'john' end end
Version data entries
9 entries across 9 versions & 1 rubygems