performs_geo_lookup_examples.rb 548 B

12345678910111213141516
  1. RSpec.shared_examples 'UserPerformsGeoLookup' do
  2. it 'can only be loaded for User' do
  3. expect(described_class).to eq User
  4. end
  5. it 'performs geo lookup' do
  6. # Mock the geo lookup as it requires an API key.
  7. allow(Service::GeoLocation).to receive(:geocode).with('Marienstraße 18, 10117, Berlin, Germany').and_return([10.0, 20.0])
  8. user = create(described_class.name.underscore, street: 'Marienstraße 18', zip: '10117', city: 'Berlin', country: 'Germany')
  9. expect(user.preferences).to include(lat: 10.0, lng: 20.0)
  10. end
  11. end