Sha256: c260cd93dc4bcb5dcdcf4f161dc77ff2a354b7ce1afdc83748bf9b6113fad09f

Contents?: true

Size: 566 Bytes

Versions: 3

Compression:

Stored size: 566 Bytes

Contents

# frozen_string_literal: true

module GrpcMock
  class StubRegistry
    def initialize
      @request_stubs = []
    end

    def reset!
      @request_stubs = []
    end

    # @param stub [GrpcMock::RequestStub]
    def register_request_stub(stub)
      @request_stubs.unshift(stub)
      stub
    end

    # @param path [String]
    # @param request [Object]
    def response_for_request(path, request)
      rstub = @request_stubs.find do |stub|
        stub.match?(path, request)
      end

      if rstub
        rstub.response.dup
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grpc_mock-0.3.0 lib/grpc_mock/stub_registry.rb
grpc_mock-0.2.2 lib/grpc_mock/stub_registry.rb
grpc_mock-0.2.1 lib/grpc_mock/stub_registry.rb