Module: GdsApi::TestHelpers::Imminence

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

Constant Summary collapse

IMMINENCE_API_ENDPOINT =

Generally true. If you are initializing the client differently, you could redefine/override the constant or stub directly.

Plek.current.find('imminence')

Instance Method Summary collapse

Instance Method Details

#imminence_has_business_support_schemes(facets_hash, schemes) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gds_api/test_helpers/imminence.rb', line 18

def imminence_has_business_support_schemes(facets_hash, schemes)
  results = {
    "_response_info" => {"status" => "ok"},
    "description" => "Business Support Schemes!",
    "total" => schemes.size, "startIndex" => 1, "pageSize" => schemes.size, "currentPage" => 1, "pages" => 1,
    "results" => schemes
  }

  stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/business_support_schemes.json").
    with(query: facets_hash).
    to_return(status: 200, body: results.to_json, headers: {})
end

#imminence_has_places(latitude, longitude, details) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/gds_api/test_helpers/imminence.rb', line 10

def imminence_has_places(latitude, longitude, details)
  response = JSON.dump(details['details'])

  stub_request(:get, "#{IMMINENCE_API_ENDPOINT}/places/#{details['slug']}.json").
  with(:query => {"lat" => latitude, "lng" => longitude, "limit" => "5"}).
  to_return(:status => 200, :body => response, :headers => {})
end

#stub_imminence_default_business_support_schemesObject

Stubs out all bussiness_support_schemes requests to return an ampty set of results. Requests stubbed with the above method will take precedence over this.



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gds_api/test_helpers/imminence.rb', line 33

def stub_imminence_default_business_support_schemes
  empty_results = {
    "_response_info" => {"status" => "ok"},
    "description" => "Business Support Schemes!",
    "total" => 0, "startIndex" => 1, "pageSize" => 0, "currentPage" => 1, "pages" => 1,
    "results" => []
  }

  stub_request(:get, %r{\A#{IMMINENCE_API_ENDPOINT}/business_support_schemes\.json}).
    to_return(:body => empty_results.to_json)
end