thrift 0.11.0.0 → 0.13.0

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.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/lib/thrift/protocol/base_protocol.rb +11 -3
  3. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  4. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  5. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  6. data/lib/thrift/protocol/json_protocol.rb +8 -0
  7. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  8. data/lib/thrift/server/base_server.rb +8 -2
  9. data/lib/thrift/server/simple_server.rb +5 -1
  10. data/lib/thrift/server/thread_pool_server.rb +5 -1
  11. data/lib/thrift/server/threaded_server.rb +5 -1
  12. data/lib/thrift/transport/base_server_transport.rb +1 -1
  13. data/lib/thrift/transport/base_transport.rb +8 -0
  14. data/lib/thrift/transport/buffered_transport.rb +9 -1
  15. data/lib/thrift/transport/framed_transport.rb +9 -1
  16. data/lib/thrift/transport/http_client_transport.rb +4 -0
  17. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  18. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  19. data/lib/thrift/transport/server_socket.rb +6 -1
  20. data/lib/thrift/transport/socket.rb +4 -2
  21. data/lib/thrift/transport/ssl_server_socket.rb +4 -0
  22. data/lib/thrift/transport/ssl_socket.rb +4 -0
  23. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  24. data/lib/thrift/transport/unix_socket.rb +5 -1
  25. data/spec/base_protocol_spec.rb +79 -71
  26. data/spec/base_transport_spec.rb +155 -117
  27. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  28. data/spec/binary_protocol_spec.rb +16 -8
  29. data/spec/binary_protocol_spec_shared.rb +73 -70
  30. data/spec/bytes_spec.rb +38 -38
  31. data/spec/client_spec.rb +41 -42
  32. data/spec/compact_protocol_spec.rb +23 -8
  33. data/spec/exception_spec.rb +54 -54
  34. data/spec/flat_spec.rb +5 -5
  35. data/spec/http_client_spec.rb +42 -38
  36. data/spec/json_protocol_spec.rb +146 -138
  37. data/spec/namespaced_spec.rb +5 -5
  38. data/spec/nonblocking_server_spec.rb +16 -16
  39. data/spec/processor_spec.rb +26 -26
  40. data/spec/serializer_spec.rb +20 -20
  41. data/spec/server_socket_spec.rb +27 -22
  42. data/spec/server_spec.rb +91 -52
  43. data/spec/socket_spec.rb +23 -16
  44. data/spec/socket_spec_shared.rb +31 -31
  45. data/spec/ssl_server_socket_spec.rb +34 -0
  46. data/spec/ssl_socket_spec.rb +26 -22
  47. data/spec/struct_nested_containers_spec.rb +24 -24
  48. data/spec/struct_spec.rb +120 -120
  49. data/spec/thin_http_server_spec.rb +18 -18
  50. data/spec/types_spec.rb +56 -53
  51. data/spec/union_spec.rb +42 -43
  52. data/spec/unix_socket_spec.rb +43 -34
  53. metadata +134 -154
  54. data/benchmark/gen-rb/benchmark_constants.rb +0 -11
  55. data/benchmark/gen-rb/benchmark_service.rb +0 -80
  56. data/benchmark/gen-rb/benchmark_types.rb +0 -10
  57. data/spec/gen-rb/base/base_service.rb +0 -80
  58. data/spec/gen-rb/base/base_service_constants.rb +0 -11
  59. data/spec/gen-rb/base/base_service_types.rb +0 -26
  60. data/spec/gen-rb/extended/extended_service.rb +0 -78
  61. data/spec/gen-rb/extended/extended_service_constants.rb +0 -11
  62. data/spec/gen-rb/extended/extended_service_types.rb +0 -12
  63. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +0 -272
  64. data/spec/gen-rb/flat/referenced_constants.rb +0 -11
  65. data/spec/gen-rb/flat/referenced_types.rb +0 -17
  66. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +0 -11
  67. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +0 -28
  68. data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +0 -272
  69. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +0 -11
  70. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +0 -28
  71. data/spec/gen-rb/nonblocking_service.rb +0 -272
  72. data/spec/gen-rb/other_namespace/referenced_constants.rb +0 -11
  73. data/spec/gen-rb/other_namespace/referenced_types.rb +0 -17
  74. data/spec/gen-rb/thrift_spec_constants.rb +0 -11
  75. data/spec/gen-rb/thrift_spec_types.rb +0 -538
  76. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -278
  77. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -781
  78. data/test/debug_proto/gen-rb/empty_service.rb +0 -28
  79. data/test/debug_proto/gen-rb/inherited.rb +0 -83
  80. data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -86
  81. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -85
  82. data/test/debug_proto/gen-rb/srv.rb +0 -395
