class GdsApi::TestHelpers::ContentApi::ArtefactStub

def comparable_query_params

because Webmock doesn't handle symbols
Ensure that all keys and values are strings
def comparable_query_params
  @query_parameters.each_with_object({}) do |(k,v),hash| 
    hash[k.to_s] = v.nil? ? v : v.to_s
  end
end

def initialize(slug)

def initialize(slug)
  @slug = slug
  @query_parameters = {}
  @response_body = artefact_for_slug(slug)
  @response_status = 200
end

def stub

Nothing is stubbed until this is called
def stub
  stub_request(:get, url_without_query)
      .with(query: hash_including(comparable_query_params))
      .to_return(status: @response_status, body: @response_body.to_json)
end

def url_without_query

def url_without_query
  "#{CONTENT_API_ENDPOINT}/#{CGI.escape(slug)}.json"
end

def with_query_parameters(hash)

def with_query_parameters(hash)
  @query_parameters = hash
  self
end

def with_response_body(response_body)

def with_response_body(response_body)
  @response_body = response_body
  self
end

def with_response_status(response_status)

def with_response_status(response_status)
  @response_status = response_status
  self
end