Sha256: 693f90bd218b3f93d8f2db8d92fc1c302c62ae1030e3db7912a784075500a39b

Contents?: true

Size: 1.93 KB

Versions: 2

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

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

2 entries across 2 versions & 1 rubygems

Version Path
roqua-core-api-0.0.39 spec/lib/roqua/core_api/dossiers_spec.rb
roqua-core-api-0.0.38 spec/lib/roqua/core_api/dossiers_spec.rb