class ProtoPharm::RSpec::ActionStubBuilder

Attributes

action_stub_proxy[RW]
grpc_service[RW]

Public Class Methods

new(grpc_service) click to toggle source
# File lib/proto_pharm/rspec/action_stub_builder.rb, line 10
def initialize(grpc_service)
  @grpc_service = grpc_service
end

Public Instance Methods

to(action_stub_proxy) click to toggle source
# File lib/proto_pharm/rspec/action_stub_builder.rb, line 14
def to(action_stub_proxy)
  @action_stub_proxy = action_stub_proxy

  ProtoPharm.stub_registry.register_request_stub(action_stub)
end

Private Instance Methods

action_stub() click to toggle source
# File lib/proto_pharm/rspec/action_stub_builder.rb, line 22
def action_stub
  @action_stub ||= ActionStub.new(grpc_service, rpc_action).tap do |stub|
    expectations.each do |ex|
      if ex.kwargs.blank?
        stub.public_send(ex.method, *ex.args)
      elsif ex.args.blank?
        stub.public_send(ex.method, **ex.kwargs)
      else
        stub.public_send(ex.method, *ex.args, **ex.kwargs)
      end
    end
  end
end