@@ -33,10 +33,14 @@ if defined? Thrift::BinaryProtocolAccelerated
33
33
 
34
34
  describe Thrift::BinaryProtocolAcceleratedFactory do
35
35
  it "should create a BinaryProtocolAccelerated" do
36
- Thrift::BinaryProtocolAcceleratedFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocolAccelerated)
36
+ expect(Thrift::BinaryProtocolAcceleratedFactory.new.get_protocol(double("MockTransport"))).to be_instance_of(Thrift::BinaryProtocolAccelerated)
37
+ end
38
+
39
+ it "should provide a reasonable to_s" do
40
+ expect(Thrift::BinaryProtocolAcceleratedFactory.new.to_s).to eq("binary-accel")
37
41
  end
38
42
  end
39
43
  end
40
44
  else
41
45
  puts "skipping BinaryProtocolAccelerated spec because it is not defined."
42
- end
46
+ end
@@ -38,29 +38,37 @@ describe 'BinaryProtocol' do
38
38
  it "should read a message header" do
39
39
  @trans.write([protocol_class.const_get(:VERSION_1) | Thrift::MessageTypes::REPLY].pack('N'))
40
40
  @trans.write([42].pack('N'))
41
- @prot.should_receive(:read_string).and_return('testMessage')
42
- @prot.read_message_begin.should == ['testMessage', Thrift::MessageTypes::REPLY, 42]
41
+ expect(@prot).to receive(:read_string).and_return('testMessage')
42
+ expect(@prot.read_message_begin).to eq(['testMessage', Thrift::MessageTypes::REPLY, 42])
43
43
  end
44
44
 
45
45
  it "should raise an exception if the message header has the wrong version" do
46
- @prot.should_receive(:read_i32).and_return(-1)
47
- lambda { @prot.read_message_begin }.should raise_error(Thrift::ProtocolException, 'Missing version identifier') do |e|
46
+ expect(@prot).to receive(:read_i32).and_return(-1)
47
+ expect { @prot.read_message_begin }.to raise_error(Thrift::ProtocolException, 'Missing version identifier') do |e|
48
48
  e.type == Thrift::ProtocolException::BAD_VERSION
49
49
  end
50
50
  end
51
51
 
52
52
  it "should raise an exception if the message header does not exist and strict_read is enabled" do
53
- @prot.should_receive(:read_i32).and_return(42)
54
- @prot.should_receive(:strict_read).and_return(true)
55
- lambda { @prot.read_message_begin }.should raise_error(Thrift::ProtocolException, 'No version identifier, old protocol client?') do |e|
53
+ expect(@prot).to receive(:read_i32).and_return(42)
54
+ expect(@prot).to receive(:strict_read).and_return(true)
55
+ expect { @prot.read_message_begin }.to raise_error(Thrift::ProtocolException, 'No version identifier, old protocol client?') do |e|
56
56
  e.type == Thrift::ProtocolException::BAD_VERSION
57
57
  end
58
58
  end
59
+
60
+ it "should provide a reasonable to_s" do
61
+ expect(@prot.to_s).to eq("binary(memory)")
62
+ end
59
63
  end
60
64
 
61
65
  describe Thrift::BinaryProtocolFactory do
62
66
  it "should create a BinaryProtocol" do
63
- Thrift::BinaryProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::BinaryProtocol)
67
+ expect(Thrift::BinaryProtocolFactory.new.get_protocol(double("MockTransport"))).to be_instance_of(Thrift::BinaryProtocol)
68
+ end
69
+
70
+ it "should provide a reasonable to_s" do
71
+ expect(Thrift::BinaryProtocolFactory.new.to_s).to eq("binary")
64
72
  end
65
73
  end
66
74
  end
@@ -27,34 +27,34 @@ shared_examples_for 'a binary protocol' do
27
27
  end
28
28
 
29
29
  it "should define the proper VERSION_1, VERSION_MASK AND TYPE_MASK" do
30
- protocol_class.const_get(:VERSION_MASK).should == 0xffff0000
31
- protocol_class.const_get(:VERSION_1).should == 0x80010000
32
- protocol_class.const_get(:TYPE_MASK).should == 0x000000ff
30
+ expect(protocol_class.const_get(:VERSION_MASK)).to eq(0xffff0000)
31
+ expect(protocol_class.const_get(:VERSION_1)).to eq(0x80010000)
32
+ expect(protocol_class.const_get(:TYPE_MASK)).to eq(0x000000ff)
33
33
  end
34
34
 
35
35
  it "should make strict_read readable" do
36
- @prot.strict_read.should eql(true)
36
+ expect(@prot.strict_read).to eql(true)
37
37
  end
38
38
 
39
39
  it "should make strict_write readable" do
40
- @prot.strict_write.should eql(true)
40
+ expect(@prot.strict_write).to eql(true)
41
41
  end
42
42
 
43
43
  it "should write the message header" do
44
44
  @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
45
- @trans.read(@trans.available).should == [protocol_class.const_get(:VERSION_1) | Thrift::MessageTypes::CALL, "testMessage".size, "testMessage", 17].pack("NNa11N")
45
+ expect(@trans.read(@trans.available)).to eq([protocol_class.const_get(:VERSION_1) | Thrift::MessageTypes::CALL, "testMessage".size, "testMessage", 17].pack("NNa11N"))
46
46
  end
47
47
 
48
48
  it "should write the message header without version when writes are not strict" do
49
49
  @prot = protocol_class.new(@trans, true, false) # no strict write
50
50
  @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
51
- @trans.read(@trans.available).should == "\000\000\000\vtestMessage\001\000\000\000\021"
51
+ expect(@trans.read(@trans.available)).to eq("\000\000\000\vtestMessage\001\000\000\000\021")
52
52
  end
53
53
 
54
54
  it "should write the message header with a version when writes are strict" do
55
55
  @prot = protocol_class.new(@trans) # strict write
56
56
  @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
57
- @trans.read(@trans.available).should == "\200\001\000\001\000\000\000\vtestMessage\000\000\000\021"
57
+ expect(@trans.read(@trans.available)).to eq("\200\001\000\001\000\000\000\vtestMessage\000\000\000\021")
58
58
  end
59
59
 
60
60
 
@@ -62,64 +62,67 @@ shared_examples_for 'a binary protocol' do
62
62
 
63
63
  it "should write the field header" do
64
64
  @prot.write_field_begin('foo', Thrift::Types::DOUBLE, 3)
65
- @trans.read(@trans.available).should == [Thrift::Types::DOUBLE, 3].pack("cn")
65
+ expect(@trans.read(@trans.available)).to eq([Thrift::Types::DOUBLE, 3].pack("cn"))
66
66
  end
67
67
 
68
68
  # field footer is a noop
69
69
 
70
70
  it "should write the STOP field" do
71
71
  @prot.write_field_stop
72
- @trans.read(1).should == "\000"
72
+ expect(@trans.read(1)).to eq("\000")
73
73
  end
74
74
 
75
75
  it "should write the map header" do
76
76
  @prot.write_map_begin(Thrift::Types::STRING, Thrift::Types::LIST, 17)
