Module: GdsApi::TestHelpers::Rummager
- Defined in:
- lib/gds_api/test_helpers/rummager.rb
Instance Method Summary collapse
- #assert_rummager_deleted_item(id) ⇒ Object
- #assert_rummager_posted_item(attributes) ⇒ Object
- #rummager_has_no_policies_for_any_type ⇒ Object
- #rummager_has_no_services_and_info_data_for_organisation ⇒ Object
- #rummager_has_policies_for_every_type(options = {}) ⇒ Object
- #rummager_has_services_and_info_data_for_organisation ⇒ Object
- #rummager_has_specialist_sector_organisations(sub_sector) ⇒ Object
- #stub_any_rummager_delete ⇒ Object
- #stub_any_rummager_post ⇒ Object
- #stub_any_rummager_post_with_queueing_enabled ⇒ Object
Instance Method Details
#assert_rummager_deleted_item(id) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 30 def assert_rummager_deleted_item(id) if id =~ %r{^/} raise ArgumentError, 'Rummager id must not start with a slash' end assert_requested(:delete, %r{#{Plek.new.find('search')}/documents/#{id}}) end |
#assert_rummager_posted_item(attributes) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 16 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_policies_for_any_type ⇒ Object
52 53 54 55 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 52 def rummager_has_no_policies_for_any_type stub_request(:get, %r{/unified_search.json}) .to_return(body: no_search_results_found) end |
#rummager_has_no_services_and_info_data_for_organisation ⇒ Object
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_policies_for_every_type(options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 57 def rummager_has_policies_for_every_type( = {}) if count = [:count] stub_request(:get, %r{/unified_search.json.*count=#{count}.*}) .to_return(body: first_n_results(new_policies_results, n: count)) else stub_request(:get, %r{/unified_search.json}) .to_return(body: new_policies_results) end end |
#rummager_has_services_and_info_data_for_organisation ⇒ Object
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_delete ⇒ Object
26 27 28 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 26 def stub_any_rummager_delete stub_request(:delete, %r{#{Plek.new.find('search')}/documents/.*}) end |
#stub_any_rummager_post ⇒ Object
7 8 9 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 7 def stub_any_rummager_post stub_request(:post, %r{#{Plek.new.find('search')}/documents}) end |
#stub_any_rummager_post_with_queueing_enabled ⇒ Object
11 12 13 14 |
# File 'lib/gds_api/test_helpers/rummager.rb', line 11 def stub_any_rummager_post_with_queueing_enabled stub_request(:post, %r{#{Plek.new.find('search')}/documents}) \ .to_return(status: [202, "Accepted"]) end |