demarches-normaliennes/spec/lib/siade/entreprise_adapter_spec.rb

96 lines
3 KiB
Ruby
Raw Normal View History

2015-08-10 11:05:06 +02:00
require 'spec_helper'
describe SIADE::EntrepriseAdapter do
2015-08-20 17:30:17 +02:00
subject { described_class.new('418166096').to_params }
2015-08-10 11:05:06 +02:00
before do
2017-12-11 15:31:45 +01:00
stub_request(:get, "https://staging.entreprise.api.gouv.fr/v2/entreprises/418166096?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
2015-08-10 11:05:06 +02:00
end
it '#to_params class est une Hash ?' do
2015-08-20 16:26:07 +02:00
expect(subject).to be_an_instance_of(Hash)
2015-08-10 11:05:06 +02:00
end
context 'Attributs Entreprises' do
it 'L\'entreprise contient bien un siren' do
expect(subject[:siren]).to eq('418166096')
end
it 'L\'entreprise contient bien un capital_social' do
2016-06-13 10:13:37 +02:00
expect(subject[:capital_social]).to eq(462308)
2015-08-10 11:05:06 +02:00
end
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
expect(subject[:numero_tva_intracommunautaire]).to eq('FR16418166096')
end
it 'L\'entreprise contient bien une forme_juridique' do
expect(subject[:forme_juridique]).to eq('SA à directoire (s.a.i.)')
end
it 'L\'entreprise contient bien un forme_juridique_code' do
expect(subject[:forme_juridique_code]).to eq('5699')
end
it 'L\'entreprise contient bien un nom_commercial' do
expect(subject[:nom_commercial]).to eq('OCTO-TECHNOLOGY')
end
it 'L\'entreprise contient bien une raison_sociale' do
expect(subject[:raison_sociale]).to eq('OCTO-TECHNOLOGY')
end
it 'L\'entreprise contient bien un siret_siege_social' do
expect(subject[:siret_siege_social]).to eq('41816609600051')
end
it 'L\'entreprise contient bien un code_effectif_entreprise' do
2016-06-13 10:13:37 +02:00
expect(subject[:code_effectif_entreprise]).to eq('31')
2015-08-10 11:05:06 +02:00
end
it 'L\'entreprise contient bien une date_creation' do
2016-06-13 10:13:37 +02:00
expect(subject[:date_creation]).to eq('Wed, 01 Apr 1998 00:00:00.000000000 +0200')
2015-08-10 11:05:06 +02:00
end
it 'L\'entreprise contient bien un nom' do
expect(subject[:nom]).to eq('test_nom')
end
it 'L\'entreprise contient bien un prenom' do
expect(subject[:prenom]).to eq('test_prenom')
end
end
context 'Mandataire sociaux' do
subject { described_class.new('418166096').mandataires_sociaux }
it '#to_params class est une Hash ?' do
expect(subject).to be_an_instance_of(Array)
end
it { expect(subject.size).to eq(8) }
describe 'Attributs' do
it 'Un mandataire social possède bien un nom' do
expect(subject[0][:nom]).to eq('HISQUIN')
end
it 'Un mandataire social possède bien un prenom' do
expect(subject[0][:prenom]).to eq('FRANCOIS')
end
it 'Un mandataire social possède bien une fonction' do
expect(subject[0][:fonction]).to eq('PRESIDENT DU DIRECTOIRE')
end
it 'Un mandataire social possède bien une date de naissance' do
expect(subject[0][:date_naissance]).to eq('1965-01-27')
end
it 'Un mandataire social possède bien une date de naissance au format timestamp' do
expect(subject[0][:date_naissance_timestamp]).to eq(-155523600)
end
end
end
2015-08-20 17:30:17 +02:00
end