module GdsApi::TestHelpers::Mapit

def stub_mapit_has_a_postcode(postcode, coords)

def stub_mapit_has_a_postcode(postcode, coords)
  response = {
    "wgs84_lat" => coords.first,
    "wgs84_lon" => coords.last,
    "postcode"  => postcode,
  }
  stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(" ", "+") + ".json")
    .to_return(body: response.to_json, status: 200)
  stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial/" + postcode.split(" ").first + ".json")
    .to_return(body: response.to_json, status: 200)
end