77
- @trans.read(@trans.available).should == [Thrift::Types::STRING, Thrift::Types::LIST, 17].pack("ccN");
77
+ expect(@trans.read(@trans.available)).to eq([Thrift::Types::STRING, Thrift::Types::LIST, 17].pack("ccN"));
78
78
  end
79
79
 
80
80
  # map footer is a noop
81
81
 
82
82
  it "should write the list header" do
83
83
  @prot.write_list_begin(Thrift::Types::I16, 42)
84
- @trans.read(@trans.available).should == [Thrift::Types::I16, 42].pack("cN")
84
+ expect(@trans.read(@trans.available)).to eq([Thrift::Types::I16, 42].pack("cN"))
85
85
  end
86
86
 
87
87
  # list footer is a noop
88
88
 
89
89
  it "should write the set header" do
90
90
  @prot.write_set_begin(Thrift::Types::I16, 42)
91
- @trans.read(@trans.available).should == [Thrift::Types::I16, 42].pack("cN")
91
+ expect(@trans.read(@trans.available)).to eq([Thrift::Types::I16, 42].pack("cN"))
92
92
  end
93
93
 
94
94
  it "should write a bool" do
95
95
  @prot.write_bool(true)
96
96
  @prot.write_bool(false)
97
- @trans.read(@trans.available).should == "\001\000"
97
+ expect(@trans.read(@trans.available)).to eq("\001\000")
98
98
  end
99
99
 
100
100
  it "should treat a nil bool as false" do
101
101
  @prot.write_bool(nil)
102
- @trans.read(1).should == "\000"
102
+ expect(@trans.read(1)).to eq("\000")
103
103
  end
104
104
 
105
105
  it "should write a byte" do
106
106
  # byte is small enough, let's check -128..127
107
107
  (-128..127).each do |i|
108
108
  @prot.write_byte(i)
109
- @trans.read(1).should == [i].pack('c')
109
+ expect(@trans.read(1)).to eq([i].pack('c'))
110
110
  end
111
- # handing it numbers out of signed range should clip
112
- @trans.rspec_verify
111
+ end
112
+
113
+ it "should clip numbers out of signed range" do
113
114
  (128..255).each do |i|
114
115
  @prot.write_byte(i)
115
- @trans.read(1).should == [i].pack('c')
116
+ expect(@trans.read(1)).to eq([i].pack('c'))
116
117
  end
117
- # and lastly, a Bignum is going to error out
118
- lambda { @prot.write_byte(2**65) }.should raise_error(RangeError)
118
+ end
119
+
120
+ it "errors out with a Bignum" do
121
+ expect { @prot.write_byte(2**65) }.to raise_error(RangeError)
119
122
  end
120
123
 
121
124
  it "should error gracefully when trying to write a nil byte" do
122
- lambda { @prot.write_byte(nil) }.should raise_error
125
+ expect { @prot.write_byte(nil) }.to raise_error
123
126
  end
124
127
 
125
128
  it "should write an i16" do
@@ -131,14 +134,14 @@ shared_examples_for 'a binary protocol' do
131
134
  # and try something out of signed range, it should clip
132
135
  @prot.write_i16(2**15 + 5)
133
136
 
134
- @trans.read(@trans.available).should == "\200\000\374\000\000\021\000\000\330\360\006\273\177\377\200\005"
137
+ expect(@trans.read(@trans.available)).to eq("\200\000\374\000\000\021\000\000\330\360\006\273\177\377\200\005")
135
138
 
136
139
  # a Bignum should error
137
140
  # lambda { @prot.write_i16(2**65) }.should raise_error(RangeError)
138
141
  end
139
142
 
140
143
  it "should error gracefully when trying to write a nil i16" do
141
- lambda { @prot.write_i16(nil) }.should raise_error
144
+ expect { @prot.write_i16(nil) }.to raise_error
142
145
  end
143
146
 
144
147
  it "should write an i32" do
