Class: SkullIsland::RSpec::FakeAPIClient
- Inherits:
-
APIClientBase
- Object
- APIClientBase
- SkullIsland::RSpec::FakeAPIClient
- Defined in:
- lib/skull_island/rspec/fake_api_client.rb
Overview
A Fake API Client for RSpec testing
Instance Attribute Summary
Attributes inherited from APIClientBase
#base_uri, #password, #server, #username
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(opts = {}) ⇒ FakeAPIClient
constructor
A new instance of FakeAPIClient.
- #response_for(type, uri, data: nil, response: {}) ⇒ Object
Methods inherited from APIClientBase
#api_uri, #authenticated?, #configured?, #delete, #get, #json_headers, #patch, #post, #put
Methods included from Helpers::APIClient
#about_service, #cache, #invalidate_cache_for, #json_escape, #lru_cache, #raw, #server_status, #version
Methods included from Validations::APIClient
#validate_creds, #validate_opts, #validate_server
Constructor Details
#initialize(opts = {}) ⇒ FakeAPIClient
Returns a new instance of FakeAPIClient.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/skull_island/rspec/fake_api_client.rb', line 7 def initialize(opts = {}) # validations validate_opts(opts) # Set up the client's state @server = opts[:server] || 'http://localhost:8001' @username = opts[:username] || 'admin' @password = opts[:password] || 'admin' @cache = LRUCache.new(100) # LRU cache of up to 100 items @configured = true end |
Instance Method Details
#connection ⇒ Object
23 24 25 |
# File 'lib/skull_island/rspec/fake_api_client.rb', line 23 def connection @connection ||= FakeRestClient.new end |
#response_for(type, uri, data: nil, response: {}) ⇒ Object
19 20 21 |
# File 'lib/skull_island/rspec/fake_api_client.rb', line 19 def response_for(type, uri, data: nil, response: {}) connection.response_for(type, uri, data: data, response: response) end |