class SkullIsland::RSpec::FakeAPIClient

A Fake API Client for RSpec testing

Public Class Methods

new(opts = {}) click to toggle source
# 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

Public Instance Methods

connection() click to toggle source
# File lib/skull_island/rspec/fake_api_client.rb, line 23
def connection
  @connection ||= FakeRestClient.new
end
response_for(type, uri, data: nil, response: {}) click to toggle source
# 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