Method: GdsApi::TestHelpers::AccountApi#stub_account_api_request

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

#stub_account_api_request(method, path, with: {}, response_status: 200, response_body: {}, govuk_account_session: nil, new_govuk_account_session: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/gds_api/test_helpers/account_api.rb', line 8

def (method, path, with: {}, response_status: 200, response_body: {}, govuk_account_session: nil, new_govuk_account_session: nil)
  with.merge!(headers: { GdsApi::AccountApi::AUTH_HEADER_NAME =>  }) if 
   = nil if response_status >= 400
  to_return = { status: response_status, body: response_body.merge(govuk_account_session: ).compact.to_json }
  if with.empty?
    stub_request(method, "#{ACCOUNT_API_ENDPOINT}#{path}").to_return(**to_return)
  else
    stub_request(method, "#{ACCOUNT_API_ENDPOINT}#{path}").with(**with).to_return(**to_return)
  end
end