Sha256: 1a199b6dbb56c1e6271fa93928fab6fd1d9ccbdd28673efbf76254967c291acb

Contents?: true

Size: 1.09 KB

Versions: 27

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

require 'protobuf/generators/service_generator'

describe ::Protobuf::Generators::ServiceGenerator do

  let(:methods) {
    [
      { :name => 'Search', :input_type => 'FooRequest', :output_type => 'FooResponse' },
      { :name => 'FooBar', :input_type => '.foo.Request', :output_type => '.bar.Response' }
    ]
  }
  let(:service_fields) { { :name => 'TestService',
                           :method => methods } }

  let(:service) { ::Google::Protobuf::ServiceDescriptorProto.new(service_fields) }

  subject { described_class.new(service) }

  describe '#compile' do
    let(:compiled) {
      %q{class TestService < ::Protobuf::Rpc::Service
  rpc :search, FooRequest, FooResponse
  rpc :foo_bar, ::Foo::Request, ::Bar::Response
end

}
    }

    it 'compiles the service and it\'s rpc methods' do
      subject.compile
      subject.to_s.should eq(compiled)
    end
  end

  describe '#build_method' do
    it 'returns a string identifying the given method descriptor' do
      subject.build_method(service.method.first).should eq("rpc :search, FooRequest, FooResponse")
    end
  end

end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
protobuffy-3.6.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuffy-3.5.1 spec/lib/protobuf/generators/service_generator_spec.rb
protobuffy-3.4.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuffy-3.3.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuffy-3.2.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuffy-3.1.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.4 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.13 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.3 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.2 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.1 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.0 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.0.rc2 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-3.0.0.rc1 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.12 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.11 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.10 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.9 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.8 spec/lib/protobuf/generators/service_generator_spec.rb
protobuf-2.8.7 spec/lib/protobuf/generators/service_generator_spec.rb