Module: GdsApi::TestHelpers::LicenceApplication
- Defined in:
- lib/gds_api/test_helpers/licence_application.rb
Constant Summary collapse
- LICENCE_APPLICATION_ENDPOINT =
"https://licensify.test.alphagov.co.uk"
Instance Method Summary collapse
- #licence_does_not_exist(identifier) ⇒ Object
- #licence_exists(identifier, licence) ⇒ Object
- #licence_returns_error(identifier) ⇒ Object
- #licence_times_out(identifier) ⇒ Object
Instance Method Details
#licence_does_not_exist(identifier) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gds_api/test_helpers/licence_application.rb', line 16 def 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 |
#licence_exists(identifier, licence) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gds_api/test_helpers/licence_application.rb', line 8 def 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 |
#licence_returns_error(identifier) ⇒ Object
27 28 29 |
# File 'lib/gds_api/test_helpers/licence_application.rb', line 27 def licence_returns_error(identifier) stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_return(status: 500) end |
#licence_times_out(identifier) ⇒ Object
23 24 25 |
# File 'lib/gds_api/test_helpers/licence_application.rb', line 23 def licence_times_out(identifier) stub_request(:get, "#{LICENCE_APPLICATION_ENDPOINT}/api/licence/#{identifier}").to_timeout end |