Module: GdsApi::TestHelpers::BusinessSupportApi
- Includes:
- CommonResponses
- Defined in:
- lib/gds_api/test_helpers/business_support_api.rb
Constant Summary
collapse
- BUSINESS_SUPPORT_API_ENDPOINT =
Generally true. If you are initializing the client differently, you could redefine/override the constant or stub directly.
Plek.current.find('business-support-api')
Instance Method Summary
collapse
#acronymize_slug, #plural_response_base, #response_base, #titleize_slug
Instance Method Details
#business_support_api_has_a_scheme(slug, scheme) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/gds_api/test_helpers/business_support_api.rb', line 41
def business_support_api_has_a_scheme(slug, scheme)
title = scheme.delete(:title)
stub_request(:get, %r{\A#{BUSINESS_SUPPORT_API_ENDPOINT}/business-support-schemes/#{slug}\.json}).to_return do |request|
{:body => response_base.merge(:format => 'business_support', :title => title, :details => scheme).to_json}
end
end
|
#business_support_api_has_scheme(scheme, facets = {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/gds_api/test_helpers/business_support_api.rb', line 27
def business_support_api_has_scheme(scheme, facets={})
key = facet_key(facets)
unless @stubbed_business_support_schemes.has_key?(key)
@stubbed_business_support_schemes[key] = []
end
@stubbed_business_support_schemes[key] << scheme
end
|
#business_support_api_has_schemes(schemes, facets = {}) ⇒ Object
35
36
37
38
39
|
# File 'lib/gds_api/test_helpers/business_support_api.rb', line 35
def business_support_api_has_schemes(schemes, facets={})
schemes.each do |scheme|
business_support_api_has_scheme(scheme, facets)
end
end
|
#setup_business_support_api_schemes_stubs ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/gds_api/test_helpers/business_support_api.rb', line 13
def setup_business_support_api_schemes_stubs
@stubbed_business_support_schemes = {}
stub_request(:get, %r{\A#{BUSINESS_SUPPORT_API_ENDPOINT}/business-support-schemes\.json}).to_return do |request|
if request.uri.query_values
key = facet_key(request.uri.query_values)
results = @stubbed_business_support_schemes[key] || []
else
results = @stubbed_business_support_schemes['default']
end
{:body => plural_response_base.merge("results" => results, "total" => results.size).to_json}
end
end
|