@@ -148,14 +151,14 @@ shared_examples_for 'a binary protocol' do
148
151
  @prot.write_i32(i)
149
152
  end
150
153
  # try something out of signed range, it should clip
151
- @trans.read(@trans.available).should == "\200\000\000\000" + "\377\376\037\r" + "\377\377\366\034" + "\377\377\377\375" + "\000\000\000\000" + "\000#\340\203" + "\000\0000+" + "\177\377\377\377"
154
+ expect(@trans.read(@trans.available)).to eq("\200\000\000\000" + "\377\376\037\r" + "\377\377\366\034" + "\377\377\377\375" + "\000\000\000\000" + "\000#\340\203" + "\000\0000+" + "\177\377\377\377")
152
155
  [2 ** 31 + 5, 2 ** 65 + 5].each do |i|
153
- lambda { @prot.write_i32(i) }.should raise_error(RangeError)
156
+ expect { @prot.write_i32(i) }.to raise_error(RangeError)
154
157
  end
155
158
  end
156
159
 
157
160
  it "should error gracefully when trying to write a nil i32" do
158
- lambda { @prot.write_i32(nil) }.should raise_error
161
+ expect { @prot.write_i32(nil) }.to raise_error
159
162
  end
160
163
 
161
164
  it "should write an i64" do
@@ -165,7 +168,7 @@ shared_examples_for 'a binary protocol' do
165
168
  @prot.write_i64(i)
166
169
  end
167
170
  # try something out of signed range, it should clip
168
- @trans.read(@trans.available).should == ["\200\000\000\000\000\000\000\000",
171
+ expect(@trans.read(@trans.available)).to eq(["\200\000\000\000\000\000\000\000",
169
172
  "\377\377\364\303\035\244+]",
170
173
  "\377\377\377\377\376\231:\341",
171
174
  "\377\377\377\377\377\377\377\026",
@@ -173,12 +176,12 @@ shared_examples_for 'a binary protocol' do
173
176
  "\000\000\000\000\000\000\004\317",
174
177
  "\000\000\000\000\000#\340\204",
175
178
  "\000\000\000\002\340\311~\365",
176
- "\177\377\377\377\377\377\377\377"].join("")
177
- lambda { @prot.write_i64(2 ** 65 + 5) }.should raise_error(RangeError)
179
+ "\177\377\377\377\377\377\377\377"].join(""))
180
+ expect { @prot.write_i64(2 ** 65 + 5) }.to raise_error(RangeError)
178
181
  end
179
182
 
180
183
  it "should error gracefully when trying to write a nil i64" do
181
- lambda { @prot.write_i64(nil) }.should raise_error
184
+ expect { @prot.write_i64(nil) }.to raise_error
182
185
  end
183
186
 
184
187
  it "should write a double" do
@@ -186,12 +189,12 @@ shared_examples_for 'a binary protocol' do
186
189
  values = [Float::MIN,-1231.15325, -123123.23, -23.23515123, 0, 12351.1325, 523.23, Float::MAX]
187
190
  values.each do |f|
188
191
  @prot.write_double(f)
189
- @trans.read(@trans.available).should == [f].pack("G")
192
+ expect(@trans.read(@trans.available)).to eq([f].pack("G"))
190
193
  end
191
194
  end
192
195
 
193
196
  it "should error gracefully when trying to write a nil double" do
194
- lambda { @prot.write_double(nil) }.should raise_error
197
+ expect { @prot.write_double(nil) }.to raise_error
195
198
  end
196
199
 
197
200
  if RUBY_VERSION >= '1.9'
@@ -199,111 +202,111 @@ shared_examples_for 'a binary protocol' do
199
202
  str = 'abc'
200
203
  @prot.write_string(str)
201
204
  a = @trans.read(@trans.available)
202
- a.encoding.should == Encoding::BINARY
203
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63]
205
+ expect(a.encoding).to eq(Encoding::BINARY)
206
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63])
204
207
  end
205
208
 
