protobuf 2.2.5-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +9 -0
- data/.yardopts +5 -0
- data/Gemfile +3 -0
- data/README.md +316 -0
- data/Rakefile +29 -0
- data/UPGRADING.md +60 -0
- data/bin/rpc_server +5 -0
- data/bin/rprotoc +62 -0
- data/examples/addressbook.pb.rb +55 -0
- data/examples/addressbook.proto +24 -0
- data/examples/reading_a_message.rb +32 -0
- data/examples/writing_a_message.rb +46 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/code_generator.h +142 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/command_line_interface.h +318 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_enum.h +99 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_enum_field.h +103 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_extension.h +85 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_field.h +167 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_file.h +98 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_helpers.h +159 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_message.h +170 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_message_field.h +102 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +103 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_string_field.h +104 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h +2721 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/importer.h +303 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_enum.h +84 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_enum_field.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_extension.h +77 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_field.h +108 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_file.h +101 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_generator.h +72 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_helpers.h +213 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_message.h +109 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_message_field.h +134 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_primitive_field.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_service.h +113 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/java/java_string_field.h +120 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/mock_code_generator.h +113 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/package_info.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/parser.h +434 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/plugin.h +73 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/plugin.pb.h +790 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/python/python_generator.h +156 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/subprocess.h +108 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/compiler/zip_writer.h +93 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor.h +1367 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor.pb.h +5223 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/descriptor_database.h +366 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/dynamic_message.h +136 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/extension_set.h +904 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/generated_message_reflection.h +424 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/generated_message_util.h +82 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/coded_stream.h +1102 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/coded_stream_inl.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/gzip_stream.h +207 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/package_info.h +54 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/printer.h +136 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/tokenizer.h +313 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream.h +238 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream_impl.h +357 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/io/zero_copy_stream_impl_lite.h +340 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/message.h +692 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/message_lite.h +239 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/package_info.h +64 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/reflection_ops.h +80 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/repeated_field.h +1295 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/service.h +291 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/common.h +1211 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/hash.h +220 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/map-util.h +119 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/once.h +123 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/stl_util-inl.h +121 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/strutil.h +457 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/stubs/substitute.h +170 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/test_util.h +174 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/test_util_lite.h +101 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/testing/file.h +83 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/testing/googletest.h +98 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/text_format.h +285 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest.pb.h +11915 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_custom_options.pb.h +2895 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_embed_optimize_for.pb.h +211 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_empty.pb.h +56 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_import.pb.h +188 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_import_lite.pb.h +151 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_lite.pb.h +4752 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_lite_imports_nonlite.pb.h +150 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_mset.pb.h +816 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_no_generic_services.pb.h +197 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unittest_optimize_for.pb.h +403 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/unknown_field_set.h +268 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format.h +304 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format_lite.h +620 -0
- data/ext/protobuf-2.4.1/src/google/protobuf/wire_format_lite_inl.h +774 -0
- data/ext/ruby_generator/Makefile +10 -0
- data/ext/ruby_generator/RubyGenerator.cpp +450 -0
- data/ext/ruby_generator/RubyGenerator.h +199 -0
- data/ext/ruby_generator/extconf.rb +36 -0
- data/ext/ruby_generator/protoc-ruby +0 -0
- data/lib/protobuf/cli.rb +188 -0
- data/lib/protobuf/enum.rb +58 -0
- data/lib/protobuf/enum_value.rb +59 -0
- data/lib/protobuf/evented.rb +22 -0
- data/lib/protobuf/exceptions.rb +11 -0
- data/lib/protobuf/ext/eventmachine.rb +14 -0
- data/lib/protobuf/field/base_field.rb +240 -0
- data/lib/protobuf/field/bool_field.rb +36 -0
- data/lib/protobuf/field/bytes_field.rb +38 -0
- data/lib/protobuf/field/double_field.rb +19 -0
- data/lib/protobuf/field/enum_field.rb +50 -0
- data/lib/protobuf/field/extension_fields.rb +32 -0
- data/lib/protobuf/field/field_array.rb +65 -0
- data/lib/protobuf/field/fixed32_field.rb +19 -0
- data/lib/protobuf/field/fixed64_field.rb +22 -0
- data/lib/protobuf/field/float_field.rb +31 -0
- data/lib/protobuf/field/int32_field.rb +12 -0
- data/lib/protobuf/field/int64_field.rb +12 -0
- data/lib/protobuf/field/integer_field.rb +19 -0
- data/lib/protobuf/field/message_field.rb +53 -0
- data/lib/protobuf/field/sfixed32_field.rb +21 -0
- data/lib/protobuf/field/sfixed64_field.rb +24 -0
- data/lib/protobuf/field/signed_integer_field.rb +23 -0
- data/lib/protobuf/field/sint32_field.rb +12 -0
- data/lib/protobuf/field/sint64_field.rb +12 -0
- data/lib/protobuf/field/string_field.rb +14 -0
- data/lib/protobuf/field/uint32_field.rb +12 -0
- data/lib/protobuf/field/uint64_field.rb +12 -0
- data/lib/protobuf/field/varint_field.rb +61 -0
- data/lib/protobuf/field.rb +57 -0
- data/lib/protobuf/logger.rb +86 -0
- data/lib/protobuf/message/decoder.rb +83 -0
- data/lib/protobuf/message/encoder.rb +48 -0
- data/lib/protobuf/message/extend.rb +8 -0
- data/lib/protobuf/message/message.rb +1 -0
- data/lib/protobuf/message.rb +320 -0
- data/lib/protobuf/rpc/buffer.rb +79 -0
- data/lib/protobuf/rpc/client.rb +166 -0
- data/lib/protobuf/rpc/connector.rb +19 -0
- data/lib/protobuf/rpc/connectors/base.rb +38 -0
- data/lib/protobuf/rpc/connectors/common.rb +156 -0
- data/lib/protobuf/rpc/connectors/em_client.rb +84 -0
- data/lib/protobuf/rpc/connectors/eventmachine.rb +87 -0
- data/lib/protobuf/rpc/connectors/socket.rb +73 -0
- data/lib/protobuf/rpc/connectors/zmq.rb +69 -0
- data/lib/protobuf/rpc/error/client_error.rb +31 -0
- data/lib/protobuf/rpc/error/server_error.rb +43 -0
- data/lib/protobuf/rpc/error.rb +25 -0
- data/lib/protobuf/rpc/rpc.pb.rb +118 -0
- data/lib/protobuf/rpc/server.rb +89 -0
- data/lib/protobuf/rpc/servers/evented/server.rb +41 -0
- data/lib/protobuf/rpc/servers/evented_runner.rb +21 -0
- data/lib/protobuf/rpc/servers/socket/server.rb +111 -0
- data/lib/protobuf/rpc/servers/socket/worker.rb +66 -0
- data/lib/protobuf/rpc/servers/socket_runner.rb +27 -0
- data/lib/protobuf/rpc/servers/zmq/broker.rb +87 -0
- data/lib/protobuf/rpc/servers/zmq/server.rb +50 -0
- data/lib/protobuf/rpc/servers/zmq/util.rb +27 -0
- data/lib/protobuf/rpc/servers/zmq/worker.rb +60 -0
- data/lib/protobuf/rpc/servers/zmq_runner.rb +25 -0
- data/lib/protobuf/rpc/service.rb +173 -0
- data/lib/protobuf/rpc/service_dispatcher.rb +130 -0
- data/lib/protobuf/rpc/service_filters.rb +267 -0
- data/lib/protobuf/rpc/stat.rb +83 -0
- data/lib/protobuf/socket.rb +22 -0
- data/lib/protobuf/version.rb +4 -0
- data/lib/protobuf/wire_type.rb +10 -0
- data/lib/protobuf/zmq.rb +21 -0
- data/lib/protobuf.rb +86 -0
- data/proto/rpc.pb.rb +48 -0
- data/proto/rpc.proto +73 -0
- data/protobuf.gemspec +44 -0
- data/spec/benchmark/tasks.rb +179 -0
- data/spec/functional/embedded_service_spec.rb +7 -0
- data/spec/functional/evented_server_spec.rb +64 -0
- data/spec/functional/socket_server_spec.rb +58 -0
- data/spec/functional/zmq_server_spec.rb +58 -0
- data/spec/lib/protobuf/cli_spec.rb +212 -0
- data/spec/lib/protobuf/enum_spec.rb +98 -0
- data/spec/lib/protobuf/enum_value_spec.rb +15 -0
- data/spec/lib/protobuf/logger_spec.rb +131 -0
- data/spec/lib/protobuf/message/encoder_spec.rb +19 -0
- data/spec/lib/protobuf/message_spec.rb +209 -0
- data/spec/lib/protobuf/rpc/client_spec.rb +158 -0
- data/spec/lib/protobuf/rpc/connector_spec.rb +32 -0
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +50 -0
- data/spec/lib/protobuf/rpc/connectors/common_spec.rb +128 -0
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +36 -0
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +22 -0
- data/spec/lib/protobuf/rpc/servers/evented_server_spec.rb +18 -0
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +43 -0
- data/spec/lib/protobuf/rpc/servers/zmq/broker_spec.rb +35 -0
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +41 -0
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +45 -0
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +44 -0
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +116 -0
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +451 -0
- data/spec/lib/protobuf/rpc/service_spec.rb +165 -0
- data/spec/lib/protobuf_spec.rb +62 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/all.rb +6 -0
- data/spec/support/server.rb +101 -0
- data/spec/support/test/enum.pb.rb +34 -0
- data/spec/support/test/enum.proto +12 -0
- data/spec/support/test/resource.pb.rb +58 -0
- data/spec/support/test/resource.proto +31 -0
- data/spec/support/test/resource_service.rb +14 -0
- data/spec/support/test_app_file.rb +2 -0
- data/spec/support/tolerance_matcher.rb +40 -0
- data/test/data/data.bin +3 -0
- data/test/data/data_source.py +14 -0
- data/test/data/types.bin +0 -0
- data/test/data/types_source.py +22 -0
- data/test/data/unk.png +0 -0
- data/test/proto/addressbook.pb.rb +66 -0
- data/test/proto/addressbook.proto +33 -0
- data/test/proto/addressbook_base.pb.rb +58 -0
- data/test/proto/addressbook_base.proto +26 -0
- data/test/proto/addressbook_ext.pb.rb +20 -0
- data/test/proto/addressbook_ext.proto +6 -0
- data/test/proto/collision.pb.rb +17 -0
- data/test/proto/collision.proto +5 -0
- data/test/proto/ext_collision.pb.rb +24 -0
- data/test/proto/ext_collision.proto +8 -0
- data/test/proto/ext_range.pb.rb +22 -0
- data/test/proto/ext_range.proto +7 -0
- data/test/proto/float_default.proto +10 -0
- data/test/proto/lowercase.pb.rb +30 -0
- data/test/proto/lowercase.proto +9 -0
- data/test/proto/merge.pb.rb +39 -0
- data/test/proto/merge.proto +15 -0
- data/test/proto/nested.pb.rb +30 -0
- data/test/proto/nested.proto +9 -0
- data/test/proto/optional_field.pb.rb +35 -0
- data/test/proto/optional_field.proto +12 -0
- data/test/proto/packed.pb.rb +22 -0
- data/test/proto/packed.proto +6 -0
- data/test/proto/rpc.proto +6 -0
- data/test/proto/types.pb.rb +84 -0
- data/test/proto/types.proto +37 -0
- data/test/test_addressbook.rb +56 -0
- data/test/test_enum_value.rb +41 -0
- data/test/test_extension.rb +36 -0
- data/test/test_lowercase.rb +11 -0
- data/test/test_message.rb +128 -0
- data/test/test_optional_field.rb +103 -0
- data/test/test_packed_field.rb +40 -0
- data/test/test_parse.rb +15 -0
- data/test/test_repeated_types.rb +132 -0
- data/test/test_serialize.rb +61 -0
- data/test/test_standard_message.rb +96 -0
- data/test/test_types.rb +226 -0
- metadata +461 -0
@@ -0,0 +1,209 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Protobuf::Message do
|
4
|
+
|
5
|
+
describe '#initialize' do
|
6
|
+
it "does not try to set attributes which have nil values" do
|
7
|
+
Test::EnumTestMessage.any_instance.should_not_receive("non_default_enum=")
|
8
|
+
test_enum = Test::EnumTestMessage.new(:non_default_enum => nil)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "takes a hash as an initialization argument" do
|
12
|
+
test_enum = Test::EnumTestMessage.new(:non_default_enum => 2)
|
13
|
+
test_enum.non_default_enum.should eq(2)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "initializes with an object that responds to #to_hash" do
|
17
|
+
hashie_object = OpenStruct.new(:to_hash => { :non_default_enum => 2 })
|
18
|
+
test_enum = Test::EnumTestMessage.new(hashie_object)
|
19
|
+
test_enum.non_default_enum.should eq(2)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "boolean predicate methods" do
|
24
|
+
subject { Test::ResourceFindRequest.new(:name => "resource") }
|
25
|
+
|
26
|
+
it { should respond_to(:active?) }
|
27
|
+
|
28
|
+
it "sets the predicate to true when the boolean value is true" do
|
29
|
+
subject.active = true
|
30
|
+
subject.active?.should be_true
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets the predicate to false when the boolean value is false" do
|
34
|
+
subject.active = false
|
35
|
+
subject.active?.should be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "does not put predicate methods on non-boolean fields" do
|
39
|
+
Test::ResourceFindRequest.new(:name => "resource").should_not respond_to(:name?)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#respond_to_and_has?" do
|
44
|
+
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
45
|
+
|
46
|
+
it "is false when the message does not have the field" do
|
47
|
+
subject.respond_to_and_has?(:other_field).should be_false
|
48
|
+
end
|
49
|
+
|
50
|
+
it "is true when the message has the field" do
|
51
|
+
subject.respond_to_and_has?(:non_default_enum).should be_true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#respond_to_has_and_present?" do
|
56
|
+
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
57
|
+
|
58
|
+
it "is false when the message does not have the field" do
|
59
|
+
subject.respond_to_and_has_and_present?(:other_field).should be_false
|
60
|
+
end
|
61
|
+
|
62
|
+
it "is false when the field is repeated and a value is not present" do
|
63
|
+
subject.respond_to_and_has_and_present?(:repeated_enums).should be_false
|
64
|
+
end
|
65
|
+
|
66
|
+
it "is false when the field is repeated and the value is empty array" do
|
67
|
+
subject.repeated_enums = []
|
68
|
+
subject.respond_to_and_has_and_present?(:repeated_enums).should be_false
|
69
|
+
end
|
70
|
+
|
71
|
+
it "is true when the field is repeated and a value is present" do
|
72
|
+
subject.repeated_enums = [2]
|
73
|
+
subject.respond_to_and_has_and_present?(:repeated_enums).should be_true
|
74
|
+
end
|
75
|
+
|
76
|
+
it "is true when the message has the field" do
|
77
|
+
subject.respond_to_and_has_and_present?(:non_default_enum).should be_true
|
78
|
+
end
|
79
|
+
|
80
|
+
context "#API" do
|
81
|
+
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
82
|
+
|
83
|
+
it { should respond_to(:respond_to_and_has_and_present?) }
|
84
|
+
it { should respond_to(:responds_to_and_has_and_present?) }
|
85
|
+
it { should respond_to(:responds_to_has?) }
|
86
|
+
it { should respond_to(:respond_to_has?) }
|
87
|
+
it { should respond_to(:respond_to_has_present?) }
|
88
|
+
it { should respond_to(:responds_to_has_present?) }
|
89
|
+
it { should respond_to(:respond_to_and_has_present?) }
|
90
|
+
it { should respond_to(:responds_to_and_has_present?) }
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#to_hash' do
|
96
|
+
context 'generating values for an ENUM field' do
|
97
|
+
it 'converts the enum to its tag representation' do
|
98
|
+
hash = Test::EnumTestMessage.new(:non_default_enum => :TWO).to_hash
|
99
|
+
hash.should eq({ :non_default_enum => 2 })
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'does not populate default values' do
|
103
|
+
hash = Test::EnumTestMessage.new.to_hash
|
104
|
+
hash.should eq(Hash.new)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'converts repeated enum fields to an array of the tags' do
|
108
|
+
hash = Test::EnumTestMessage.new(:repeated_enums => [ :ONE, :TWO, :TWO, :ONE ]).to_hash
|
109
|
+
hash.should eq({ :repeated_enums => [ 1, 2, 2, 1 ] })
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'generating values for a Message field' do
|
114
|
+
it 'recursively hashes field messages' do
|
115
|
+
hash = Test::Nested.new({ :resource => { :name => 'Nested' } }).to_hash
|
116
|
+
hash.should eq({ :resource => { :name => 'Nested' } })
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'recursively hashes a repeated set of messages' do
|
120
|
+
proto = Test::Nested.new(:multiple_resources => [
|
121
|
+
Test::Resource.new(:name => 'Resource 1'),
|
122
|
+
Test::Resource.new(:name => 'Resource 2')
|
123
|
+
])
|
124
|
+
|
125
|
+
proto.to_hash.should eq({ :multiple_resources => [ { :name => 'Resource 1' },
|
126
|
+
{ :name => 'Resource 2' } ] })
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#to_json' do
|
133
|
+
subject do
|
134
|
+
::Test::ResourceFindRequest.new({ :name => 'Test Name', :active => false })
|
135
|
+
end
|
136
|
+
|
137
|
+
its(:to_json) { should eq '{"name":"Test Name","active":false}' }
|
138
|
+
end
|
139
|
+
|
140
|
+
describe '#get_field_by_name' do
|
141
|
+
subject do
|
142
|
+
::Test::Resource.new({ :name => 'Test Name', :date_created => Time.now.to_i })
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when name is a valid field' do
|
146
|
+
let(:valid_field) { subject.get_field_by_name(:name) }
|
147
|
+
specify { valid_field.should be_a ::Protobuf::Field::StringField }
|
148
|
+
specify { valid_field.name.should eq :name }
|
149
|
+
end
|
150
|
+
|
151
|
+
context 'when name is not a valid field' do
|
152
|
+
specify do
|
153
|
+
expect {
|
154
|
+
subject.get_field_by_name(1)
|
155
|
+
}.to raise_error(::Protobuf::Message::FieldNotDefinedError, /.*1.*#{subject.class.name}/)
|
156
|
+
end
|
157
|
+
|
158
|
+
specify do
|
159
|
+
expect {
|
160
|
+
subject.get_field_by_name(:nothere)
|
161
|
+
}.to raise_error(::Protobuf::Message::FieldNotDefinedError, /.*nothere.*#{subject.class.name}/)
|
162
|
+
end
|
163
|
+
|
164
|
+
specify do
|
165
|
+
expect {
|
166
|
+
subject.get_field_by_name(nil)
|
167
|
+
}.to raise_error(::Protobuf::Message::FieldNotDefinedError, /.*nil.*#{subject.class.name}/)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#get_ext_field_by_name' do
|
173
|
+
pending 'Need to get a proto compiled with extensions first'
|
174
|
+
end
|
175
|
+
|
176
|
+
describe '#get_field_by_tag' do
|
177
|
+
subject do
|
178
|
+
::Test::Resource.new({ :name => 'Test Name', :date_created => Time.now.to_i })
|
179
|
+
end
|
180
|
+
|
181
|
+
context 'when tag references a valid field' do
|
182
|
+
let(:valid_field) { subject.get_field_by_tag(1) }
|
183
|
+
specify { valid_field.should be_a ::Protobuf::Field::StringField }
|
184
|
+
specify { valid_field.name.should eq :name }
|
185
|
+
end
|
186
|
+
|
187
|
+
context 'when tag does not reference a field' do
|
188
|
+
it 'returns nil' do
|
189
|
+
pending 'need to implement a range-limiting array sub-class for field access'
|
190
|
+
subject.get_field_by_tag(-1).should be_nil
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'when tag is not numeric' do
|
195
|
+
specify do
|
196
|
+
expect {
|
197
|
+
subject.get_field_by_tag("not a number")
|
198
|
+
}.to raise_error(::Protobuf::Message::FieldNotDefinedError, /.*not a number.*#{subject.class.name}/)
|
199
|
+
end
|
200
|
+
|
201
|
+
specify do
|
202
|
+
expect {
|
203
|
+
subject.get_field_by_tag(nil)
|
204
|
+
}.to raise_error(::Protobuf::Message::FieldNotDefinedError, /.*nil.*#{subject.class.name}/)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spec/support/test/resource_service'
|
3
|
+
|
4
|
+
describe Protobuf::Rpc::Client do
|
5
|
+
before(:each) do
|
6
|
+
load 'protobuf/evented.rb'
|
7
|
+
end
|
8
|
+
|
9
|
+
context "when using fiber based calls" do
|
10
|
+
it "waits for response" do
|
11
|
+
EventMachine.fiber_run do
|
12
|
+
StubServer.new(:delay => 3) do |server|
|
13
|
+
client = Test::ResourceService.client
|
14
|
+
start = now
|
15
|
+
|
16
|
+
client.find(:name => "Test Name", :active => true) do |c|
|
17
|
+
c.on_success do |succ|
|
18
|
+
succ.name.should eq("Test Name")
|
19
|
+
succ.status.should eq(Test::StatusType::ENABLED)
|
20
|
+
end
|
21
|
+
|
22
|
+
c.on_failure do |err|
|
23
|
+
raise err.inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
(now - start).should be_within(server.options.delay * 0.10).of(server.options.delay)
|
28
|
+
end
|
29
|
+
|
30
|
+
EM.stop
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "throws and error when call is attempted without 'EventMachine.fiber_run'" do
|
35
|
+
subject = Proc.new do
|
36
|
+
EventMachine.run do
|
37
|
+
StubServer.new(:delay => 1) do |server|
|
38
|
+
client = Test::ResourceService.client
|
39
|
+
client.find(:name => "Test Name", :active => true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
subject.should raise_error(RuntimeError, /EM.fiber_run/)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "throws a timeout when client timeout is exceeded" do
|
48
|
+
error = nil
|
49
|
+
test_proc = Proc.new do
|
50
|
+
EventMachine.fiber_run do
|
51
|
+
StubServer.new(:delay => 2) do |server|
|
52
|
+
client = Test::ResourceService.client(:timeout => 1)
|
53
|
+
client.find(:name => "Test Name", :active => true) do |cl|
|
54
|
+
cl.on_success {}
|
55
|
+
cl.on_failure {|f| error = f}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
EM.stop
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
test_proc.call
|
63
|
+
error.message.should =~ /timeout/i
|
64
|
+
end
|
65
|
+
|
66
|
+
context "without reactor_running?" do
|
67
|
+
|
68
|
+
it "throws a timeout when client timeout is exceeded" do
|
69
|
+
subject = Proc.new do
|
70
|
+
StubServer.new(:delay => 2) do |server|
|
71
|
+
client = Test::ResourceService.client(:timeout => 1)
|
72
|
+
client.find(:name => "Test Name", :active => true)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
subject.should raise_error(RuntimeError, /timeout/i)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "calls failure_cb & throws a timeout when client timeout is exceeded" do
|
80
|
+
failure_message = nil
|
81
|
+
|
82
|
+
subject = Proc.new do
|
83
|
+
StubServer.new(:delay => 2) do |server|
|
84
|
+
client = Test::ResourceService.client(:timeout => 1)
|
85
|
+
client.find(:name => "Test Name", :active => true) do |c|
|
86
|
+
c.on_failure do |f|
|
87
|
+
failure_message = f.message
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
subject.call
|
94
|
+
failure_message.should match(/timeout/)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when creating a client from a service' do
|
102
|
+
before { reset_service_location(Test::ResourceService) }
|
103
|
+
|
104
|
+
it 'should be able to get a client through the Service#client helper method' do
|
105
|
+
Test::ResourceService.client(:port => 9191).should eq(Protobuf::Rpc::Client.new(:service => Test::ResourceService, :port => 9191))
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be able to override a service location's host and port" do
|
109
|
+
Test::ResourceService.located_at 'somewheregreat.com:12345'
|
110
|
+
clean_client = Test::ResourceService.client
|
111
|
+
clean_client.options[:host].should eq('somewheregreat.com')
|
112
|
+
clean_client.options[:port].should eq(12345)
|
113
|
+
|
114
|
+
updated_client = Test::ResourceService.client(:host => 'amazing.com', :port => 54321)
|
115
|
+
updated_client.options[:host].should eq('amazing.com')
|
116
|
+
updated_client.options[:port].should eq(54321)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should be able to define which service to create itself for' do
|
120
|
+
client = Protobuf::Rpc::Client.new :service => Test::ResourceService
|
121
|
+
client.options[:service].should eq(Test::ResourceService)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should have a hard default for host and port on a service that has not been configured' do
|
125
|
+
client = Test::ResourceService.client
|
126
|
+
client.options[:host].should eq(Protobuf::Rpc::Service::DEFAULT_HOST)
|
127
|
+
client.options[:port].should eq(Protobuf::Rpc::Service::DEFAULT_PORT)
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when calling methods on a service client' do
|
133
|
+
|
134
|
+
# NOTE: we are assuming the service methods are accurately
|
135
|
+
# defined inside spec/proto/test_service.rb,
|
136
|
+
# namely the :find method
|
137
|
+
|
138
|
+
it 'should respond to defined service methods' do
|
139
|
+
client = Test::ResourceService.client
|
140
|
+
client.should_receive(:send_request).and_return(nil)
|
141
|
+
expect { client.find(nil) }.to_not raise_error
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when receiving request objects' do
|
146
|
+
|
147
|
+
it 'should be able to create the correct request object if passed a hash' do
|
148
|
+
client = Test::ResourceService.client
|
149
|
+
client.should_receive(:send_request)
|
150
|
+
client.find({:name => 'Test Name', :active => false})
|
151
|
+
client.options[:request].should be_a(Test::ResourceFindRequest)
|
152
|
+
client.options[:request].name.should eq('Test Name')
|
153
|
+
client.options[:request].active.should eq(false)
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'protobuf/socket'
|
3
|
+
require 'protobuf/evented'
|
4
|
+
require 'protobuf/zmq'
|
5
|
+
|
6
|
+
describe ::Protobuf::Rpc::Connector do
|
7
|
+
|
8
|
+
describe '.connector_for_client(true)' do
|
9
|
+
subject { described_class.connector_for_client }
|
10
|
+
|
11
|
+
context 'Protobuf.connector_type is socket' do
|
12
|
+
before { ::Protobuf.connector_type = :socket }
|
13
|
+
it { should eq ::Protobuf::Rpc::Connectors::Socket }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'Protobuf.connector_type is not a known value' do
|
17
|
+
before { ::Protobuf.connector_type = :socket }
|
18
|
+
it { should eq ::Protobuf::Rpc::Connectors::Socket }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'Protobuf.connector_type is evented' do
|
22
|
+
before { ::Protobuf.connector_type = :evented }
|
23
|
+
it { should eq ::Protobuf::Rpc::Connectors::EventMachine }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'Protobuf.connector_type is zmq' do
|
27
|
+
before { ::Protobuf.connector_type = :zmq }
|
28
|
+
it { should eq ::Protobuf::Rpc::Connectors::Zmq }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Protobuf::Rpc::Connectors::Base do
|
4
|
+
|
5
|
+
let(:options) do
|
6
|
+
{ :timeout => 60 }
|
7
|
+
end
|
8
|
+
|
9
|
+
subject { Protobuf::Rpc::Connectors::Base.new(options) }
|
10
|
+
|
11
|
+
describe "#send_request" do
|
12
|
+
it "raising an error when 'send_request' is not overridden" do
|
13
|
+
expect{ subject.send_request }.to raise_error(RuntimeError, /inherit a Connector/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "does not raise error when 'send_request' is overridden" do
|
17
|
+
new_sub = Class.new(subject.class){ def send_request; end }.new(options)
|
18
|
+
expect{ new_sub.send_request }.to_not raise_error
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.new' do
|
23
|
+
it 'assigns passed options and initializes success/failure callbacks' do
|
24
|
+
subject.options.should eq(Protobuf::Rpc::Connectors::DEFAULT_OPTIONS.merge(options))
|
25
|
+
subject.success_cb.should be_nil
|
26
|
+
subject.failure_cb.should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#success_cb' do
|
31
|
+
it 'allows setting the success callback and calling it' do
|
32
|
+
subject.success_cb.should be_nil
|
33
|
+
cb = proc {|res| raise res }
|
34
|
+
subject.success_cb = cb
|
35
|
+
subject.success_cb.should eq(cb)
|
36
|
+
expect { subject.success_cb.call('an error from cb') }.to raise_error 'an error from cb'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#failure_cb' do
|
41
|
+
it 'allows setting the failure callback and calling it' do
|
42
|
+
subject.failure_cb.should be_nil
|
43
|
+
cb = proc {|res| raise res }
|
44
|
+
subject.failure_cb = cb
|
45
|
+
subject.failure_cb.should eq(cb)
|
46
|
+
expect { subject.failure_cb.call('an error from cb') }.to raise_error 'an error from cb'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'protobuf/rpc/service'
|
3
|
+
|
4
|
+
describe Protobuf::Rpc::Connectors::Common do
|
5
|
+
let(:common_class) do
|
6
|
+
Class.new(Protobuf::Rpc::Connectors::Base) do
|
7
|
+
include Protobuf::Rpc::Connectors::Common
|
8
|
+
attr_accessor :options
|
9
|
+
attr_accessor :stats
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
subject{ @subject ||= common_class.new({}) }
|
14
|
+
|
15
|
+
context "API" do
|
16
|
+
specify{ subject.respond_to?(:any_callbacks?).should be_true }
|
17
|
+
specify{ subject.respond_to?(:data_callback).should be_true }
|
18
|
+
specify{ subject.respond_to?(:error).should be_true }
|
19
|
+
specify{ subject.respond_to?(:fail).should be_true }
|
20
|
+
specify{ subject.respond_to?(:complete).should be_true }
|
21
|
+
specify{ subject.respond_to?(:parse_response).should be_true }
|
22
|
+
specify{ subject.respond_to?(:verify_options).should be_true }
|
23
|
+
specify{ subject.respond_to?(:verify_callbacks).should be_true }
|
24
|
+
end
|
25
|
+
|
26
|
+
context "#any_callbacks?" do
|
27
|
+
|
28
|
+
[:@complete_cb, :@success_cb, :@failure_cb].each do |cb|
|
29
|
+
it "returns true if #{cb} is provided" do
|
30
|
+
subject.instance_variable_set(cb, "something")
|
31
|
+
subject.any_callbacks?.should be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns false when all callbacks are not provided" do
|
36
|
+
subject.instance_variable_set(:@complete_cb, nil)
|
37
|
+
subject.instance_variable_set(:@success_cb, nil)
|
38
|
+
subject.instance_variable_set(:@failure_cb, nil)
|
39
|
+
|
40
|
+
subject.any_callbacks?.should be_false
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "#data_callback" do
|
46
|
+
it "changes state to use the data callback" do
|
47
|
+
subject.data_callback("data")
|
48
|
+
subject.instance_variable_get(:@used_data_callback).should be_true
|
49
|
+
end
|
50
|
+
|
51
|
+
it "sets the data var when using the data_callback" do
|
52
|
+
subject.data_callback("data")
|
53
|
+
subject.instance_variable_get(:@data).should eq("data")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "#verify_callbacks" do
|
58
|
+
|
59
|
+
it "sets @failure_cb to #data_callback when no callbacks are defined" do
|
60
|
+
subject.verify_callbacks
|
61
|
+
subject.instance_variable_get(:@failure_cb).should eq(subject.method(:data_callback))
|
62
|
+
end
|
63
|
+
|
64
|
+
it "sets @success_cb to #data_callback when no callbacks are defined" do
|
65
|
+
subject.verify_callbacks
|
66
|
+
subject.instance_variable_get(:@success_cb).should eq(subject.method(:data_callback))
|
67
|
+
end
|
68
|
+
|
69
|
+
it "doesn't set @failure_cb when already defined" do
|
70
|
+
set_cb = lambda{ true }
|
71
|
+
subject.instance_variable_set(:@failure_cb, set_cb)
|
72
|
+
subject.verify_callbacks
|
73
|
+
subject.instance_variable_get(:@failure_cb).should eq(set_cb)
|
74
|
+
subject.instance_variable_get(:@failure_cb).should_not eq(subject.method(:data_callback))
|
75
|
+
end
|
76
|
+
|
77
|
+
it "doesn't set @success_cb when already defined" do
|
78
|
+
set_cb = lambda{ true }
|
79
|
+
subject.instance_variable_set(:@success_cb, set_cb)
|
80
|
+
subject.verify_callbacks
|
81
|
+
subject.instance_variable_get(:@success_cb).should eq(set_cb)
|
82
|
+
subject.instance_variable_get(:@success_cb).should_not eq(subject.method(:data_callback))
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
shared_examples "a ConnectorDisposition" do |meth, cb, *args|
|
88
|
+
|
89
|
+
it "calls #complete before exit" do
|
90
|
+
stats = double("Object")
|
91
|
+
stats.stub(:stop) { true }
|
92
|
+
subject.stats = stats
|
93
|
+
|
94
|
+
subject.should_receive(:complete)
|
95
|
+
subject.method(meth).call(*args)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "calls the #{cb} callback when provided" do
|
99
|
+
stats = double("Object")
|
100
|
+
stats.stub(:stop) { true }
|
101
|
+
subject.stats = stats
|
102
|
+
_cb = double("Object")
|
103
|
+
|
104
|
+
subject.instance_variable_set("@#{cb}", _cb)
|
105
|
+
_cb.should_receive(:call).and_return(true)
|
106
|
+
subject.method(meth).call(*args)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "calls the complete callback when provided" do
|
110
|
+
stats = double("Object")
|
111
|
+
stats.stub(:stop) { true }
|
112
|
+
subject.stats = stats
|
113
|
+
comp_cb = double("Object")
|
114
|
+
|
115
|
+
subject.instance_variable_set(:@complete_cb, comp_cb)
|
116
|
+
comp_cb.should_receive(:call).and_return(true)
|
117
|
+
subject.method(meth).call(*args)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
it_behaves_like("a ConnectorDisposition", :fail, "failure_cb", "code", "message")
|
123
|
+
it_behaves_like("a ConnectorDisposition", :fail, "complete_cb", "code", "message")
|
124
|
+
it_behaves_like("a ConnectorDisposition", :succeed, "complete_cb", "response")
|
125
|
+
it_behaves_like("a ConnectorDisposition", :succeed, "success_cb", "response")
|
126
|
+
it_behaves_like("a ConnectorDisposition", :complete, "complete_cb")
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'protobuf/socket'
|
3
|
+
|
4
|
+
shared_examples "a Protobuf Connector" do
|
5
|
+
subject{ described_class.new({}) }
|
6
|
+
|
7
|
+
context "API" do
|
8
|
+
# Check the API
|
9
|
+
specify{ subject.respond_to?(:send_request, true).should be_true }
|
10
|
+
specify{ subject.respond_to?(:post_init, true).should be_true }
|
11
|
+
specify{ subject.respond_to?(:close_connection, true).should be_true }
|
12
|
+
specify{ subject.respond_to?(:error?, true).should be_true }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Protobuf::Rpc::Connectors::Socket do
|
17
|
+
subject{ described_class.new({}) }
|
18
|
+
|
19
|
+
it_behaves_like "a Protobuf Connector"
|
20
|
+
|
21
|
+
specify{ described_class.include?(Protobuf::Rpc::Connectors::Common).should be_true }
|
22
|
+
|
23
|
+
context "#read_response" do
|
24
|
+
let(:data){ "New data" }
|
25
|
+
|
26
|
+
it "fills the buffer with data from the socket" do
|
27
|
+
socket = StringIO.new("#{data.bytesize}-#{data}")
|
28
|
+
subject.instance_variable_set(:@socket, socket)
|
29
|
+
subject.instance_variable_set(:@stats, OpenStruct.new)
|
30
|
+
subject.should_receive(:parse_response).and_return(true)
|
31
|
+
|
32
|
+
subject.__send__(:read_response)
|
33
|
+
subject.instance_variable_get(:@response_data).should eq(data)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'protobuf/zmq'
|
3
|
+
|
4
|
+
describe ::Protobuf::Rpc::Connectors::Zmq do
|
5
|
+
let(:socket_mock) do
|
6
|
+
sm = mock(::ZMQ::Socket)
|
7
|
+
sm.stub(:connect).and_return(0)
|
8
|
+
sm
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:zmq_context_mock) do
|
12
|
+
zc = mock(::ZMQ::Context)
|
13
|
+
zc.stub(:socket).and_return(socket_mock)
|
14
|
+
zc
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
::ZMQ::Context.stub(:new).and_return(zmq_context_mock)
|
19
|
+
end
|
20
|
+
|
21
|
+
pending
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'spec/support/test/resource_service'
|
3
|
+
require 'protobuf/rpc/servers/evented_runner'
|
4
|
+
require 'protobuf/evented'
|
5
|
+
|
6
|
+
describe Protobuf::Rpc::Evented::Server do
|
7
|
+
|
8
|
+
it "provides a Runner class" do
|
9
|
+
runner_class = described_class.to_s.gsub(/Evented::Server/, "EventedRunner")
|
10
|
+
expect { runner_class.constantize }.to_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
it "Runner provides a stop method" do
|
14
|
+
runner_class = described_class.to_s.gsub(/Evented::Server/, "EventedRunner").constantize
|
15
|
+
runner_class.respond_to?(:stop).should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|