style check

This commit is contained in:
Tanguy PATTE 2015-08-20 17:30:17 +02:00
parent a7e6931303
commit d557cee249
24 changed files with 67 additions and 78 deletions

View file

@ -1,12 +1,11 @@
require 'spec_helper'
describe SIADE::API do
describe '.entreprise' do
subject { SIADE::API.entreprise(siren) }
subject { described_class.entreprise(siren) }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}").
to_return(:status => status, :body => body)
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siren does not exist' do
let(:siren) { '111111111' }
@ -14,7 +13,7 @@ describe SIADE::API do
let(:body) { '' }
it 'raises RestClient::ResourceNotFound' do
expect{ subject }.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
context 'when siret exist' do
@ -29,10 +28,10 @@ describe SIADE::API do
end
describe '.etablissement' do
subject { SIADE::API.etablissement(siret) }
subject { described_class.etablissement(siret) }
before do
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}").
to_return(:status => status, :body => body)
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siret does not exist' do
@ -41,7 +40,7 @@ describe SIADE::API do
let(:body) { '' }
it 'raises RestClient::ResourceNotFound' do
expect{ subject }.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
@ -55,4 +54,4 @@ describe SIADE::API do
end
end
end
end
end

View file

@ -1,11 +1,11 @@
require 'spec_helper'
describe SIADE::EntrepriseAdapter do
subject { SIADE::EntrepriseAdapter.new('418166096').to_params }
subject { described_class.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))
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
end
it '#to_params class est une Hash ?' do
@ -18,7 +18,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un capital_social' do
expect(subject[:capital_social]).to eq(372795)
expect(subject[:capital_social]).to eq(372_795)
end
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
@ -50,7 +50,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien une date_creation' do
expect(subject[:date_creation]).to eq(891381600)
expect(subject[:date_creation]).to eq(891_381_600)
end
it 'L\'entreprise contient bien un nom' do
@ -61,4 +61,4 @@ describe SIADE::EntrepriseAdapter do
expect(subject[:prenom]).to eq('test_prenom')
end
end
end
end

View file

@ -1,14 +1,13 @@
require 'spec_helper'
describe SIADE::EtablissementAdapter do
context 'SIRET valide' do
let(:siret){41816609600051}
subject { SIADE::EtablissementAdapter.new(siret).to_params }
let(:siret) { 41_816_609_600_051 }
subject { described_class.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))
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
end
it '#to_params class est une Hash ?' do
@ -16,7 +15,6 @@ describe SIADE::EtablissementAdapter do
end
context 'Attributs Etablissements' do
it 'L\'entreprise contient bien un siret' do
expect(subject[:siret]).to eq('41816609600051')
end
@ -71,16 +69,16 @@ describe SIADE::EtablissementAdapter do
end
context 'when siret is not found' do
let(:bad_siret){ 11111111111111 }
subject { SIADE::EtablissementAdapter.new(bad_siret).to_params }
let(:bad_siret) { 11_111_111_111_111 }
subject { described_class.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)
.to_return(body: 'Fake body', status: 404)
end
it 'raises exception RestClient::ResourceNotFound' do
expect{subject}.to raise_error(RestClient::ResourceNotFound)
expect { subject }.to raise_error(RestClient::ResourceNotFound)
end
end
end
end