From dc28e79ab4022a7f46c569f67bb7a64275bee70d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Oct 2018 17:04:51 +0200 Subject: [PATCH] Group API Entreprise mock responses in a folder --- spec/controllers/users/dossiers_controller_spec.rb | 8 ++++---- spec/features/users/complete_demande_spec.rb | 6 +++--- spec/features/users/dossier_creation_spec.rb | 6 +++--- spec/features/users/start_demande_spec.rb | 6 +++--- spec/lib/api_entreprise/api_spec.rb | 8 ++++---- spec/lib/api_entreprise/entreprise_adapter_spec.rb | 2 +- spec/lib/api_entreprise/etablissement_adapter_spec.rb | 2 +- spec/lib/api_entreprise/exercices_adapter_spec.rb | 2 +- spec/lib/api_entreprise/rna_adapter_spec.rb | 2 +- .../files/{rna.json => api_entreprise/associations.json} | 0 .../{entreprise.json => api_entreprise/entreprises.json} | 0 .../etablissements.json} | 0 spec/support/files/{ => api_entreprise}/exercices.json | 0 13 files changed, 21 insertions(+), 21 deletions(-) rename spec/support/files/{rna.json => api_entreprise/associations.json} (100%) rename spec/support/files/{entreprise.json => api_entreprise/entreprises.json} (100%) rename spec/support/files/{etablissement.json => api_entreprise/etablissements.json} (100%) rename spec/support/files/{ => api_entreprise}/exercices.json (100%) diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 9e9ff9143..5d952d491 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -15,7 +15,7 @@ describe Users::DossiersController, type: :controller do let(:user) { create :user } let(:exercices_status) { 200 } - let(:exercices_body) { File.read('spec/support/files/exercices.json') } + let(:exercices_body) { File.read('spec/support/files/api_entreprise/exercices.json') } let(:siren) { '440117620' } let(:siret) { '44011762001530' } @@ -199,10 +199,10 @@ describe Users::DossiersController, type: :controller do .to_return(status: 404, body: 'fake body') stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) - .to_return(status: status_entreprise_call, body: File.read('spec/support/files/etablissement.json')) + .to_return(status: status_entreprise_call, body: File.read('spec/support/files/api_entreprise/etablissements.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) - .to_return(status: status_entreprise_call, body: File.read('spec/support/files/entreprise.json')) + .to_return(status: status_entreprise_call, body: File.read('spec/support/files/api_entreprise/entreprises.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) .to_return(status: exercices_status, body: exercices_body) @@ -280,7 +280,7 @@ describe Users::DossiersController, type: :controller do context 'when siren have rna informations' do let(:rna_status) { 200 } - let(:rna_body) { File.read('spec/support/files/rna.json') } + let(:rna_body) { File.read('spec/support/files/api_entreprise/associations.json') } it 'creates rna information for entreprise' do subject diff --git a/spec/features/users/complete_demande_spec.rb b/spec/features/users/complete_demande_spec.rb index 8277a35ab..2de695d97 100644 --- a/spec/features/users/complete_demande_spec.rb +++ b/spec/features/users/complete_demande_spec.rb @@ -31,12 +31,12 @@ feature 'user path for dossier creation' do context 'sets siret' do before do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) - .to_return(body: File.read('spec/support/files/etablissement.json', status: 200)) + .to_return(body: File.read('spec/support/files/api_entreprise/etablissements.json', status: 200)) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/entreprises.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/exercices.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') diff --git a/spec/features/users/dossier_creation_spec.rb b/spec/features/users/dossier_creation_spec.rb index 0784c57f2..8db07b62e 100644 --- a/spec/features/users/dossier_creation_spec.rb +++ b/spec/features/users/dossier_creation_spec.rb @@ -67,11 +67,11 @@ feature 'As a User I wanna create a dossier' do expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s)) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/etablissement.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/etablissements.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/entreprises.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/exercices.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') diff --git a/spec/features/users/start_demande_spec.rb b/spec/features/users/start_demande_spec.rb index 40aac6547..ad7937318 100644 --- a/spec/features/users/start_demande_spec.rb +++ b/spec/features/users/start_demande_spec.rb @@ -27,11 +27,11 @@ feature 'user arrive on siret page' do context 'when enter a siret', js: true do before do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/etablissement.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/etablissements.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/entreprises.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) - .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) + .to_return(status: 200, body: File.read('spec/support/files/api_entreprise/exercices.json')) stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') diff --git a/spec/lib/api_entreprise/api_spec.rb b/spec/lib/api_entreprise/api_spec.rb index 070568dba..2dffe6ae6 100644 --- a/spec/lib/api_entreprise/api_spec.rb +++ b/spec/lib/api_entreprise/api_spec.rb @@ -20,7 +20,7 @@ describe ApiEntreprise::API do context 'when siret exist' do let(:siren) { '418166096' } let(:status) { 200 } - let(:body) { File.read('spec/support/files/entreprise.json') } + let(:body) { File.read('spec/support/files/api_entreprise/entreprises.json') } it 'returns response body' do expect(subject).to eq(JSON.parse(body, symbolize_names: true)) @@ -48,7 +48,7 @@ describe ApiEntreprise::API do context 'when siret exists' do let(:siret) { '41816609600051' } let(:status) { 200 } - let(:body) { File.read('spec/support/files/etablissement.json') } + let(:body) { File.read('spec/support/files/api_entreprise/etablissements.json') } it 'returns body' do expect(subject).to eq(JSON.parse(body, symbolize_names: true)) @@ -79,7 +79,7 @@ describe ApiEntreprise::API do let(:siret) { '41816609600051' } let(:status) { 200 } - let(:body) { File.read('spec/support/files/exercices.json') } + let(:body) { File.read('spec/support/files/api_entreprise/exercices.json') } it 'raises RestClient::Unauthorized' do expect(subject).to eq(JSON.parse(body, symbolize_names: true)) @@ -108,7 +108,7 @@ describe ApiEntreprise::API do context 'when siren exists' do let(:siren) { '418166096' } let(:status) { 200 } - let(:body) { File.read('spec/support/files/rna.json') } + let(:body) { File.read('spec/support/files/api_entreprise/associations.json') } it { expect(subject).to eq(JSON.parse(body, symbolize_names: true)) } end diff --git a/spec/lib/api_entreprise/entreprise_adapter_spec.rb b/spec/lib/api_entreprise/entreprise_adapter_spec.rb index 52b70e490..75328fe9c 100644 --- a/spec/lib/api_entreprise/entreprise_adapter_spec.rb +++ b/spec/lib/api_entreprise/entreprise_adapter_spec.rb @@ -8,7 +8,7 @@ describe ApiEntreprise::EntrepriseAdapter do before do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) - .to_return(body: File.read('spec/support/files/entreprise.json', status: 200)) + .to_return(body: File.read('spec/support/files/api_entreprise/entreprises.json', status: 200)) end it '#to_params class est une Hash ?' do diff --git a/spec/lib/api_entreprise/etablissement_adapter_spec.rb b/spec/lib/api_entreprise/etablissement_adapter_spec.rb index 31f21414a..e2224bdbe 100644 --- a/spec/lib/api_entreprise/etablissement_adapter_spec.rb +++ b/spec/lib/api_entreprise/etablissement_adapter_spec.rb @@ -9,7 +9,7 @@ describe ApiEntreprise::EtablissementAdapter do before do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) - .to_return(body: File.read('spec/support/files/etablissement.json', status: 200)) + .to_return(body: File.read('spec/support/files/api_entreprise/etablissements.json', status: 200)) end it '#to_params class est une Hash ?' do diff --git a/spec/lib/api_entreprise/exercices_adapter_spec.rb b/spec/lib/api_entreprise/exercices_adapter_spec.rb index bdfe2c7da..36c5cbb8b 100644 --- a/spec/lib/api_entreprise/exercices_adapter_spec.rb +++ b/spec/lib/api_entreprise/exercices_adapter_spec.rb @@ -7,7 +7,7 @@ describe ApiEntreprise::ExercicesAdapter do before do stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) - .to_return(body: File.read('spec/support/files/exercices.json', status: 200)) + .to_return(body: File.read('spec/support/files/api_entreprise/exercices.json', status: 200)) end it '#to_params class est un Hash ?' do diff --git a/spec/lib/api_entreprise/rna_adapter_spec.rb b/spec/lib/api_entreprise/rna_adapter_spec.rb index b567c47ec..2b246d54f 100644 --- a/spec/lib/api_entreprise/rna_adapter_spec.rb +++ b/spec/lib/api_entreprise/rna_adapter_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe ApiEntreprise::RNAAdapter do let(:siret) { '50480511000013' } let(:procedure_id) { 22 } - let(:body) { File.read('spec/support/files/rna.json') } + let(:body) { File.read('spec/support/files/api_entreprise/associations.json') } let(:status) { 200 } let(:adapter) { described_class.new(siret, procedure_id) } diff --git a/spec/support/files/rna.json b/spec/support/files/api_entreprise/associations.json similarity index 100% rename from spec/support/files/rna.json rename to spec/support/files/api_entreprise/associations.json diff --git a/spec/support/files/entreprise.json b/spec/support/files/api_entreprise/entreprises.json similarity index 100% rename from spec/support/files/entreprise.json rename to spec/support/files/api_entreprise/entreprises.json diff --git a/spec/support/files/etablissement.json b/spec/support/files/api_entreprise/etablissements.json similarity index 100% rename from spec/support/files/etablissement.json rename to spec/support/files/api_entreprise/etablissements.json diff --git a/spec/support/files/exercices.json b/spec/support/files/api_entreprise/exercices.json similarity index 100% rename from spec/support/files/exercices.json rename to spec/support/files/api_entreprise/exercices.json