First Commit
This commit is contained in:
commit
b5b83e939a
213 changed files with 8688 additions and 0 deletions
32
spec/lib/siade/api_spec.rb
Normal file
32
spec/lib/siade/api_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EntrepriseAdapter do
|
||||
|
||||
context 'self.#entreprise bad SIREN' do
|
||||
let(:siren){1}
|
||||
subject { SIADE::Api.entreprise(siren) }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}").
|
||||
to_return(:status => 404, :body => "", :headers => {})
|
||||
end
|
||||
|
||||
it 'bad SIREN' do
|
||||
expect(subject).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'self.#etablissement bad SIRET' do
|
||||
let(:siret){1}
|
||||
subject { SIADE::Api.etablissement(siret) }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}").
|
||||
to_return(:status => 404, :body => "", :headers => {})
|
||||
end
|
||||
|
||||
it 'bad SIRET' do
|
||||
expect(subject).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
64
spec/lib/siade/entreprise_adapter_spec.rb
Normal file
64
spec/lib/siade/entreprise_adapter_spec.rb
Normal file
|
@ -0,0 +1,64 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EntrepriseAdapter do
|
||||
subject { SIADE::EntrepriseAdapter.new('418166096').to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
|
||||
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
|
||||
end
|
||||
|
||||
it '#to_params class est une Hash ?' do
|
||||
expect(subject.class).to eq (Hash)
|
||||
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
|
||||
expect(subject[:capital_social]).to eq(372795)
|
||||
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
|
||||
expect(subject[:code_effectif_entreprise]).to eq('22')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien une date_creation' do
|
||||
expect(subject[:date_creation]).to eq(891381600)
|
||||
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
|
||||
end
|
86
spec/lib/siade/etablissement_adapter_spec.rb
Normal file
86
spec/lib/siade/etablissement_adapter_spec.rb
Normal file
|
@ -0,0 +1,86 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe SIADE::EtablissementAdapter do
|
||||
|
||||
context 'SIRET valide' do
|
||||
let(:siret){41816609600051}
|
||||
subject { SIADE::EtablissementAdapter.new(siret).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
|
||||
end
|
||||
|
||||
it '#to_params class est une Hash ?' do
|
||||
expect(subject.class).to eq (Hash)
|
||||
end
|
||||
|
||||
context 'Attributs Etablissements' do
|
||||
|
||||
it 'L\'entreprise contient bien un siret' do
|
||||
expect(subject[:siret]).to eq('41816609600051')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un siege_social' do
|
||||
expect(subject[:siege_social]).to eq(true)
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un naf' do
|
||||
expect(subject[:naf]).to eq('6202A')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un libelle_naf' do
|
||||
expect(subject[:libelle_naf]).to eq('Conseil en systèmes et logiciels informatiques')
|
||||
end
|
||||
|
||||
context 'Concaténation lignes adresse' do
|
||||
it 'L\'entreprise contient bien une adresse sur plusieurs lignes' do
|
||||
expect(subject[:adresse]).to eq("OCTO-TECHNOLOGY\r\n50 AV DES CHAMPS ELYSEES\r\n75008 PARIS 8\r\nligne 4\r\nligne 5\r\n")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Détails adresse' do
|
||||
it 'L\'entreprise contient bien un numero_voie' do
|
||||
expect(subject[:numero_voie]).to eq('50')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un type_voie' do
|
||||
expect(subject[:type_voie]).to eq('AV')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un nom_voie' do
|
||||
expect(subject[:nom_voie]).to eq('DES CHAMPS ELYSEES')
|
||||
end
|
||||
it 'L\'entreprise contient bien un complement_adresse' do
|
||||
expect(subject[:complement_adresse]).to eq('complement_adresse')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un code_postal' do
|
||||
expect(subject[:code_postal]).to eq('75008')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien une localite' do
|
||||
expect(subject[:localite]).to eq('PARIS 8')
|
||||
end
|
||||
|
||||
it 'L\'entreprise contient bien un code_insee_localite' do
|
||||
expect(subject[:code_insee_localite]).to eq('75108')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'SIRET Inconnu' do
|
||||
let(:bad_siret){1}
|
||||
subject { SIADE::EtablissementAdapter.new(bad_siret).to_params }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
|
||||
.to_return(body: 'Fake body', status: 404)
|
||||
end
|
||||
|
||||
it 'retour de nil' do
|
||||
expect{subject}.to raise_error ('SIRET Non reconnu')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue