demarches-normaliennes/spec/lib/api_entreprise/exercices_adapter_spec.rb

25 lines
919 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-08-05 18:40:47 +02:00
describe APIEntreprise::ExercicesAdapter do
let(:siret) { '41816609600051' }
2020-04-27 16:31:41 +02:00
let(:procedure) { create(:procedure) }
subject { described_class.new(siret, procedure.id).to_params }
before do
2023-05-29 16:45:21 +02:00
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/dgfip\/etablissements\/#{siret}\/chiffres_affaires/)
.to_return(body: File.read('spec/fixtures/files/api_entreprise/exercices.json', status: 200))
2020-08-05 18:40:47 +02:00
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
end
2019-04-30 16:18:56 +02:00
it { is_expected.to be_an_instance_of(Hash) }
2019-04-30 16:18:56 +02:00
it 'contains several exercices attributes' do
2023-05-29 16:45:21 +02:00
expect(subject[:exercices_attributes].size).to eq(2)
end
2019-04-30 16:18:56 +02:00
it 'contains informations in each exercices_attributes' do
2023-05-29 16:45:21 +02:00
expect(subject[:exercices_attributes][0][:ca]).to eq('900001')
expect(subject[:exercices_attributes][0][:date_fin_exercice].year).to eq(2015)
end
2017-04-04 15:27:04 +02:00
end