2015-11-16 11:23:29 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-03-15 16:56:21 +01:00
|
|
|
describe ApiEntreprise::ExercicesAdapter do
|
2015-11-16 11:23:29 +01:00
|
|
|
let(:siret) { '41816609600051' }
|
2018-03-15 12:02:45 +01:00
|
|
|
let(:procedure_id) { 11 }
|
2018-03-19 15:43:15 +01:00
|
|
|
subject { described_class.new(siret, procedure_id).to_params }
|
2015-11-16 11:23:29 +01:00
|
|
|
|
|
|
|
before do
|
2018-05-09 12:03:04 +02:00
|
|
|
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/)
|
2018-10-15 17:04:51 +02:00
|
|
|
.to_return(body: File.read('spec/support/files/api_entreprise/exercices.json', status: 200))
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
2018-03-19 15:43:15 +01:00
|
|
|
it '#to_params class est un Hash ?' do
|
|
|
|
expect(subject).to be_an_instance_of(Hash)
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'have 3 exercices' do
|
2018-03-19 15:43:15 +01:00
|
|
|
expect(subject[:exercices_attributes].size).to eq(3)
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'Attributs Exercices' do
|
|
|
|
it 'L\'exercice contient bien un ca' do
|
2018-03-19 15:43:15 +01:00
|
|
|
expect(subject[:exercices_attributes][0][:ca]).to eq('21009417')
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'L\'exercice contient bien une date de fin d\'exercice' do
|
2018-03-19 15:43:15 +01:00
|
|
|
expect(subject[:exercices_attributes][0][:date_fin_exercice]).to eq("2013-12-31T00:00:00+01:00")
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'L\'exercice contient bien une date_fin_exercice_timestamp' do
|
2018-03-19 15:43:15 +01:00
|
|
|
expect(subject[:exercices_attributes][0][:date_fin_exercice_timestamp]).to eq(1388444400)
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|