206
209
  it 'should write a string with unicode characters' do
207
210
  str = "abc \u20AC \u20AD".encode('UTF-8')
208
211
  @prot.write_string(str)
209
212
  a = @trans.read(@trans.available)
210
- a.encoding.should == Encoding::BINARY
211
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x0B, 0x61, 0x62, 0x63, 0x20,
212
- 0xE2, 0x82, 0xAC, 0x20, 0xE2, 0x82, 0xAD]
213
+ expect(a.encoding).to eq(Encoding::BINARY)
214
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x0B, 0x61, 0x62, 0x63, 0x20,
215
+ 0xE2, 0x82, 0xAC, 0x20, 0xE2, 0x82, 0xAD])
213
216
  end
214
217
 
215
218
  it 'should write should write a string with unicode characters and transcoding' do
216
219
  str = "abc \u20AC".encode('ISO-8859-15')
217
220
  @prot.write_string(str)
218
221
  a = @trans.read(@trans.available)
219
- a.encoding.should == Encoding::BINARY
220
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x07, 0x61, 0x62, 0x63, 0x20, 0xE2, 0x82, 0xAC]
222
+ expect(a.encoding).to eq(Encoding::BINARY)
223
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x07, 0x61, 0x62, 0x63, 0x20, 0xE2, 0x82, 0xAC])
221
224
  end
222
225
 
223
226
  it 'should write a binary string' do
224
227
  buffer = [0, 1, 2, 3].pack('C*')
225
228
  @prot.write_binary(buffer)
226
229
  a = @trans.read(@trans.available)
227
- a.encoding.should == Encoding::BINARY
228
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03]
230
+ expect(a.encoding).to eq(Encoding::BINARY)
231
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03])
229
232
  end
230
233
  else
231
234
  it 'should write a string' do
232
235
  str = 'abc'
233
236
  @prot.write_string(str)
234
237
  a = @trans.read(@trans.available)
235
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63]
238
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63])
236
239
  end
237
240
 
238
241
  it 'should write a binary string' do
239
242
  buffer = [0, 1, 2, 3].pack('C*')
240
243
  @prot.write_binary(buffer)
241
244
  a = @trans.read(@trans.available)
242
- a.unpack('C*').should == [0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03]
245
+ expect(a.unpack('C*')).to eq([0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03])
243
246
  end
244
247
  end
245
248
 
246
249
  it "should error gracefully when trying to write a nil string" do
247
- lambda { @prot.write_string(nil) }.should raise_error
250
+ expect { @prot.write_string(nil) }.to raise_error
248
251
  end
249
252
 
250
253
  it "should write the message header without version when writes are not strict" do
251
254
  @prot = protocol_class.new(@trans, true, false) # no strict write
252
255
  @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
253
- @trans.read(@trans.available).should == "\000\000\000\vtestMessage\001\000\000\000\021"
256
+ expect(@trans.read(@trans.available)).to eq("\000\000\000\vtestMessage\001\000\000\000\021")
254
257
  end
255
258
 
256
259
  it "should write the message header with a version when writes are strict" do
257
260
  @prot = protocol_class.new(@trans) # strict write
258
261
  @prot.write_message_begin('testMessage', Thrift::MessageTypes::CALL, 17)
259
- @trans.read(@trans.available).should == "\200\001\000\001\000\000\000\vtestMessage\000\000\000\021"
262
+ expect(@trans.read(@trans.available)).to eq("\200\001\000\001\000\000\000\vtestMessage\000\000\000\021")
260
263
  end
261
264
 
262
265
  # message footer is a noop
263
266
 
264
267
  it "should read a field header" do
265
268
  @trans.write([Thrift::Types::STRING, 3].pack("cn"))
266
- @prot.read_field_begin.should == [nil, Thrift::Types::STRING, 3]
269
+ expect(@prot.read_field_begin).to eq([nil, Thrift::Types::STRING, 3])
267
270
  end
268
271
 
