Group API Entreprise mock responses in a folder

This commit is contained in:
gregoirenovel 2018-10-15 17:04:51 +02:00
parent 7ae5e8ce52
commit dc28e79ab4
13 changed files with 21 additions and 21 deletions

View file

@ -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

View file

@ -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: '')

View file

@ -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: '')

View file

@ -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: '')

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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) }