require 'spec_helper' module Roqua module CoreApi module Sessions describe OrganizationSession do let(:session) { Fabricate :organization_session } describe '#dossier_session' do it 'creates a new dossier when attributes are provided' do dossier_attributes = double expect(session).to receive(:create_dossier).with dossier_attributes session.dossier_session dossier_attributes end it 'initializes a dossier session with a newly created dossier' do dossier_attributes = double dossier = double allow(session).to receive(:create_dossier).with(dossier_attributes).and_return dossier expect(DossierSession).to receive(:new).with(dossier, session.organization, session.key, session.server) session.dossier_session dossier_attributes end it 'initializes an organization session with a given organization' do dossier = Fabricate :dossier expect(DossierSession).to receive(:new).with(dossier, session.organization, session.key, session.server) session.dossier_session dossier end end end end end end