protobuf 2.2.5-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,451 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class FilterTest
|
|
4
|
+
include Protobuf::Rpc::ServiceFilters
|
|
5
|
+
|
|
6
|
+
attr_accessor :called
|
|
7
|
+
|
|
8
|
+
# Initialize the hash keys as instance vars
|
|
9
|
+
def initialize(ivar_hash)
|
|
10
|
+
@called = []
|
|
11
|
+
ivar_hash.each_pair do |key, value|
|
|
12
|
+
self.class.class_eval do
|
|
13
|
+
attr_accessor key
|
|
14
|
+
end
|
|
15
|
+
__send__("#{key}=", value)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def endpoint
|
|
20
|
+
@called << :endpoint
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.clear_filters!
|
|
24
|
+
@defined_filters = nil
|
|
25
|
+
@filters = nil
|
|
26
|
+
@rescue_filters = nil
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe Protobuf::Rpc::ServiceFilters do
|
|
31
|
+
let(:params) { {} }
|
|
32
|
+
subject { FilterTest.new(params) }
|
|
33
|
+
after(:each) { FilterTest.clear_filters! }
|
|
34
|
+
|
|
35
|
+
describe '#before_filter' do
|
|
36
|
+
let(:params) { { :before_filter_calls => 0 } }
|
|
37
|
+
|
|
38
|
+
before(:all) do
|
|
39
|
+
class FilterTest
|
|
40
|
+
private
|
|
41
|
+
def verify_before
|
|
42
|
+
@called << :verify_before
|
|
43
|
+
@before_filter_calls += 1
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def foo
|
|
47
|
+
@called << :foo
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
before do
|
|
53
|
+
FilterTest.before_filter(:verify_before)
|
|
54
|
+
FilterTest.before_filter(:verify_before)
|
|
55
|
+
FilterTest.before_filter(:foo)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'calls filters in the order they were defined' do
|
|
59
|
+
subject.__send__(:run_filters, :endpoint)
|
|
60
|
+
subject.called.should eq [ :verify_before, :foo, :endpoint ]
|
|
61
|
+
subject.before_filter_calls.should eq 1
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context 'when filter is configured with "only"' do
|
|
65
|
+
before(:all) do
|
|
66
|
+
class FilterTest
|
|
67
|
+
private
|
|
68
|
+
def endpoint_with_verify
|
|
69
|
+
@called << :endpoint_with_verify
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
before do
|
|
75
|
+
FilterTest.clear_filters!
|
|
76
|
+
FilterTest.before_filter(:verify_before, :only => :endpoint_with_verify)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context 'when invoking a method defined in "only" option' do
|
|
80
|
+
it 'invokes the filter' do
|
|
81
|
+
subject.__send__(:run_filters, :endpoint_with_verify)
|
|
82
|
+
subject.called.should eq [ :verify_before, :endpoint_with_verify ]
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context 'when invoking a method not defined by "only" option' do
|
|
87
|
+
it 'does not invoke the filter' do
|
|
88
|
+
subject.__send__(:run_filters, :endpoint)
|
|
89
|
+
subject.called.should eq [ :endpoint ]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
context 'when filter is configured with "except"' do
|
|
95
|
+
before(:all) do
|
|
96
|
+
class FilterTest
|
|
97
|
+
private
|
|
98
|
+
def endpoint_without_verify
|
|
99
|
+
@called << :endpoint_without_verify
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
before do
|
|
105
|
+
FilterTest.clear_filters!
|
|
106
|
+
FilterTest.before_filter(:verify_before, :except => :endpoint_without_verify)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context 'when invoking a method not defined in "except" option' do
|
|
110
|
+
it 'invokes the filter' do
|
|
111
|
+
subject.__send__(:run_filters, :endpoint)
|
|
112
|
+
subject.called.should eq [ :verify_before, :endpoint ]
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context 'when invoking a method defined by "except" option' do
|
|
117
|
+
it 'does not invoke the filter' do
|
|
118
|
+
subject.__send__(:run_filters, :endpoint_without_verify)
|
|
119
|
+
subject.called.should eq [ :endpoint_without_verify ]
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
context 'when filter is configured with "if"' do
|
|
125
|
+
before(:all) do
|
|
126
|
+
class FilterTest
|
|
127
|
+
private
|
|
128
|
+
def check_true; return true; end
|
|
129
|
+
def check_false; return false; end
|
|
130
|
+
def verify_before; @called << :verify_before; end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context 'when "if" option is a method that returns true' do
|
|
135
|
+
before do
|
|
136
|
+
FilterTest.clear_filters!
|
|
137
|
+
FilterTest.before_filter(:verify_before, :if => :check_true)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'invokes the filter' do
|
|
141
|
+
subject.__send__(:run_filters, :endpoint)
|
|
142
|
+
subject.called.should eq [ :verify_before, :endpoint ]
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
context 'when "if" option is a callable that returns true' do
|
|
147
|
+
before do
|
|
148
|
+
FilterTest.clear_filters!
|
|
149
|
+
FilterTest.before_filter(:verify_before, :if => lambda { |service| true })
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it 'invokes the filter' do
|
|
153
|
+
subject.__send__(:run_filters, :endpoint)
|
|
154
|
+
subject.called.should eq [ :verify_before, :endpoint ]
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
context 'when "if" option is a method that returns false' do
|
|
159
|
+
before do
|
|
160
|
+
FilterTest.clear_filters!
|
|
161
|
+
FilterTest.before_filter(:verify_before, :if => :check_false)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'skips the filter' do
|
|
165
|
+
subject.__send__(:run_filters, :endpoint)
|
|
166
|
+
subject.called.should eq [ :endpoint ]
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
context 'when "if" option is a callable that returns false' do
|
|
171
|
+
before do
|
|
172
|
+
FilterTest.clear_filters!
|
|
173
|
+
FilterTest.before_filter(:verify_before, :if => lambda { |service| false })
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it 'skips the filter' do
|
|
177
|
+
subject.__send__(:run_filters, :endpoint)
|
|
178
|
+
subject.called.should eq [ :endpoint ]
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context 'when filter is configured with "unless"' do
|
|
184
|
+
before(:all) do
|
|
185
|
+
class FilterTest
|
|
186
|
+
private
|
|
187
|
+
def check_true; return true; end
|
|
188
|
+
def check_false; return false; end
|
|
189
|
+
def verify_before; @called << :verify_before; end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
context 'when "unless" option is a method that returns false' do
|
|
194
|
+
before do
|
|
195
|
+
FilterTest.clear_filters!
|
|
196
|
+
FilterTest.before_filter(:verify_before, :unless => :check_false)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it 'invokes the filter' do
|
|
200
|
+
subject.__send__(:run_filters, :endpoint)
|
|
201
|
+
subject.called.should eq [ :verify_before, :endpoint ]
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context 'when "unless" option is a callable that returns true' do
|
|
206
|
+
before do
|
|
207
|
+
FilterTest.clear_filters!
|
|
208
|
+
FilterTest.before_filter(:verify_before, :unless => lambda { |service| false })
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
it 'invokes the filter' do
|
|
212
|
+
subject.__send__(:run_filters, :endpoint)
|
|
213
|
+
subject.called.should eq [ :verify_before, :endpoint ]
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
context 'when "unless" option is a method that returns false' do
|
|
218
|
+
before do
|
|
219
|
+
FilterTest.clear_filters!
|
|
220
|
+
FilterTest.before_filter(:verify_before, :unless => :check_true)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it 'skips the filter' do
|
|
224
|
+
subject.__send__(:run_filters, :endpoint)
|
|
225
|
+
subject.called.should eq [ :endpoint ]
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
context 'when "unless" option is a callable that returns false' do
|
|
230
|
+
before do
|
|
231
|
+
FilterTest.clear_filters!
|
|
232
|
+
FilterTest.before_filter(:verify_before, :unless => lambda { |service| true })
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
it 'skips the filter' do
|
|
236
|
+
subject.__send__(:run_filters, :endpoint)
|
|
237
|
+
subject.called.should eq [ :endpoint ]
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
context 'when filter returns false' do
|
|
243
|
+
before(:all) do
|
|
244
|
+
class FilterTest
|
|
245
|
+
private
|
|
246
|
+
def short_circuit_filter
|
|
247
|
+
@called << :short_circuit_filter
|
|
248
|
+
return false
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
before do
|
|
254
|
+
FilterTest.clear_filters!
|
|
255
|
+
FilterTest.before_filter(:short_circuit_filter)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it 'does not invoke the rpc method' do
|
|
259
|
+
subject.should_not_receive(:endpoint)
|
|
260
|
+
subject.__send__(:run_filters, :endpoint)
|
|
261
|
+
subject.called.should eq [ :short_circuit_filter ]
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
describe '#after_filter' do
|
|
267
|
+
let(:params) { { :after_filter_calls => 0 } }
|
|
268
|
+
|
|
269
|
+
before(:all) do
|
|
270
|
+
class FilterTest
|
|
271
|
+
private
|
|
272
|
+
def verify_after
|
|
273
|
+
@called << :verify_after
|
|
274
|
+
@after_filter_calls += 1
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def foo
|
|
278
|
+
@called << :foo
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
before do
|
|
284
|
+
FilterTest.after_filter(:verify_after)
|
|
285
|
+
FilterTest.after_filter(:verify_after)
|
|
286
|
+
FilterTest.after_filter(:foo)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
it 'calls filters in the order they were defined' do
|
|
290
|
+
subject.__send__(:run_filters, :endpoint)
|
|
291
|
+
subject.called.should eq [ :endpoint, :verify_after, :foo ]
|
|
292
|
+
subject.after_filter_calls.should eq 1
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
describe '#around_filter' do
|
|
297
|
+
let(:params) { {} }
|
|
298
|
+
|
|
299
|
+
before(:all) do
|
|
300
|
+
class FilterTest
|
|
301
|
+
private
|
|
302
|
+
def outer_around
|
|
303
|
+
@called << :outer_around_top
|
|
304
|
+
yield
|
|
305
|
+
@called << :outer_around_bottom
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def inner_around
|
|
309
|
+
@called << :inner_around_top
|
|
310
|
+
yield
|
|
311
|
+
@called << :inner_around_bottom
|
|
312
|
+
end
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
before do
|
|
317
|
+
FilterTest.around_filter(:outer_around)
|
|
318
|
+
FilterTest.around_filter(:inner_around)
|
|
319
|
+
FilterTest.around_filter(:outer_around)
|
|
320
|
+
FilterTest.around_filter(:inner_around)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
it 'calls filters in the order they were defined' do
|
|
324
|
+
subject.__send__(:run_filters, :endpoint)
|
|
325
|
+
subject.called.should eq([ :outer_around_top,
|
|
326
|
+
:inner_around_top,
|
|
327
|
+
:endpoint,
|
|
328
|
+
:inner_around_bottom,
|
|
329
|
+
:outer_around_bottom ])
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
context 'when around_filter does not yield' do
|
|
333
|
+
before do
|
|
334
|
+
class FilterTest
|
|
335
|
+
private
|
|
336
|
+
def inner_around
|
|
337
|
+
@called << :inner_around
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
before do
|
|
343
|
+
FilterTest.around_filter(:outer_around)
|
|
344
|
+
FilterTest.around_filter(:inner_around)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it 'cancels calling the rest of the filters and the endpoint' do
|
|
348
|
+
subject.should_not_receive(:endpoint)
|
|
349
|
+
subject.__send__(:run_filters, :endpoint)
|
|
350
|
+
subject.called.should eq([ :outer_around_top,
|
|
351
|
+
:inner_around,
|
|
352
|
+
:outer_around_bottom ])
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
describe '#rescue_from' do
|
|
359
|
+
before do
|
|
360
|
+
class CustomError1 < StandardError; end
|
|
361
|
+
class CustomError2 < StandardError; end
|
|
362
|
+
class CustomError3 < StandardError; end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
before do
|
|
366
|
+
class FilterTest
|
|
367
|
+
private
|
|
368
|
+
|
|
369
|
+
def filter_with_error1
|
|
370
|
+
@called << :filter_with_error1
|
|
371
|
+
raise CustomError1, 'Filter 1 failed'
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def filter_with_error2
|
|
375
|
+
@called << :filter_with_error2
|
|
376
|
+
raise CustomError1, 'Filter 2 failed'
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def filter_with_error3
|
|
380
|
+
@called << :filter_with_error3
|
|
381
|
+
raise CustomError3, 'Filter 3 failed'
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def custom_error_occurred(ex)
|
|
385
|
+
@ex_class = ex.class
|
|
386
|
+
@called << :custom_error_occurred
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
let(:params) { { :ex_class => nil } }
|
|
392
|
+
|
|
393
|
+
context 'when defining multiple errors with a given callback' do
|
|
394
|
+
before do
|
|
395
|
+
FilterTest.rescue_from(CustomError1, CustomError2, CustomError3, :with => :custom_error_occurred)
|
|
396
|
+
end
|
|
397
|
+
before { FilterTest.before_filter(:filter_with_error3) }
|
|
398
|
+
|
|
399
|
+
it 'short-circuits the call stack' do
|
|
400
|
+
expect {
|
|
401
|
+
subject.should_not_receive(:endpoint)
|
|
402
|
+
subject.__send__(:run_filters, :endpoint)
|
|
403
|
+
subject.called.should eq([ :filter_with_error3, :custom_error_occurred ])
|
|
404
|
+
subject.ex_class.should eq CustomError3
|
|
405
|
+
}.to_not raise_error(CustomError3)
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
context 'when defined with options' do
|
|
410
|
+
context 'when :with option is not given' do
|
|
411
|
+
specify do
|
|
412
|
+
expect { FilterTest.rescue_from(CustomError1) }.to raise_error(ArgumentError, /with/)
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
context 'when error occurs inside filter' do
|
|
417
|
+
before { FilterTest.rescue_from(CustomError1, :with => :custom_error_occurred) }
|
|
418
|
+
before { FilterTest.before_filter(:filter_with_error1) }
|
|
419
|
+
|
|
420
|
+
it 'short-circuits the call stack' do
|
|
421
|
+
expect {
|
|
422
|
+
subject.should_not_receive(:endpoint)
|
|
423
|
+
subject.__send__(:run_filters, :endpoint)
|
|
424
|
+
subject.called.should eq([ :filter_with_error1, :custom_error_occurred ])
|
|
425
|
+
subject.ex_class.should eq CustomError1
|
|
426
|
+
}.to_not raise_error(CustomError1)
|
|
427
|
+
end
|
|
428
|
+
end
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
context 'when defined with block' do
|
|
432
|
+
before do
|
|
433
|
+
FilterTest.rescue_from(CustomError1) do |service, ex|
|
|
434
|
+
service.ex_class = ex.class
|
|
435
|
+
service.called << :block_rescue_handler
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
before { FilterTest.before_filter(:filter_with_error1) }
|
|
439
|
+
|
|
440
|
+
it 'short-circuits the call stack' do
|
|
441
|
+
expect {
|
|
442
|
+
subject.should_not_receive(:endpoint)
|
|
443
|
+
subject.__send__(:run_filters, :endpoint)
|
|
444
|
+
subject.called.should eq([ :filter_with_error1, :block_rescue_handler ])
|
|
445
|
+
subject.ex_class.should eq CustomError1
|
|
446
|
+
}.to_not raise_error(CustomError1)
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'spec/support/test/resource_service'
|
|
3
|
+
|
|
4
|
+
describe Protobuf::Rpc::Service do
|
|
5
|
+
|
|
6
|
+
context 'class methods' do
|
|
7
|
+
subject { Test::ResourceService }
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
reset_service_location Test::ResourceService
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe '.host' do
|
|
14
|
+
its(:host) { should eq described_class::DEFAULT_HOST }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '.host=' do
|
|
18
|
+
before { subject.host = 'mynewhost.com' }
|
|
19
|
+
its(:host) { should eq 'mynewhost.com' }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '.port' do
|
|
23
|
+
its(:port) { should eq described_class::DEFAULT_PORT }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '.port=' do
|
|
27
|
+
before { subject.port = 12345 }
|
|
28
|
+
its(:port) { should eq 12345 }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '.configure' do
|
|
32
|
+
context 'when providing a host' do
|
|
33
|
+
before { subject.configure(:host => 'mynewhost.com') }
|
|
34
|
+
its(:host) { should eq 'mynewhost.com' }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'when providing a port' do
|
|
38
|
+
before { subject.configure(:port => 12345) }
|
|
39
|
+
its(:port) { should eq 12345 }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '.located_at' do
|
|
44
|
+
context 'when given location is empty' do
|
|
45
|
+
before { subject.located_at(nil) }
|
|
46
|
+
its(:host) { should eq described_class::DEFAULT_HOST }
|
|
47
|
+
its(:port) { should eq described_class::DEFAULT_PORT }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context 'when given location is invalid' do
|
|
51
|
+
before { subject.located_at('i like pie') }
|
|
52
|
+
its(:host) { should eq described_class::DEFAULT_HOST }
|
|
53
|
+
its(:port) { should eq described_class::DEFAULT_PORT }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'when given location contains a host and port' do
|
|
57
|
+
before { subject.located_at('mynewdomain.com:12345') }
|
|
58
|
+
its(:host) { should eq 'mynewdomain.com' }
|
|
59
|
+
its(:port) { should eq 12345 }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe '.client' do
|
|
64
|
+
it 'initializes a client object for this service' do
|
|
65
|
+
client = double('client')
|
|
66
|
+
::Protobuf::Rpc::Client.should_receive(:new)
|
|
67
|
+
.with(hash_including({ :service => subject,
|
|
68
|
+
:host => subject.host,
|
|
69
|
+
:port => subject.port }))
|
|
70
|
+
.and_return(client)
|
|
71
|
+
subject.client.should eq client
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '.rpc' do
|
|
76
|
+
before { Test::ResourceService.rpc(:update, Test::ResourceFindRequest, Test::Resource) }
|
|
77
|
+
subject { Test::ResourceService.rpcs[:update] }
|
|
78
|
+
its(:method) { should eq :update }
|
|
79
|
+
its(:request_type) { should eq Test::ResourceFindRequest }
|
|
80
|
+
its(:response_type) { should eq Test::Resource }
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '.rpc_method?' do
|
|
84
|
+
before { Test::ResourceService.rpc(:delete, Test::Resource, Test::Resource) }
|
|
85
|
+
|
|
86
|
+
context 'when given name is a pre-defined rpc method' do
|
|
87
|
+
it 'returns true' do
|
|
88
|
+
subject.rpc_method?(:delete).should be_true
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'when given name is not a pre-defined rpc method' do
|
|
93
|
+
it 'returns false' do
|
|
94
|
+
subject.rpc_method?(:zoobaboo).should be_false
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context 'instance methods' do
|
|
101
|
+
context 'when invoking a service call' do
|
|
102
|
+
before(:all) do
|
|
103
|
+
class ::NewTestService < Protobuf::Rpc::Service
|
|
104
|
+
rpc :find_with_implied_response, Test::ResourceFindRequest, Test::Resource
|
|
105
|
+
def find_with_implied_response
|
|
106
|
+
response.name = 'Implicit response'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
rpc :find_with_respond_with, Test::ResourceFindRequest, Test::Resource
|
|
110
|
+
def find_with_respond_with
|
|
111
|
+
custom = Test::Resource.new(:name => 'Custom response')
|
|
112
|
+
respond_with(custom)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
rpc :find_with_rpc_failed, Test::ResourceFindRequest, Test::Resource
|
|
116
|
+
def find_with_rpc_failed
|
|
117
|
+
rpc_failed('This is a failed endpoint')
|
|
118
|
+
response.name = 'Name will still be set'
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
let(:request) do
|
|
125
|
+
Test::ResourceFindRequest.new(:name => 'resource')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
let(:response) do
|
|
129
|
+
Test::Resource.new
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
context 'when calling the rpc method' do
|
|
133
|
+
context 'when response is implied' do
|
|
134
|
+
subject { NewTestService.new(:find_with_implied_response, request.serialize_to_string) }
|
|
135
|
+
|
|
136
|
+
before { subject.find_with_implied_response }
|
|
137
|
+
its(:response) { should be_a(Test::Resource) }
|
|
138
|
+
specify { subject.response.name.should eq 'Implicit response' }
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
context 'when using respond_with paradigm' do
|
|
142
|
+
subject { NewTestService.new(:find_with_respond_with, request.serialize_to_string) }
|
|
143
|
+
|
|
144
|
+
before { subject.find_with_respond_with }
|
|
145
|
+
its(:response) { should be_a(Test::Resource) }
|
|
146
|
+
specify { subject.response.name.should eq 'Custom response' }
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
context 'when calling rpc_failed in the method' do
|
|
151
|
+
subject { NewTestService.new(:find_with_rpc_failed, request.serialize_to_string) }
|
|
152
|
+
|
|
153
|
+
it 'invokes the rpc_failed callback with the error' do
|
|
154
|
+
error = nil
|
|
155
|
+
subject.on_rpc_failed(lambda { |err| error = err })
|
|
156
|
+
subject.find_with_rpc_failed
|
|
157
|
+
error.should eq 'This is a failed endpoint'
|
|
158
|
+
subject.response.name.should eq 'Name will still be set'
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'protobuf'
|
|
3
|
+
|
|
4
|
+
describe ::Protobuf do
|
|
5
|
+
|
|
6
|
+
describe '.connector_type' do
|
|
7
|
+
before { described_class.instance_variable_set(:@_connector_type, nil) }
|
|
8
|
+
|
|
9
|
+
it 'defaults to socket' do
|
|
10
|
+
described_class.connector_type.should eq :socket
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'accepts socket, evented, or zmq' do
|
|
14
|
+
[:socket, :evented, :zmq].each do |type|
|
|
15
|
+
described_class.connector_type = type
|
|
16
|
+
described_class.connector_type.should eq type
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'does not accept other types' do
|
|
21
|
+
[:hello, :world].each do |type|
|
|
22
|
+
expect {
|
|
23
|
+
described_class.connector_type = type
|
|
24
|
+
}.to raise_error(ArgumentError)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '.gc_pause_server_request?' do
|
|
30
|
+
before { described_class.instance_variable_set(:@_gc_pause_server_request, nil) }
|
|
31
|
+
|
|
32
|
+
it 'defaults to a false value' do
|
|
33
|
+
described_class.gc_pause_server_request?.should be_false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'is settable' do
|
|
37
|
+
described_class.gc_pause_server_request = true
|
|
38
|
+
described_class.gc_pause_server_request?.should be_true
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '.print_deprecation_warnings?' do
|
|
43
|
+
before { described_class.instance_variable_set(:@_print_deprecation_warnings, nil) }
|
|
44
|
+
|
|
45
|
+
it 'defaults to a true value' do
|
|
46
|
+
described_class.print_deprecation_warnings?.should be_true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'is settable' do
|
|
50
|
+
described_class.print_deprecation_warnings = false
|
|
51
|
+
described_class.print_deprecation_warnings?.should be_false
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context 'when ENV["PB_IGNORE_DEPRECATIONS"] present' do
|
|
55
|
+
it 'defaults to a false value' do
|
|
56
|
+
ENV['PB_IGNORE_DEPRECATIONS'] = '1'
|
|
57
|
+
described_class.print_deprecation_warnings?.should be_false
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|