Module: GeocoderHelpers

Defined in:
decidim-dev/lib/decidim/dev/test/rspec_support/geocoder.rb

Instance Method Summary collapse

Instance Method Details

#configure_mapsObject



27
28
29
30
31
32
33
34
35
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/geocoder.rb', line 27

public def configure_maps
  # Set maps configuration in test mode
  Decidim.maps = {
    provider: :test,
    api_key: "1234123412341234",
    static: { url: "https://www.example.org/my_static_map" },
    autocomplete: { url: "/photon_api" } # Locally drawn route for the tests
  }
end

#fill_in_geocoding(attribute, options = {}) ⇒ Object

Waits for the front-end geocoding request to finish in order to ensure there are no pending requests when proceeding.



19
20
21
22
23
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/geocoder.rb', line 19

def fill_in_geocoding(attribute, options = {})
  fill_in attribute, **options
  expect(page).to have_selector(".autoComplete_wrapper ul#autoComplete_list_1", count: 1)
  find("li#autoComplete_result_0").click
end

#stub_geocoding(address, coordinates) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/geocoder.rb', line 4

def stub_geocoding(address, coordinates)
  result = coordinates.blank? ? [] : [{ "coordinates" => [latitude, longitude] }]

  Geocoder::Lookup::Test.add_stub(
    address,
    result
  )
  Decidim::Map::Provider::Autocomplete::Test.add_stub(
    address,
    coordinates
  )
end