more robust normalization
This commit is contained in:
parent
758673a355
commit
5567570d74
2 changed files with 40 additions and 1 deletions
|
@ -107,4 +107,34 @@ describe APIGeoService do
|
|||
it { expect(subject[:city_name]).to eq('Paris') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'safely_normalize_city_name' do
|
||||
let(:department_code) { '75' }
|
||||
let(:city_code) { '75056' }
|
||||
let(:fallback) { 'Paris' }
|
||||
|
||||
subject { APIGeoService.safely_normalize_city_name(department_code, city_code, fallback) }
|
||||
|
||||
context 'nominal' do
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'without department' do
|
||||
let(:department_code) { nil }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'without city_code' do
|
||||
let(:city_code) { nil }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
|
||||
context 'with a wrong department' do
|
||||
let(:department_code) { 'wrong' }
|
||||
|
||||
it { is_expected.to eq('Paris') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue