Refactor siade adapters
This commit is contained in:
parent
0b2ad653fa
commit
da14cceadc
9 changed files with 66 additions and 53 deletions
|
@ -1,10 +1,12 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EntrepriseAdapter do
|
||||
subject { described_class.new('418166096').to_params }
|
||||
let(:siren) { '418166096' }
|
||||
let(:adapter) { described_class.new(siren) }
|
||||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/entreprises/418166096?token=#{SIADETOKEN}")
|
||||
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
|
||||
end
|
||||
|
||||
|
@ -14,7 +16,7 @@ describe SIADE::EntrepriseAdapter do
|
|||
|
||||
context 'Attributs Entreprises' do
|
||||
it 'L\'entreprise contient bien un siren' do
|
||||
expect(subject[:siren]).to eq('418166096')
|
||||
expect(subject[:siren]).to eq(siren)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un capital_social' do
|
||||
|
@ -60,10 +62,14 @@ describe SIADE::EntrepriseAdapter do
|
|||
it 'L\'entreprise contient bien un prenom' do
|
||||
expect(subject[:prenom]).to eq('test_prenom')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien les mandataires_sociaux' do
|
||||
expect(subject[:mandataires_sociaux]).to be_an_instance_of(Array)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Mandataire sociaux' do
|
||||
subject { described_class.new('418166096').mandataires_sociaux }
|
||||
subject { described_class.new(siren).to_params[:mandataires_sociaux] }
|
||||
|
||||
it '#to_params class est une Hash ?' do
|
||||
expect(subject).to be_an_instance_of(Array)
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe SIADE::EtablissementAdapter do
|
||||
context 'SIRET valide' do
|
||||
let(:siret) { 41_816_609_600_051 }
|
||||
let(:siret) { '41816609600051' }
|
||||
subject { described_class.new(siret).to_params }
|
||||
|
||||
before do
|
||||
|
@ -16,7 +16,7 @@ describe SIADE::EtablissementAdapter do
|
|||
|
||||
context 'Attributs Etablissements' do
|
||||
it 'L\'entreprise contient bien un siret' do
|
||||
expect(subject[:siret]).to eq('41816609600051')
|
||||
expect(subject[:siret]).to eq(siret)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un siege_social' do
|
||||
|
|
|
@ -23,7 +23,7 @@ describe SIADE::ExercicesAdapter do
|
|||
end
|
||||
|
||||
it 'L\'exercice contient bien une date de fin d\'exercice' do
|
||||
expect(subject[0][:dateFinExercice]).to eq("2013-12-31T00:00:00+01:00")
|
||||
expect(subject[0][:date_fin_exercice]).to eq("2013-12-31T00:00:00+01:00")
|
||||
end
|
||||
|
||||
it 'L\'exercice contient bien une date_fin_exercice_timestamp' do
|
||||
|
|
|
@ -4,8 +4,9 @@ describe SIADE::RNAAdapter do
|
|||
let(:siret) { '50480511000013' }
|
||||
let(:body) { File.read('spec/support/files/rna.json') }
|
||||
let(:status) { 200 }
|
||||
let(:adapter) { described_class.new(siret) }
|
||||
|
||||
subject { described_class.new(siret).to_params }
|
||||
subject { adapter.to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/.*token=/)
|
||||
|
@ -23,7 +24,7 @@ describe SIADE::RNAAdapter do
|
|||
it { expect(subject).to be_an_instance_of(Hash) }
|
||||
|
||||
describe 'Attributs Associations' do
|
||||
it { expect(subject[:association_id]).to eq('W595001988') }
|
||||
it { expect(subject[:rna]).to eq('W595001988') }
|
||||
|
||||
it { expect(subject[:titre]).to eq('UN SUR QUATRE') }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue