2015-12-11 10:36:16 +01:00
require 'spec_helper'
describe SIADE :: RNAAdapter do
2015-12-11 12:36:44 +01:00
let ( :siret ) { '50480511000013' }
let ( :body ) { File . read ( 'spec/support/files/rna.json' ) }
let ( :status ) { 200 }
2015-12-24 16:12:16 +01:00
2015-12-11 12:36:44 +01:00
subject { described_class . new ( siret ) . to_params }
2015-12-11 10:36:16 +01:00
before do
2017-12-11 15:31:45 +01:00
stub_request ( :get , / https: \/ \/ staging.entreprise.api.gouv.fr \/ v2 \/ associations \/ .*token= / )
2015-12-11 12:36:44 +01:00
. to_return ( body : body , status : status )
end
context 'when siret is not valid' do
let ( :siret ) { '234567' }
let ( :body ) { '' }
let ( :status ) { '404' }
2015-12-24 16:12:16 +01:00
2015-12-11 12:36:44 +01:00
it { is_expected . to eq ( nil ) }
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
it { expect ( subject [ :association_id ] ) . to eq ( 'W595001988' ) }
2015-12-11 10:36:16 +01:00
2015-12-24 16:12:16 +01:00
it { expect ( subject [ :titre ] ) . to eq ( 'UN SUR QUATRE' ) }
2015-12-11 10:36:16 +01:00
2015-12-24 16:12:16 +01:00
it { expect ( subject [ :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
2015-12-24 16:12:16 +01:00
it { expect ( subject [ :date_creation ] ) . to eq ( '2014-01-23' ) }
2015-12-11 10:36:16 +01:00
2015-12-24 16:12:16 +01:00
it { expect ( subject [ :date_declaration ] ) . to eq ( '2014-01-24' ) }
2015-12-11 10:36:16 +01:00
2015-12-24 16:12:16 +01:00
it { expect ( subject [ :date_publication ] ) . to eq ( '2014-02-08' ) }
2015-12-11 10:36:16 +01:00
end
end