Module: GeocoderHelpers
- Defined in:
- lib/decidim/dev/test/rspec_support/geocoder.rb
Instance Method Summary collapse
- #configure_maps ⇒ Object
-
#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.
- #stub_geocoding(address, coordinates) ⇒ Object
Instance Method Details
#configure_maps ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File '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", dynamic: { tile_layer: { url: Decidim::Dev::Test::MapServer.url(:tiles) } }, static: { url: Decidim::Dev::Test::MapServer.url(:static) }, autocomplete: { url: Decidim::Dev::Test::MapServer.url(:autocomplete) } } 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 'lib/decidim/dev/test/rspec_support/geocoder.rb', line 19 def fill_in_geocoding(attribute, = {}) fill_in attribute, ** expect(page).to have_css(".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 '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 |