2018-03-15 16:56:21 +01:00
describe ApiEntreprise :: RNAAdapter do
2015-12-11 12:36:44 +01:00
let ( :siret ) { '50480511000013' }
2020-04-27 16:31:41 +02:00
let ( :procedure ) { create ( :procedure ) }
let ( :procedure_id ) { procedure . id }
2018-10-16 00:01:53 +02:00
let ( :body ) { File . read ( 'spec/fixtures/files/api_entreprise/associations.json' ) }
2015-12-11 12:36:44 +01:00
let ( :status ) { 200 }
2018-03-15 12:02:45 +01:00
let ( :adapter ) { described_class . new ( siret , procedure_id ) }
2015-12-24 16:12:16 +01:00
2018-02-21 16:29:22 +01:00
subject { adapter . to_params }
2015-12-11 10:36:16 +01:00
before do
2018-05-09 12:03:04 +02:00
stub_request ( :get , / https: \/ \/ entreprise.api.gouv.fr \/ v2 \/ associations \/ .*token= / )
2018-01-15 19:34:08 +01:00
. to_return ( body : body , status : status )
2015-12-11 12:36:44 +01:00
end
context 'when siret is not valid' do
let ( :siret ) { '234567' }
let ( :body ) { '' }
2019-04-30 16:36:40 +02:00
let ( :status ) { 404 }
2015-12-24 16:12:16 +01:00
2018-03-19 14:47:56 +01:00
it { is_expected . to eq ( { } ) }
2015-12-11 10:36:16 +01:00
end
2015-12-24 16:12:16 +01:00
it { expect ( subject ) . to be_an_instance_of ( Hash ) }
2015-12-11 10:36:16 +01:00
2015-12-24 16:12:16 +01:00
describe 'Attributs Associations' do
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_rna ] ) . to eq ( 'W595001988' ) }
2015-12-11 10:36:16 +01:00
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_titre ] ) . to eq ( 'UN SUR QUATRE' ) }
2015-12-11 10:36:16 +01:00
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_objet ] ) . to eq ( " valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement " ) }
2015-12-11 10:36:16 +01:00
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_date_creation ] ) . to eq ( '2014-01-23' ) }
2015-12-11 10:36:16 +01:00
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_date_declaration ] ) . to eq ( '2014-01-24' ) }
2015-12-11 10:36:16 +01:00
2018-03-19 15:41:20 +01:00
it { expect ( subject [ :association_date_publication ] ) . to eq ( '2014-02-08' ) }
2015-12-11 10:36:16 +01:00
end
end