spec(commune): improuve spec
This commit is contained in:
parent
f1658dedc5
commit
01602101f1
7 changed files with 310 additions and 56 deletions
293
spec/fixtures/cassettes/api_geo_communes.yml
vendored
293
spec/fixtures/cassettes/api_geo_communes.yml
vendored
File diff suppressed because one or more lines are too long
41
spec/fixtures/cassettes/api_geo_communes_01.yml
vendored
41
spec/fixtures/cassettes/api_geo_communes_01.yml
vendored
File diff suppressed because one or more lines are too long
|
@ -15,14 +15,14 @@ RSpec.describe PrefillParams do
|
|||
|
||||
VCR.insert_cassette('api_geo_regions')
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_communes_01')
|
||||
VCR.insert_cassette('api_geo_communes')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_regions')
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_communes_01')
|
||||
VCR.eject_cassette('api_geo_communes')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
|
|
|
@ -12,12 +12,12 @@ RSpec.describe TypesDeChamp::PrefillCommuneTypeDeChamp do
|
|||
|
||||
before do
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_communes_01')
|
||||
VCR.insert_cassette('api_geo_communes')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_communes_01')
|
||||
VCR.eject_cassette('api_geo_communes')
|
||||
end
|
||||
|
||||
describe 'ancestors' do
|
||||
|
|
|
@ -43,7 +43,7 @@ describe APIGeoService do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'communes', vcr: { cassette_name: 'api_geo_communes_01' } do
|
||||
describe 'communes', vcr: { cassette_name: 'api_geo_communes' } do
|
||||
it 'return sorted results' do
|
||||
expect(APIGeoService.communes('01').size).to eq(399)
|
||||
expect(APIGeoService.communes('01').first).to eq(code: '01004', name: 'Ambérieu-en-Bugey', postal_code: '01500', departement_code: '01', epci_code: '240100883')
|
||||
|
@ -51,12 +51,22 @@ describe APIGeoService do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'commune_name', vcr: { cassette_name: 'api_geo_communes_01' } do
|
||||
describe 'communes_by_postal_code', vcr: { cassette_name: 'api_geo_communes' } do
|
||||
it 'return results' do
|
||||
expect(APIGeoService.communes_by_postal_code('75019').size).to eq(2)
|
||||
expect(APIGeoService.communes_by_postal_code('69005').size).to eq(2)
|
||||
expect(APIGeoService.communes_by_postal_code('13006').size).to eq(2)
|
||||
expect(APIGeoService.communes_by_postal_code('73480').size).to eq(3)
|
||||
expect(APIGeoService.communes_by_postal_code('20000').first[:code]).to eq('2A004')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'commune_name', vcr: { cassette_name: 'api_geo_communes' } do
|
||||
subject { APIGeoService.commune_name('01', '01457') }
|
||||
it { is_expected.to eq('Vonnas') }
|
||||
end
|
||||
|
||||
describe 'commune_code', vcr: { cassette_name: 'api_geo_communes_01' } do
|
||||
describe 'commune_code', vcr: { cassette_name: 'api_geo_communes' } do
|
||||
subject { APIGeoService.commune_code('01', 'Vonnas') }
|
||||
it { is_expected.to eq('01457') }
|
||||
end
|
||||
|
|
|
@ -79,13 +79,13 @@ describe 'Prefilling a dossier (with a GET request):', js: true do
|
|||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_communes_01')
|
||||
VCR.insert_cassette('api_geo_communes')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_communes_01')
|
||||
VCR.eject_cassette('api_geo_communes')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
|
|
|
@ -56,13 +56,13 @@ describe 'Prefilling a dossier (with a POST request):', js: true do
|
|||
.to_return(status: 200, body: File.read('spec/fixtures/files/api_entreprise/associations.json'))
|
||||
|
||||
VCR.insert_cassette('api_geo_departements')
|
||||
VCR.insert_cassette('api_geo_communes_01')
|
||||
VCR.insert_cassette('api_geo_communes')
|
||||
VCR.insert_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
after do
|
||||
VCR.eject_cassette('api_geo_departements')
|
||||
VCR.eject_cassette('api_geo_communes_01')
|
||||
VCR.eject_cassette('api_geo_communes')
|
||||
VCR.eject_cassette('api_geo_epcis')
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue