module GdsApi::TestHelpers::Rummager

def assert_rummager_posted_item(attributes, index: nil, **options)

def assert_rummager_posted_item(attributes, index: nil, **options)
  if index
    url = RUMMAGER_ENDPOINT + "/#{index}/documents"
  else
    url = RUMMAGER_ENDPOINT + "/documents"
  end
  assert_requested(:post, url, **options) do |req|
    data = JSON.parse(req.body)
    attributes.to_a.all? do |key, value|
      data[key.to_s] == value
    end
  end
end