3 class NominatimTest < ActiveSupport::TestCase
 
   4   def test_describe_location
 
   5     stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
 
   6       .to_return(:body => "<reversegeocode><result>Target location</result></reversegeocode>")
 
   8     with_settings(:nominatim_url => "https://nominatim.example.com/") do
 
   9       location = Nominatim.describe_location(60, 30, 10, "en")
 
  10       assert_equal "Target location", location
 
  13     assert_requested :get, "https://nominatim.example.com/reverse?lat=60&lon=30&zoom=10&accept-language=en",
 
  14                      :headers => { "User-Agent" => Settings.server_url }
 
  17   def test_describe_location_no_result
 
  18     stub_request(:get, %r{^https://nominatim\.example\.com/reverse\?})
 
  19       .to_return(:body => "<reversegeocode><error>Unable to geocode</error></reversegeocode>")
 
  21     with_settings(:nominatim_url => "https://nominatim.example.com/") do
 
  22       location = Nominatim.describe_location(1, 2, 14, "en")
 
  23       assert_equal "1.000, 2.000", location
 
  26     assert_requested :get, "https://nominatim.example.com/reverse?lat=1&lon=2&zoom=14&accept-language=en",
 
  27                      :headers => { "User-Agent" => Settings.server_url }