Module: Aws::AsyncClientStubs

Includes:
ClientStubs
Defined in:
lib/aws-sdk-core/async_client_stubs.rb

Defined Under Namespace

Classes: StubStream

Instance Method Summary collapse

Methods included from ClientStubs

#api_requests, #next_stub, #stub_data, #stub_responses

Instance Method Details

#send_eventsObject



43
44
45
46
47
48
49
50
51
# File 'lib/aws-sdk-core/async_client_stubs.rb', line 43

def send_events
  if config.stub_responses
    @send_events
  else
    msg = 'This method is only implemented for stubbed clients, and is '\
          'available when you enable stubbing in the constructor with `stub_responses: true`'
    raise NotImplementedError.new(msg)
  end
end

#setup_stubbingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aws-sdk-core/async_client_stubs.rb', line 9

def setup_stubbing
  @stubs = {}
  @stub_mutex = Mutex.new
  if Hash === @config.stub_responses
    @config.stub_responses.each do |operation_name, stubs|
      apply_stubs(operation_name, Array === stubs ? stubs : [stubs])
    end
  end

  # When a client is stubbed allow the user to access the requests made
  @api_requests = []

  # allow to access signaled events when client is stubbed
  @send_events = []

  requests = @api_requests
  send_events = @send_events

  self.handle do |context|
    if input_stream = context[:input_event_stream_handler]
      stub_stream = StubStream.new
      stub_stream.send_events = send_events
      input_stream.event_emitter.stream = stub_stream 
      input_stream.event_emitter.validate_event = context.config.validate_params
    end
    requests << {
      operation_name: context.operation_name,
      params: context.params,
      context: context
    }
    @handler.call(context)
  end
end