Sha256: bcd43437287b2adca0599fbc2984dad29dd6cfe586953663f1ac7383f1019363

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe Protobuf::Rpc::Middleware::Logger do
  let(:app) { Proc.new { |inner_env| inner_env } }
  let(:env) {
    Protobuf::Rpc::Env.new(
      'client_host' => 'client_host.test.co',
      'encoded_request' => request_wrapper.encode,
      'encoded_response' => response_wrapper.encode,
      'method_name' => method_name,
      'request' => request,
      'request_type' => rpc_method.request_type,
      'response' => response,
      'response_type' => rpc_method.response_type,
      'rpc_method' => rpc_method,
      'rpc_service' => service_class,
      'service_name' => service_name,
    )
  }
  let(:method_name) { :find }
  let(:request) { request_type.new(:name => 'required') }
  let(:request_type) { rpc_method.request_type }
  let(:request_wrapper) {
    Protobuf::Socketrpc::Request.new(
      :service_name => service_name,
      :method_name => method_name.to_s,
      :request_proto => request
    )
  }
  let(:response_wrapper) { Protobuf::Socketrpc::Response.new(:response_proto => response) }
  let(:response) { rpc_method.response_type.new(:name => 'required') }
  let(:rpc_method) { service_class.rpcs[method_name] }
  let(:rpc_service) { service_class.new(env) }
  let(:service_class) { Test::ResourceService }
  let(:service_name) { service_class.to_s }

  subject { described_class.new(app) }

  describe "#call" do
    it "calls the stack" do
      app.should_receive(:call).with(env)
      subject.call(env)
    end

    it "returns the env" do
      subject.call(env).should eq env
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
protobuffy-3.6.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuffy-3.5.1 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuffy-3.4.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuffy-3.3.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuffy-3.2.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuffy-3.1.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuf-3.0.4 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuf-3.0.3 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuf-3.0.2 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuf-3.0.1 spec/lib/protobuf/rpc/middleware/logger_spec.rb
protobuf-3.0.0 spec/lib/protobuf/rpc/middleware/logger_spec.rb