module Aws::ClientStubs

def self.included(subclass)

Other tags:
    Api: - private
def self.included(subclass)
  subclass.add_plugin('Aws::Plugins::StubResponses')
end

def apply_stubs(operation_name, stubs)

def apply_stubs(operation_name, stubs)
  @stub_mutex.synchronize do
    @stubs[operation_name.to_sym] = stubs.map do |stub|
      case stub
      when Exception then stub
      when String then service_error_class(stub)
      when Hash then new_stub(operation_name, stub)
      else stub
      end
    end
  end
end

def initialize(*args)

def initialize(*args)
  @stubs = {}
  @stub_mutex = Mutex.new
  super
end

def new_stub(operation_name, data = nil)

Returns:
  • (Structure) -

Parameters:
  • data (Hash, nil) --
  • operation_name (Symbol) --
def new_stub(operation_name, data = nil)
  Stub.new(operation(operation_name).output).format(data || {})
end

def next_stub(operation_name)

Other tags:
    Api: - private
def next_stub(operation_name)
  @stub_mutex.synchronize do
    stubs = @stubs[operation_name.to_sym] || []
    case stubs.length
    when 0 then new_stub(operation_name)
    when 1 then stubs.first
    else stubs.shift
    end
  end
end

def service_error_class(name)

def service_error_class(name)
  svc_module = Aws.const_get(self.class.name.split('::')[1])
  svc_module.const_get(:Errors).const_get(name)
end

def stub_responses(operation_name, *stubs)

Raises:
  • (RuntimeError) - Raises a runtime error when called

Returns:
  • (void) -

Parameters:
  • stubs (Mixed) -- One or more responses to return from the named
  • operation_name (Symbol) --
def stub_responses(operation_name, *stubs)
  if config.stub_responses
    apply_stubs(operation_name, stubs.flatten)
  else
    msg = 'stubbing is not enabled; enable stubbing in the constructor '
    msg << 'with `:stub_responses => true`'
    raise msg
  end
end