269
272
  # field footer is a noop
270
273
 
271
274
  it "should read a stop field" do
272
275
  @trans.write([Thrift::Types::STOP].pack("c"));
273
- @prot.read_field_begin.should == [nil, Thrift::Types::STOP, 0]
276
+ expect(@prot.read_field_begin).to eq([nil, Thrift::Types::STOP, 0])
274
277
  end
275
278
 
276
279
  it "should read a map header" do
277
280
  @trans.write([Thrift::Types::DOUBLE, Thrift::Types::I64, 42].pack("ccN"))
278
- @prot.read_map_begin.should == [Thrift::Types::DOUBLE, Thrift::Types::I64, 42]
281
+ expect(@prot.read_map_begin).to eq([Thrift::Types::DOUBLE, Thrift::Types::I64, 42])
279
282
  end
280
283
 
281
284
  # map footer is a noop
282
285
 
283
286
  it "should read a list header" do
284
287
  @trans.write([Thrift::Types::STRING, 17].pack("cN"))
285
- @prot.read_list_begin.should == [Thrift::Types::STRING, 17]
288
+ expect(@prot.read_list_begin).to eq([Thrift::Types::STRING, 17])
286
289
  end
287
290
 
288
291
  # list footer is a noop
289
292
 
290
293
  it "should read a set header" do
291
294
  @trans.write([Thrift::Types::STRING, 17].pack("cN"))
292
- @prot.read_set_begin.should == [Thrift::Types::STRING, 17]
295
+ expect(@prot.read_set_begin).to eq([Thrift::Types::STRING, 17])
293
296
  end
294
297
 
295
298
  # set footer is a noop
296
299
 
297
300
  it "should read a bool" do
298
301
  @trans.write("\001\000");
299
- @prot.read_bool.should == true
300
- @prot.read_bool.should == false
302
+ expect(@prot.read_bool).to eq(true)
303
+ expect(@prot.read_bool).to eq(false)
301
304
  end
302
305
 
303
306
  it "should read a byte" do
304
307
  [-128, -57, -3, 0, 17, 24, 127].each do |i|
305
308
  @trans.write([i].pack("c"))
306
- @prot.read_byte.should == i
309
+ expect(@prot.read_byte).to eq(i)
307
310
  end
308
311
  end
309
312
 
@@ -311,7 +314,7 @@ shared_examples_for 'a binary protocol' do
311
314
  # try a scattering of values, including min/max
312
315
  [-2**15, -5237, -353, 0, 1527, 2234, 2**15-1].each do |i|
313
316
  @trans.write([i].pack("n"));
314
- @prot.read_i16.should == i
317
+ expect(@prot.read_i16).to eq(i)
315
318
  end
316
319
  end
317
320
 
@@ -319,7 +322,7 @@ shared_examples_for 'a binary protocol' do
319
322
  # try a scattering of values, including min/max
320
323
  [-2**31, -235125, -6236, 0, 2351, 123123, 2**31-1].each do |i|
321
324
  @trans.write([i].pack("N"))
322
- @prot.read_i32.should == i
325
+ expect(@prot.read_i32).to eq(i)
323
326
  end
324
327
  end
325
328
 
@@ -327,7 +330,7 @@ shared_examples_for 'a binary protocol' do
327
330
  # try a scattering of values, including min/max
328
331
  [-2**63, -123512312, -6346, 0, 32, 2346322323, 2**63-1].each do |i|
329
332
  @trans.write([i >> 32, i & 0xFFFFFFFF].pack("NN"))
330
- @prot.read_i64.should == i
333
+ expect(@prot.read_i64).to eq(i)
331
334
  end
332
335
  end
333
336
 
@@ -335,7 +338,7 @@ shared_examples_for 'a binary protocol' do
335
338
  # try a random scattering of values, including min/max
336
339
  [Float::MIN, -231231.12351, -323.233513, 0, 123.2351235, 2351235.12351235, Float::MAX].each do |f|
