Sha256: 827d08a78c719ca82050903706f0d0e1721c327cd79a19e7927da6f4418f0ac6

Contents?: true

Size: 1.95 KB

Versions: 4

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe Dossiers do
  let(:session) { Fabricate :roqua_core_api_token_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

4 entries across 4 versions & 1 rubygems

Version Path
roqua-core-api-0.7.0 spec/lib/roqua/core_api/dossiers_spec.rb
roqua-core-api-0.6.0 spec/lib/roqua/core_api/dossiers_spec.rb
roqua-core-api-0.5.0 spec/lib/roqua/core_api/dossiers_spec.rb
roqua-core-api-0.4.0 spec/lib/roqua/core_api/dossiers_spec.rb