Module: GdsApi::TestHelpers::LicenceApplication

Extended by:
AliasDeprecated
Defined in:
lib/gds_api/test_helpers/licence_application.rb

Constant Summary collapse

LICENCE_APPLICATION_ENDPOINT =

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

Plek.current.find("licensify")

Instance Method Summary collapse

Methods included from AliasDeprecated

alias_deprecated

Instance Method Details

#stub_licence_does_not_exist(identifier) ⇒ Object



21
22
23
24
25
26
# File 'lib/gds_api/test_helpers/licence_application.rb', line 21

def stub_licence_does_not_exist(identifier)
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
    with(headers: GdsApi::JsonClient.default_request_headers).
    to_return(status: 404,
      body: "{\"error\": [\"Unrecognised Licence Id: #{identifier}\"]}")
end

#stub_licence_exists(identifier, licence) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/gds_api/test_helpers/licence_application.rb', line 13

def stub_licence_exists(identifier, licence)
  licence = licence.to_json unless licence.is_a?(String)
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").
    with(headers: GdsApi::JsonClient.default_request_headers).
    to_return(status: 200,
      body: licence)
end

#stub_licence_returns_error(identifier) ⇒ Object



32
33
34
# File 'lib/gds_api/test_helpers/licence_application.rb', line 32

def stub_licence_returns_error(identifier)
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500)
end

#stub_licence_times_out(identifier) ⇒ Object



28
29
30
# File 'lib/gds_api/test_helpers/licence_application.rb', line 28

def stub_licence_times_out(identifier)
  stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_timeout
end