protobuf 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/protobuf/field/base_field.rb +5 -1
- data/lib/protobuf/field/float_field.rb +4 -0
- data/lib/protobuf/rpc/connectors/zmq.rb +31 -20
- data/lib/protobuf/rpc/servers/zmq/broker.rb +1 -1
- data/lib/protobuf/version.rb +1 -1
- data/protobuf.gemspec +1 -1
- data/spec/encoding/all_types_spec.rb +1 -1
- data/spec/encoding/extreme_values_spec.rb +0 -0
- data/spec/functional/socket_server_spec.rb +5 -4
- data/spec/functional/zmq_server_spec.rb +7 -7
- data/spec/lib/protobuf/cli_spec.rb +39 -39
- data/spec/lib/protobuf/code_generator_spec.rb +4 -4
- data/spec/lib/protobuf/enum_spec.rb +23 -23
- data/spec/lib/protobuf/field/float_field_spec.rb +55 -0
- data/spec/lib/protobuf/field/string_field_spec.rb +4 -4
- data/spec/lib/protobuf/generators/base_spec.rb +4 -7
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +3 -3
- data/spec/lib/protobuf/generators/extension_generator_spec.rb +4 -4
- data/spec/lib/protobuf/generators/field_generator_spec.rb +11 -11
- data/spec/lib/protobuf/generators/file_generator_spec.rb +3 -3
- data/spec/lib/protobuf/generators/service_generator_spec.rb +2 -2
- data/spec/lib/protobuf/lifecycle_spec.rb +16 -16
- data/spec/lib/protobuf/logger_spec.rb +27 -27
- data/spec/lib/protobuf/message_spec.rb +42 -42
- data/spec/lib/protobuf/optionable_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/client_spec.rb +13 -13
- data/spec/lib/protobuf/rpc/connector_spec.rb +4 -4
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +7 -7
- data/spec/lib/protobuf/rpc/connectors/common_spec.rb +31 -33
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +8 -8
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +24 -35
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +8 -8
- data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +2 -2
- data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +10 -10
- data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +6 -6
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +2 -2
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +5 -5
- data/spec/lib/protobuf/rpc/service_directory_spec.rb +26 -27
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +4 -4
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +39 -39
- data/spec/lib/protobuf/rpc/service_spec.rb +27 -27
- data/spec/lib/protobuf/rpc/stat_spec.rb +4 -4
- data/spec/lib/protobuf_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/packed_field.rb +1 -1
- metadata +6 -76
@@ -20,22 +20,22 @@ describe Protobuf::Logger do
|
|
20
20
|
|
21
21
|
it 'doesn\'t create a logger if the file was not set' do
|
22
22
|
subject.file = nil
|
23
|
-
subject.instance.
|
23
|
+
expect(subject.instance).to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'doesn\'t create a logger if the level was not set' do
|
27
27
|
subject.level = nil
|
28
|
-
subject.instance.
|
28
|
+
expect(subject.instance).to be_nil
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'gets a new instance of the logger when file and level are set' do
|
32
|
-
subject.file.
|
33
|
-
subject.level.
|
34
|
-
subject.instance.
|
32
|
+
expect(subject.file).to_not be_nil
|
33
|
+
expect(subject.level).to_not be_nil
|
34
|
+
expect(subject.instance).to_not be_nil
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'keeps the same object from multiple calls to instance' do
|
38
|
-
subject.instance
|
38
|
+
expect(subject.instance).to equal(subject.instance)
|
39
39
|
end
|
40
40
|
|
41
41
|
end
|
@@ -43,13 +43,13 @@ describe Protobuf::Logger do
|
|
43
43
|
describe '.configure' do
|
44
44
|
before(:each) { subject.reset_device! }
|
45
45
|
it 'sets the file and level in one call' do
|
46
|
-
subject.file.
|
47
|
-
subject.level.
|
48
|
-
subject.instance.
|
46
|
+
expect(subject.file).to_not be
|
47
|
+
expect(subject.level).to_not be
|
48
|
+
expect(subject.instance).to_not be
|
49
49
|
subject.configure :file => 'myfile.log', :level => ::Logger::WARN
|
50
|
-
subject.file.
|
51
|
-
subject.level.
|
52
|
-
subject.instance.level.
|
50
|
+
expect(subject.file).to eq('myfile.log')
|
51
|
+
expect(subject.level).to eq(::Logger::WARN)
|
52
|
+
expect(subject.instance.level).to eq(::Logger::WARN)
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -57,13 +57,13 @@ describe Protobuf::Logger do
|
|
57
57
|
describe '.reset_device!' do
|
58
58
|
|
59
59
|
it 'resets the logger instance, file, and level' do
|
60
|
-
subject.instance.
|
61
|
-
subject.file.
|
62
|
-
subject.level.
|
60
|
+
expect(subject.instance).to be
|
61
|
+
expect(subject.file).to be
|
62
|
+
expect(subject.level).to be
|
63
63
|
subject.reset_device!
|
64
|
-
subject.instance.
|
65
|
-
subject.file.
|
66
|
-
subject.level.
|
64
|
+
expect(subject.instance).to_not be
|
65
|
+
expect(subject.file).to_not be
|
66
|
+
expect(subject.level).to_not be
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -72,7 +72,7 @@ describe Protobuf::Logger do
|
|
72
72
|
|
73
73
|
it 'doesn\'t raise errors when log instance is nil' do
|
74
74
|
subject.reset_device!
|
75
|
-
subject.instance.
|
75
|
+
expect(subject.instance).to be_nil
|
76
76
|
expect {
|
77
77
|
subject.debug 'No errors here'
|
78
78
|
subject.info 'No errors here'
|
@@ -85,8 +85,8 @@ describe Protobuf::Logger do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'logs correctly when instance is valid' do
|
88
|
-
subject.instance.
|
89
|
-
subject.instance.
|
88
|
+
expect(subject.instance).to_not be_nil
|
89
|
+
expect(subject.instance).to receive(:info).with('Should log great')
|
90
90
|
subject.info 'Should log great'
|
91
91
|
end
|
92
92
|
|
@@ -114,20 +114,20 @@ describe Protobuf::Logger do
|
|
114
114
|
|
115
115
|
context '#log_exception' do
|
116
116
|
it 'logs the exception message as an error and backtrace as debug' do
|
117
|
-
subject.
|
118
|
-
subject.
|
117
|
+
expect(subject).to receive(:log_error).twice
|
118
|
+
expect(subject).to receive(:log_debug)
|
119
119
|
subject.log_exception(RuntimeError.new('this is an exception'))
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
-
|
123
|
+
specify { expect(subject.log_signature).to eq "[MyTestClass]" }
|
124
124
|
describe '#sign_message' do
|
125
|
-
specify { subject.sign_message("this is a test").
|
126
|
-
specify { subject.class.sign_message("this is a test").
|
125
|
+
specify { expect(subject.sign_message("this is a test")).to eq "[MyTestClass] this is a test" }
|
126
|
+
specify { expect(subject.class.sign_message("this is a test")).to eq "[MyTestClass] this is a test" }
|
127
127
|
end
|
128
128
|
|
129
129
|
it 'passes all embedded log calls to Logger instance' do
|
130
|
-
Protobuf::Logger.instance.
|
130
|
+
expect(Protobuf::Logger.instance).to receive(:debug).with('[MyTestClass] log this')
|
131
131
|
subject.log_debug('log this')
|
132
132
|
end
|
133
133
|
|
@@ -6,7 +6,7 @@ describe Protobuf::Message do
|
|
6
6
|
let(:message) { ::Test::Resource.new(:name => "Jim") }
|
7
7
|
|
8
8
|
it 'creates a new message object decoded from the given bytes' do
|
9
|
-
::Test::Resource.decode(message.encode).
|
9
|
+
expect(::Test::Resource.decode(message.encode)).to eq message
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -62,41 +62,41 @@ describe Protobuf::Message do
|
|
62
62
|
let(:values) { { :name => "Jim" } }
|
63
63
|
|
64
64
|
it 'creates a new message object with the given values and returns the encoded bytes' do
|
65
|
-
::Test::Resource.encode(values).
|
65
|
+
expect(::Test::Resource.encode(values)).to eq ::Test::Resource.new(values).encode
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe '#initialize' do
|
70
70
|
it "initializes the enum getter to 0" do
|
71
71
|
test_enum = Test::EnumTestMessage.new
|
72
|
-
test_enum.non_default_enum.
|
72
|
+
expect(test_enum.non_default_enum).to eq(0)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "exposes the enum getter raw value through ! method" do
|
76
76
|
test_enum = Test::EnumTestMessage.new
|
77
|
-
test_enum.non_default_enum
|
77
|
+
expect(test_enum.non_default_enum!).to be_nil
|
78
78
|
end
|
79
79
|
|
80
80
|
it "exposes the enum getter raw value through ! method (when set)" do
|
81
81
|
test_enum = Test::EnumTestMessage.new
|
82
82
|
test_enum.non_default_enum = 1
|
83
|
-
test_enum.non_default_enum
|
83
|
+
expect(test_enum.non_default_enum!).to eq(1)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "does not try to set attributes which have nil values" do
|
87
|
-
Test::EnumTestMessage.
|
87
|
+
expect_any_instance_of(Test::EnumTestMessage).not_to receive("non_default_enum=")
|
88
88
|
Test::EnumTestMessage.new(:non_default_enum => nil)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "takes a hash as an initialization argument" do
|
92
92
|
test_enum = Test::EnumTestMessage.new(:non_default_enum => 2)
|
93
|
-
test_enum.non_default_enum.
|
93
|
+
expect(test_enum.non_default_enum).to eq(2)
|
94
94
|
end
|
95
95
|
|
96
96
|
it "initializes with an object that responds to #to_hash" do
|
97
97
|
hashie_object = OpenStruct.new(:to_hash => { :non_default_enum => 2 })
|
98
98
|
test_enum = Test::EnumTestMessage.new(hashie_object)
|
99
|
-
test_enum.non_default_enum.
|
99
|
+
expect(test_enum.non_default_enum).to eq(2)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -114,7 +114,7 @@ describe Protobuf::Message do
|
|
114
114
|
|
115
115
|
message = ::Test::Resource.new(:name => name)
|
116
116
|
new_message = ::Test::Resource.decode(message.encode)
|
117
|
-
(new_message.name == name).
|
117
|
+
expect(new_message.name == name).to be_truthy
|
118
118
|
end
|
119
119
|
|
120
120
|
it "trims binary when binary is input for string fields" do
|
@@ -123,7 +123,7 @@ describe Protobuf::Message do
|
|
123
123
|
|
124
124
|
message = ::Test::Resource.new(:name => name)
|
125
125
|
new_message = ::Test::Resource.decode(message.encode)
|
126
|
-
(new_message.name == "my name").
|
126
|
+
expect(new_message.name == "my name").to be_truthy
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -149,19 +149,19 @@ describe Protobuf::Message do
|
|
149
149
|
|
150
150
|
it "sets the value to nil when empty array is passed" do
|
151
151
|
message.repeated_enum = []
|
152
|
-
message.instance_variable_get("@values")[:repeated_enum].
|
152
|
+
expect(message.instance_variable_get("@values")[:repeated_enum]).to be_nil
|
153
153
|
end
|
154
154
|
|
155
155
|
it "does not compact the edit original array" do
|
156
156
|
a = [nil].freeze
|
157
157
|
message.repeated_enum = a
|
158
|
-
message.repeated_enum.
|
159
|
-
a.
|
158
|
+
expect(message.repeated_enum).to eq([])
|
159
|
+
expect(a).to eq([nil].freeze)
|
160
160
|
end
|
161
161
|
|
162
162
|
it "compacts the set array" do
|
163
163
|
message.repeated_enum = [nil]
|
164
|
-
message.repeated_enum.
|
164
|
+
expect(message.repeated_enum).to eq([])
|
165
165
|
end
|
166
166
|
|
167
167
|
it "raises TypeError when a non-array replaces it" do
|
@@ -179,16 +179,16 @@ describe Protobuf::Message do
|
|
179
179
|
|
180
180
|
it "sets the predicate to true when the boolean value is true" do
|
181
181
|
subject.active = true
|
182
|
-
subject.active
|
182
|
+
expect(subject.active?).to be_truthy
|
183
183
|
end
|
184
184
|
|
185
185
|
it "sets the predicate to false when the boolean value is false" do
|
186
186
|
subject.active = false
|
187
|
-
subject.active
|
187
|
+
expect(subject.active?).to be_falsey
|
188
188
|
end
|
189
189
|
|
190
190
|
it "does not put predicate methods on non-boolean fields" do
|
191
|
-
Test::ResourceFindRequest.new(:name => "resource").
|
191
|
+
expect(Test::ResourceFindRequest.new(:name => "resource")).to_not respond_to(:name?)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
@@ -196,11 +196,11 @@ describe Protobuf::Message do
|
|
196
196
|
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
197
197
|
|
198
198
|
it "is false when the message does not have the field" do
|
199
|
-
subject.respond_to_and_has?(:other_field).
|
199
|
+
expect(subject.respond_to_and_has?(:other_field)).to be_falsey
|
200
200
|
end
|
201
201
|
|
202
202
|
it "is true when the message has the field" do
|
203
|
-
subject.respond_to_and_has?(:non_default_enum).
|
203
|
+
expect(subject.respond_to_and_has?(:non_default_enum)).to be_truthy
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -208,38 +208,38 @@ describe Protobuf::Message do
|
|
208
208
|
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
209
209
|
|
210
210
|
it "is false when the message does not have the field" do
|
211
|
-
subject.respond_to_and_has_and_present?(:other_field).
|
211
|
+
expect(subject.respond_to_and_has_and_present?(:other_field)).to be_falsey
|
212
212
|
end
|
213
213
|
|
214
214
|
it "is false when the field is repeated and a value is not present" do
|
215
|
-
subject.respond_to_and_has_and_present?(:repeated_enums).
|
215
|
+
expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_falsey
|
216
216
|
end
|
217
217
|
|
218
218
|
it "is false when the field is repeated and the value is empty array" do
|
219
219
|
subject.repeated_enums = []
|
220
|
-
subject.respond_to_and_has_and_present?(:repeated_enums).
|
220
|
+
expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_falsey
|
221
221
|
end
|
222
222
|
|
223
223
|
it "is true when the field is repeated and a value is present" do
|
224
224
|
subject.repeated_enums = [2]
|
225
|
-
subject.respond_to_and_has_and_present?(:repeated_enums).
|
225
|
+
expect(subject.respond_to_and_has_and_present?(:repeated_enums)).to be_truthy
|
226
226
|
end
|
227
227
|
|
228
228
|
it "is true when the message has the field" do
|
229
|
-
subject.respond_to_and_has_and_present?(:non_default_enum).
|
229
|
+
expect(subject.respond_to_and_has_and_present?(:non_default_enum)).to be_truthy
|
230
230
|
end
|
231
231
|
|
232
232
|
context "#API" do
|
233
233
|
subject { Test::EnumTestMessage.new(:non_default_enum => 2) }
|
234
234
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
235
|
+
specify { expect(subject).to respond_to(:respond_to_and_has_and_present?) }
|
236
|
+
specify { expect(subject).to respond_to(:responds_to_and_has_and_present?) }
|
237
|
+
specify { expect(subject).to respond_to(:responds_to_has?) }
|
238
|
+
specify { expect(subject).to respond_to(:respond_to_has?) }
|
239
|
+
specify { expect(subject).to respond_to(:respond_to_has_present?) }
|
240
|
+
specify { expect(subject).to respond_to(:responds_to_has_present?) }
|
241
|
+
specify { expect(subject).to respond_to(:respond_to_and_has_present?) }
|
242
|
+
specify { expect(subject).to respond_to(:responds_to_and_has_present?) }
|
243
243
|
end
|
244
244
|
|
245
245
|
end
|
@@ -248,24 +248,24 @@ describe Protobuf::Message do
|
|
248
248
|
context 'generating values for an ENUM field' do
|
249
249
|
it 'converts the enum to its tag representation' do
|
250
250
|
hash = Test::EnumTestMessage.new(:non_default_enum => :TWO).to_hash
|
251
|
-
hash.
|
251
|
+
expect(hash).to eq({ :non_default_enum => 2 })
|
252
252
|
end
|
253
253
|
|
254
254
|
it 'does not populate default values' do
|
255
255
|
hash = Test::EnumTestMessage.new.to_hash
|
256
|
-
hash.
|
256
|
+
expect(hash).to eq(Hash.new)
|
257
257
|
end
|
258
258
|
|
259
259
|
it 'converts repeated enum fields to an array of the tags' do
|
260
260
|
hash = Test::EnumTestMessage.new(:repeated_enums => [ :ONE, :TWO, :TWO, :ONE ]).to_hash
|
261
|
-
hash.
|
261
|
+
expect(hash).to eq({ :repeated_enums => [ 1, 2, 2, 1 ] })
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
265
|
context 'generating values for a Message field' do
|
266
266
|
it 'recursively hashes field messages' do
|
267
267
|
hash = Test::Nested.new({ :resource => { :name => 'Nested' } }).to_hash
|
268
|
-
hash.
|
268
|
+
expect(hash).to eq({ :resource => { :name => 'Nested' } })
|
269
269
|
end
|
270
270
|
|
271
271
|
it 'recursively hashes a repeated set of messages' do
|
@@ -274,7 +274,7 @@ describe Protobuf::Message do
|
|
274
274
|
Test::Resource.new(:name => 'Resource 2')
|
275
275
|
])
|
276
276
|
|
277
|
-
proto.to_hash.
|
277
|
+
expect(proto.to_hash).to eq({ :multiple_resources => [ { :name => 'Resource 1' },
|
278
278
|
{ :name => 'Resource 2' } ] })
|
279
279
|
|
280
280
|
end
|
@@ -286,7 +286,7 @@ describe Protobuf::Message do
|
|
286
286
|
::Test::ResourceFindRequest.new({ :name => 'Test Name', :active => false })
|
287
287
|
end
|
288
288
|
|
289
|
-
|
289
|
+
specify { expect(subject.to_json).to eq '{"name":"Test Name","active":false}' }
|
290
290
|
end
|
291
291
|
|
292
292
|
describe '.to_json' do
|
@@ -330,8 +330,8 @@ describe Protobuf::Message do
|
|
330
330
|
end
|
331
331
|
|
332
332
|
it 'returns nil when field is not found' do
|
333
|
-
::Test::Resource.get_extension_field(-1).
|
334
|
-
::Test::Resource.get_extension_field(nil).
|
333
|
+
expect(::Test::Resource.get_extension_field(-1)).to be_nil
|
334
|
+
expect(::Test::Resource.get_extension_field(nil)).to be_nil
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
@@ -360,8 +360,8 @@ describe Protobuf::Message do
|
|
360
360
|
end
|
361
361
|
|
362
362
|
it 'returns nil when field is not defined' do
|
363
|
-
::Test::Resource.get_field(-1).
|
364
|
-
::Test::Resource.get_field(nil).
|
363
|
+
expect(::Test::Resource.get_field(-1)).to be_nil
|
364
|
+
expect(::Test::Resource.get_field(nil)).to be_nil
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
@@ -20,7 +20,7 @@ describe 'Optionable' do
|
|
20
20
|
|
21
21
|
it 'defaults the value to true' do
|
22
22
|
OptionableSetOptionTest.set_option(:baz_enabled)
|
23
|
-
expect(OptionableSetOptionTest.get_option(:baz_enabled)).to
|
23
|
+
expect(OptionableSetOptionTest.get_option(:baz_enabled)).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -10,29 +10,29 @@ describe Protobuf::Rpc::Client do
|
|
10
10
|
before { reset_service_location(Test::ResourceService) }
|
11
11
|
|
12
12
|
it 'should be able to get a client through the Service#client helper method' do
|
13
|
-
Test::ResourceService.client(:port => 9191).
|
13
|
+
expect(::Test::ResourceService.client(:port => 9191)).to eq(Protobuf::Rpc::Client.new(:service => Test::ResourceService, :port => 9191))
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should be able to override a service location's host and port" do
|
17
17
|
Test::ResourceService.located_at 'somewheregreat.com:12345'
|
18
18
|
clean_client = Test::ResourceService.client
|
19
|
-
clean_client.options[:host].
|
20
|
-
clean_client.options[:port].
|
19
|
+
expect(clean_client.options[:host]).to eq('somewheregreat.com')
|
20
|
+
expect(clean_client.options[:port]).to eq(12345)
|
21
21
|
|
22
22
|
updated_client = Test::ResourceService.client(:host => 'amazing.com', :port => 54321)
|
23
|
-
updated_client.options[:host].
|
24
|
-
updated_client.options[:port].
|
23
|
+
expect(updated_client.options[:host]).to eq('amazing.com')
|
24
|
+
expect(updated_client.options[:port]).to eq(54321)
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should be able to define which service to create itself for' do
|
28
28
|
client = Protobuf::Rpc::Client.new :service => Test::ResourceService
|
29
|
-
client.options[:service].
|
29
|
+
expect(client.options[:service]).to eq(Test::ResourceService)
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should have a hard default for host and port on a service that has not been configured' do
|
33
33
|
client = Test::ResourceService.client
|
34
|
-
client.options[:host].
|
35
|
-
client.options[:port].
|
34
|
+
expect(client.options[:host]).to eq(Protobuf::Rpc::Service::DEFAULT_HOST)
|
35
|
+
expect(client.options[:port]).to eq(Protobuf::Rpc::Service::DEFAULT_PORT)
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -45,7 +45,7 @@ describe Protobuf::Rpc::Client do
|
|
45
45
|
|
46
46
|
it 'should respond to defined service methods' do
|
47
47
|
client = Test::ResourceService.client
|
48
|
-
client.
|
48
|
+
expect(client).to receive(:send_request).and_return(nil)
|
49
49
|
expect { client.find(nil) }.to_not raise_error
|
50
50
|
end
|
51
51
|
end
|
@@ -54,11 +54,11 @@ describe Protobuf::Rpc::Client do
|
|
54
54
|
|
55
55
|
it 'should be able to create the correct request object if passed a hash' do
|
56
56
|
client = Test::ResourceService.client
|
57
|
-
client.
|
57
|
+
expect(client).to receive(:send_request)
|
58
58
|
client.find({:name => 'Test Name', :active => false})
|
59
|
-
client.options[:request].
|
60
|
-
client.options[:request].name.
|
61
|
-
client.options[:request].active.
|
59
|
+
expect(client.options[:request]).to be_a(Test::ResourceFindRequest)
|
60
|
+
expect(client.options[:request].name).to eq('Test Name')
|
61
|
+
expect(client.options[:request].active).to eq(false)
|
62
62
|
end
|
63
63
|
|
64
64
|
end
|
@@ -9,17 +9,17 @@ describe ::Protobuf::Rpc::Connector do
|
|
9
9
|
|
10
10
|
context 'Protobuf.connector_type is socket' do
|
11
11
|
before { ::Protobuf.connector_type = :socket }
|
12
|
-
|
12
|
+
specify { expect(subject).to eq ::Protobuf::Rpc::Connectors::Socket }
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'Protobuf.connector_type is not a known value' do
|
16
|
-
before { ::Protobuf.
|
17
|
-
|
16
|
+
before { allow(::Protobuf).to receive(:connector_type).and_return(:foo) }
|
17
|
+
specify { expect(subject).to eq(::Protobuf::Rpc::Connectors::Socket) }
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'Protobuf.connector_type is zmq' do
|
21
21
|
before { ::Protobuf.connector_type = :zmq }
|
22
|
-
|
22
|
+
specify { expect(subject).to eq(::Protobuf::Rpc::Connectors::Zmq) }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|