337
340
  @trans.write([f].pack("G"));
338
- @prot.read_double.should == f
341
+ expect(@prot.read_double).to eq(f)
339
342
  end
340
343
  end
341
344
 
@@ -345,8 +348,8 @@ shared_examples_for 'a binary protocol' do
345
348
  buffer = [0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63].pack('C*')
346
349
  @trans.write(buffer)
347
350
  a = @prot.read_string
348
- a.should == 'abc'.encode('UTF-8')
349
- a.encoding.should == Encoding::UTF_8
351
+ expect(a).to eq('abc'.encode('UTF-8'))
352
+ expect(a.encoding).to eq(Encoding::UTF_8)
350
353
  end
351
354
 
352
355
  it 'should read a string containing unicode characters from UTF-8 encoded buffer' do
@@ -354,44 +357,44 @@ shared_examples_for 'a binary protocol' do
354
357
  buffer = [0x00, 0x00, 0x00, 0x03, 0xE2, 0x82, 0xAC].pack('C*')
355
358
  @trans.write(buffer)
356
359
  a = @prot.read_string
357
- a.should == "\u20AC".encode('UTF-8')
358
- a.encoding.should == Encoding::UTF_8
360
+ expect(a).to eq("\u20AC".encode('UTF-8'))
361
+ expect(a.encoding).to eq(Encoding::UTF_8)
359
362
  end
360
363
 
361
364
  it 'should read a binary string' do
362
365
  buffer = [0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03].pack('C*')
363
366
  @trans.write(buffer)
364
367
  a = @prot.read_binary
365
- a.should == [0x00, 0x01, 0x02, 0x03].pack('C*')
366
- a.encoding.should == Encoding::BINARY
368
+ expect(a).to eq([0x00, 0x01, 0x02, 0x03].pack('C*'))
369
+ expect(a.encoding).to eq(Encoding::BINARY)
367
370
  end
368
371
  else
369
372
  it 'should read a string' do
370
373
  # i32 of value 3, followed by three characters/UTF-8 bytes 'a', 'b', 'c'
371
374
  buffer = [0x00, 0x00, 0x00, 0x03, 0x61, 0x62, 0x63].pack('C*')
372
375
  @trans.write(buffer)
373
- @prot.read_string.should == 'abc'
376
+ expect(@prot.read_string).to eq('abc')
374
377
  end
375
378
 
376
379
  it 'should read a binary string' do
377
380
  buffer = [0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x02, 0x03].pack('C*')
378
381
  @trans.write(buffer)
379
382
  a = @prot.read_binary
380
- a.should == [0x00, 0x01, 0x02, 0x03].pack('C*')
383
+ expect(a).to eq([0x00, 0x01, 0x02, 0x03].pack('C*'))
381
384
  end
382
385
  end
383
386
 
384
387
  it "should perform a complete rpc with no args or return" do
385
388
  srv_test(
386
389
  proc {|client| client.send_voidMethod()},
387
- proc {|client| client.recv_voidMethod.should == nil}
390
+ proc {|client| expect(client.recv_voidMethod).to eq(nil)}
388
391
  )
389
392
  end
390
393
 
391
394
  it "should perform a complete rpc with a primitive return type" do
392
395
  srv_test(
393
396
  proc {|client| client.send_primitiveMethod()},
394
- proc {|client| client.recv_primitiveMethod.should == 1}
397
+ proc {|client| expect(client.recv_primitiveMethod).to eq(1)}
395
398
  )
396
399
  end
397
400
 
@@ -402,7 +405,7 @@ shared_examples_for 'a binary protocol' do
402
405
  result = client.recv_structMethod
403
406
  result.set_byte_map = nil
404
407
  result.map_byte_map = nil
405
- result.should == Fixtures::COMPACT_PROTOCOL_TEST_STRUCT
408
+ expect(result).to eq(Fixtures::COMPACT_PROTOCOL_TEST_STRUCT)
406
409
  }
407
410
  )
408
411
  end