Module: GdsApi::TestHelpers::Rummager

Defined in:
lib/gds_api/test_helpers/rummager.rb

Instance Method Summary collapse

Instance Method Details

#assert_rummager_deleted_item(id) ⇒ Object



29
30
31
32
33
34
# File 'lib/gds_api/test_helpers/rummager.rb', line 29

def assert_rummager_deleted_item(id)
  if id =~ %r{^/}
    raise ArgumentError, 'Rummager id must not start with a slash'
  end
  stub_request(:delete, %r{#{Plek.new.find('search')}/documents/#{id}})
end

#assert_rummager_posted_item(attributes) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/gds_api/test_helpers/rummager.rb', line 15

def assert_rummager_posted_item(attributes)
  url = Plek.new.find('search') + "/documents"
  assert_requested(:post, url) do |req|
    data = JSON.parse(req.body)
    attributes.to_a.all? do |key, value|
      data[key.to_s] == value
    end
  end
end

#rummager_has_no_services_and_info_data_for_organisationObject



42
43
44
45
# File 'lib/gds_api/test_helpers/rummager.rb', line 42

def rummager_has_no_services_and_info_data_for_organisation
  stub_request_for(no_search_results_found)
  run_example_query
end

#rummager_has_services_and_info_data_for_organisationObject



37
38
39
40
# File 'lib/gds_api/test_helpers/rummager.rb', line 37

def rummager_has_services_and_info_data_for_organisation
  stub_request_for(search_results_found)
  run_example_query
end

#rummager_has_specialist_sector_organisations(sub_sector) ⇒ Object



47
48
49
50
# File 'lib/gds_api/test_helpers/rummager.rb', line 47

def rummager_has_specialist_sector_organisations(sub_sector)
  stub_request_for(sub_sector_organisations_results)
  run_example_query
end

#stub_any_rummager_deleteObject



25
26
27
# File 'lib/gds_api/test_helpers/rummager.rb', line 25

def stub_any_rummager_delete
  stub_request(:delete, %r{#{Plek.new.find('search')}/documents/.*})
end

#stub_any_rummager_postObject



6
7
8
# File 'lib/gds_api/test_helpers/rummager.rb', line 6

def stub_any_rummager_post
  stub_request(:post, %r{#{Plek.new.find('search')}/documents})
end

#stub_any_rummager_post_with_queueing_enabledObject



10
11
12
13
# File 'lib/gds_api/test_helpers/rummager.rb', line 10

def stub_any_rummager_post_with_queueing_enabled
  stub_request(:post, %r{#{Plek.new.find('search')}/documents}) \
    .to_return(status: [202, "Accepted"])
end