Sha256: 19685c114a2f6fe8017e49f97047178881c960abab9f5788430b40626c065a69

Contents?: true

Size: 1.11 KB

Versions: 36

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'protobuf/rpc/service_dispatcher'

RSpec.describe Protobuf::Rpc::ServiceDispatcher do
  let(:app) { proc { |env| env } }
  let(:env) do
    Protobuf::Rpc::Env.new(
      'method_name' => method_name,
      'request' => request,
      'rpc_service' => service_class,
      'service_name' => service_name,
    )
  end
  let(:method_name) { :find }
  let(:request) { request_type.new(:name => 'required') }
  let(:request_type) { service_class.rpcs[method_name].request_type }
  let(:response) { response_type.new(:name => 'required') }
  let(:response_type) { service_class.rpcs[method_name].response_type }
  let(:rpc_service) { service_class.new(env) }
  let(:service_class) { Test::ResourceService }
  let(:service_name) { service_class.to_s }

  subject { described_class.new(app) }

  before { allow(subject).to receive(:rpc_service).and_return(rpc_service) }

  describe '#call' do
    before { allow(rpc_service).to receive(:response).and_return(response) }

    it "dispatches the request" do
      stack_env = subject._call(env)
      expect(stack_env.response).to eq response
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
protobuf-3.10.9 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.8 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.7 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.6 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.5 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.4 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-cucumber-3.10.8 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-cucumber-3.10.7 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-cucumber-3.10.6 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-cucumber-3.10.5 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-cucumber-3.10.4 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.3 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.2 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.1 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.0 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.10.0.pre0 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.9.0 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.9.0.pre2 spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.9.0.pre spec/lib/protobuf/rpc/service_dispatcher_spec.rb
protobuf-3.8.5 spec/lib/protobuf/rpc/service_dispatcher_spec.rb