Sha256: 342ef2786a726f884ff671de06831742d82a5f45826dda56890e0345aaf345a9

Contents?: true

Size: 729 Bytes

Versions: 3

Compression:

Stored size: 729 Bytes

Contents

# frozen_string_literal: true

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

    Geocoder::Lookup::Test.add_stub(
      address,
      result
    )
  end
end

RSpec.configure do |config|
  config.include GeocoderHelpers

  config.before(:suite) do
    # Set geocoder configuration in test mode
    Decidim.geocoder = {
      static_map_url: "https://www.example.org/my_static_map",
      here_api_key: "1234123412341234"
    }
    Geocoder.configure(lookup: :test)
  end

  config.before(:each, :serves_map) do
    stub_request(:get, %r{https://www\.example\.org/my_static_map})
      .to_return(body: "map_data")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-dev-0.22.0 lib/decidim/dev/test/rspec_support/geocoder.rb
decidim-dev-0.21.0 lib/decidim/dev/test/rspec_support/geocoder.rb
decidim-dev-0.20.1 lib/decidim/dev/test/rspec_support/geocoder.rb