2016-12-16 17:28:50 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-10-15 16:56:20 +02:00
|
|
|
describe ApiAdresse::Geocodeur do
|
2016-12-16 17:28:50 +01:00
|
|
|
let(:address) { '50 av des champs elysees' }
|
2018-10-15 16:33:42 +02:00
|
|
|
describe '.convert_adresse_to_point', vcr: { cassette_name: 'api_adresse_octo' } do
|
2018-01-04 10:46:33 +01:00
|
|
|
it 'return a point' do
|
|
|
|
expect(described_class.convert_adresse_to_point(address).class).to eq(RGeo::Cartesian::PointImpl)
|
2016-12-16 17:28:50 +01:00
|
|
|
end
|
|
|
|
context 'when RestClient::Exception' do
|
|
|
|
before do
|
2018-10-15 18:23:32 +02:00
|
|
|
allow(ApiAdresse::API).to receive(:call).and_raise(RestClient::Exception)
|
2016-12-16 17:28:50 +01:00
|
|
|
end
|
|
|
|
it 'return nil' do
|
|
|
|
expect(described_class.convert_adresse_to_point(address)).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when JSON::ParserError' do
|
|
|
|
before do
|
2018-10-15 18:08:13 +02:00
|
|
|
allow_any_instance_of(ApiAdresse::PointAdapter).to receive(:point).and_raise(JSON::ParserError)
|
2016-12-16 17:28:50 +01:00
|
|
|
end
|
|
|
|
it 'return nil' do
|
|
|
|
expect(described_class.convert_adresse_to_point(address)).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|