Module: GdsApi::TestHelpers::PlacesManager
- Defined in:
- lib/gds_api/test_helpers/places_manager.rb
Constant Summary collapse
- PLACES_MANAGER_API_ENDPOINT =
Generally true. If you are initializing the client differently, you could redefine/override the constant or stub directly.
Plek.find("places-manager")
Instance Method Summary collapse
- #stub_places_manager_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit) ⇒ Object
- #stub_places_manager_has_places(latitude, longitude, details) ⇒ Object
- #stub_places_manager_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug) ⇒ Object
- #stub_places_manager_places_request(slug, query_hash, return_data, status_code = 200) ⇒ Object
Instance Method Details
#stub_places_manager_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/gds_api/test_helpers/places_manager.rb', line 20 def (addresses, slug, postcode, limit) query_hash = { "postcode" => postcode, "limit" => limit } response_data = { status: "address-information-required", content: "addresses", addresses:, } stub_places_manager_places_request(slug, query_hash, response_data) end |
#stub_places_manager_has_places(latitude, longitude, details) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/gds_api/test_helpers/places_manager.rb', line 10 def stub_places_manager_has_places(latitude, longitude, details) query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" } response_data = { status: "ok", content: "places", places: details["details"], } stub_places_manager_places_request(details["slug"], query_hash, response_data) end |
#stub_places_manager_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gds_api/test_helpers/places_manager.rb', line 30 def stub_places_manager_has_places_for_postcode(places, slug, postcode, limit, ) query_hash = { "postcode" => postcode, "limit" => limit } query_hash.merge!(local_authority_slug:) if response_data = { status: "ok", content: "places", places:, } stub_places_manager_places_request(slug, query_hash, response_data) end |
#stub_places_manager_places_request(slug, query_hash, return_data, status_code = 200) ⇒ Object
41 42 43 44 45 |
# File 'lib/gds_api/test_helpers/places_manager.rb', line 41 def stub_places_manager_places_request(slug, query_hash, return_data, status_code = 200) stub_request(:get, "#{PLACES_MANAGER_API_ENDPOINT}/places/#{slug}.json") .with(query: query_hash) .to_return(status: status_code, body: return_data.to_json, headers: {}) end |