thrift 0.11.0.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a9a70c3d1662d7eacf0ec7062e1134d679ebc085
4
- data.tar.gz: b65b2bbb34d616676940087447e47d487cdb815c
2
+ SHA256:
3
+ metadata.gz: 6c894aeced9c6d4f7f4e66441472dbe37603b45722cffe89007e6faa1d2771c8
4
+ data.tar.gz: 3417f5e29c4459b18933e1a6c2eb6575ce0b8c6c073bac4836043742854a8c01
5
5
  SHA512:
6
- metadata.gz: 4cc1765c1335c36c4473563bab2ef2eacf27540414251e3b94e7b0a0e9ac9a0f637e75f5c64f69b0028c2c402b08d8916d0fb29897f0da37f837d42b07fcac66
7
- data.tar.gz: 54fdb5210b5f850b4fd1fb6741dbac719d3ad340bcc94b2db8965b807ae701fad140961303f2bb52cd9f10bba2bd9c80d83b1682c9b70e3b15c271faf6e13049
6
+ metadata.gz: 4daf374c7752cfd11fb60fa7f1a5323f026bacbff118987f7e4342bfc79e9da8cc80e2872ddf571e2b705a310fe7921bc0c011215ec5f222cee252e0ec9a513f
7
+ data.tar.gz: 4712fd01cd41fde2877df76808af17ce303656c3a003dcda92c876766aba508cdaf802511e3698ce5f4476064a435057e47493f05a2e4f928c67e16ec7554562
@@ -323,8 +323,6 @@ module Thrift
323
323
 
324
324
  def skip(type)
325
325
  case type
326
- when Types::STOP
327
- nil
328
326
  when Types::BOOL
329
327
  read_bool
330
328
  when Types::BYTE
@@ -367,13 +365,23 @@ module Thrift
367
365
  skip(etype)
368
366
  end
369
367
  read_list_end
368
+ else
369
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid data')
370
370
  end
371
371
  end
372
+
373
+ def to_s
374
+ "#{trans.to_s}"
375
+ end
372
376
  end
373
377
 
374
378
  class BaseProtocolFactory
375
379
  def get_protocol(trans)
376
380
  raise NotImplementedError
377
381
  end
382
+
383
+ def to_s
384
+ "base"
385
+ end
378
386
  end
379
- end
387
+ end
@@ -226,12 +226,19 @@ module Thrift
226
226
  size = read_i32
227
227
  trans.read_all(size)
228
228
  end
229
-
229
+
230
+ def to_s
231
+ "binary(#{super.to_s})"
232
+ end
230
233
  end
231
234
 
232
235
  class BinaryProtocolFactory < BaseProtocolFactory
233
236
  def get_protocol(trans)
234
237
  return Thrift::BinaryProtocol.new(trans)
235
238
  end
239
+
240
+ def to_s
241
+ "binary"
242
+ end
236
243
  end
237
244
  end
@@ -35,5 +35,13 @@ module Thrift
35
35
  BinaryProtocol.new(trans)
36
36
  end
37
37
  end
38
+
39
+ def to_s
40
+ if (defined? BinaryProtocolAccelerated)
41
+ "binary-accel"
42
+ else
43
+ "binary"
44
+ end
45
+ end
38
46
  end
39
47
  end
@@ -345,6 +345,10 @@ module Thrift
345
345
  size = read_varint32()
346
346
  trans.read_all(size)
347
347
  end
348
+
349
+ def to_s
350
+ "compact(#{super.to_s})"
351
+ end
348
352
 
349
353
  private
350
354
 
@@ -431,5 +435,9 @@ module Thrift
431
435
  def get_protocol(trans)
432
436
  CompactProtocol.new(trans)
433
437
  end
438
+
439
+ def to_s
440
+ "compact"
441
+ end
434
442
  end
435
443
  end
@@ -768,11 +768,19 @@ module Thrift
768
768
  def read_binary
769
769
  read_json_base64
770
770
  end
771
+
772
+ def to_s
773
+ "json(#{super.to_s})"
774
+ end
771
775
  end
772
776
 
773
777
  class JsonProtocolFactory < BaseProtocolFactory
774
778
  def get_protocol(trans)
775
779
  return Thrift::JsonProtocol.new(trans)
776
780
  end
781
+
782
+ def to_s
783
+ "json"
784
+ end
777
785
  end
778
786
  end
@@ -36,5 +36,9 @@ module Thrift
36
36
  @protocol.write_message_begin(name, type, seqid)
37
37
  end
38
38
  end
39
+
40
+ def to_s
41
+ "multiplexed(#{@service_name=@protocol.to_s})"
42
+ end
39
43
  end
40
- end
44
+ end
@@ -26,6 +26,12 @@ module Thrift
26
26
  @protocol_factory = protocol_factory ? protocol_factory : Thrift::BinaryProtocolFactory.new
27
27
  end
28
28
 
29
- def serve; nil; end
29
+ def serve
30
+ raise NotImplementedError
31
+ end
32
+
33
+ def to_s
34
+ "server(#{@protocol_factory.to_s}(#{@transport_factory.to_s}(#{@server_transport.to_s})))"
35
+ end
30
36
  end
31
- end
37
+ end
@@ -39,5 +39,9 @@ module Thrift
39
39
  @server_transport.close
40
40
  end
41
41
  end
42
+
43
+ def to_s
44
+ "simple(#{super.to_s})"
45
+ end
42
46
  end
43
- end
47
+ end
@@ -71,5 +71,9 @@ module Thrift
71
71
  @server_transport.close
72
72
  end
73
73
  end
74
+
75
+ def to_s
76
+ "threadpool(#{super.to_s})"
77
+ end
74
78
  end
75
- end
79
+ end
@@ -43,5 +43,9 @@ module Thrift
43
43
  @server_transport.close
44
44
  end
45
45
  end
46
+
47
+ def to_s
48
+ "threaded(#{super.to_s})"
49
+ end
46
50
  end
47
- end
51
+ end
@@ -34,4 +34,4 @@ module Thrift
34
34
  raise NotImplementedError
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -99,11 +99,19 @@ module Thrift
99
99
  alias_method :<<, :write
100
100
 
101
101
  def flush; end
102
+
103
+ def to_s
104
+ "base"
105
+ end
102
106
  end
103
107
 
104
108
  class BaseTransportFactory
105
109
  def get_transport(trans)
106
110
  return trans
107
111
  end
112
+
113
+ def to_s
114
+ "base"
115
+ end
108
116
  end
109
117
  end
@@ -104,11 +104,19 @@ module Thrift
104
104
 
105
105
  @transport.flush
106
106
  end
107
+
108
+ def to_s
109
+ "buffered(#{@transport.to_s})"
110
+ end
107
111
  end
108
112
 
109
113
  class BufferedTransportFactory < BaseTransportFactory
110
114
  def get_transport(transport)
111
115
  return BufferedTransport.new(transport)
112
116
  end
117
+
118
+ def to_s
119
+ "buffered"
120
+ end
113
121
  end
114
- end
122
+ end
@@ -99,6 +99,10 @@ module Thrift
99
99
  @wbuf = Bytes.empty_byte_buffer
100
100
  end
101
101
 
102
+ def to_s
103
+ "framed(#{@transport.to_s})"
104
+ end
105
+
102
106
  private
103
107
 
104
108
  def read_frame
@@ -113,5 +117,9 @@ module Thrift
113
117
  def get_transport(transport)
114
118
  return FramedTransport.new(transport)
115
119
  end
120
+
121
+ def to_s
122
+ "framed"
123
+ end
116
124
  end
117
- end
125
+ end
@@ -53,5 +53,9 @@ module Thrift
53
53
  ensure
54
54
  @outbuf = Bytes.empty_byte_buffer
55
55
  end
56
+
57
+ def to_s
58
+ "@{self.url}"
59
+ end
56
60
  end
57
61
  end
@@ -35,5 +35,8 @@ module Thrift
35
35
  def write(buf); @output.write(Bytes.force_binary_encoding(buf)) end
36
36
  def close; @input.close; @output.close end
37
37
  def to_io; @input end # we're assuming this is used in a IO.select for reading
38
+ def to_s
39
+ "iostream(input=#{@input.to_s},output=#{@output.to_s})"
40
+ end
38
41
  end
39
- end
42
+ end
@@ -121,5 +121,9 @@ module Thrift
121
121
  end
122
122
  out.join(" ")
123
123
  end
124
+
125
+ def to_s
126
+ "memory"
127
+ end
124
128
  end
125
129
  end
@@ -59,5 +59,10 @@ module Thrift
59
59
  end
60
60
 
61
61
  alias to_io handle
62
+
63
+ def to_s
64
+ "socket(#{@host}:#{@port})"
65
+ end
66
+
62
67
  end
63
- end
68
+ end
@@ -134,8 +134,10 @@ module Thrift
134
134
  @handle = nil
135
135
  end
136
136
 
137
- def to_io
138
- @handle
137
+ alias to_io handle
138
+
139
+ def to_s
140
+ "socket(#{@host}:#{@port})"
139
141
  end
140
142
  end
141
143
  end
@@ -33,5 +33,9 @@ module Thrift
33
33
  socket = TCPServer.new(@host, @port)
34
34
  @handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
35
35
  end
36
+
37
+ def to_s
38
+ "ssl(#{super.to_s})"
39
+ end
36
40
  end
37
41
  end
@@ -43,5 +43,9 @@ module Thrift
43
43
  raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
44
44
  end
45
45
  end
46
+
47
+ def to_s
48
+ "ssl(#{super.to_s})"
49
+ end
46
50
  end
47
51
  end
@@ -56,5 +56,9 @@ module Thrift
56
56
  end
57
57
 
58
58
  alias to_io handle
59
+
60
+ def to_s
61
+ "domain(#{@path})"
62
+ end
59
63
  end
60
- end
64
+ end
@@ -36,5 +36,9 @@ module Thrift
36
36
  raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
37
37
  end
38
38
  end
39
+
40
+ def to_s
41
+ "domain(#{@path})"
42
+ end
39
43
  end
40
- end
44
+ end
@@ -22,41 +22,46 @@ require 'spec_helper'
22
22
  describe 'BaseProtocol' do
23
23
 
24
24
  before(:each) do
25
- @trans = mock("MockTransport")
25
+ @trans = double("MockTransport")
26
26
  @prot = Thrift::BaseProtocol.new(@trans)
27
27
  end
28
28
 
29
29
  describe Thrift::BaseProtocol do
30
30
  # most of the methods are stubs, so we can ignore them
31
31
 
32
+ it "should provide a reasonable to_s" do
33
+ expect(@trans).to receive(:to_s).once.and_return("trans")
34
+ expect(@prot.to_s).to eq("trans")
35
+ end
36
+
32
37
  it "should make trans accessible" do
33
- @prot.trans.should eql(@trans)
38
+ expect(@prot.trans).to eql(@trans)
34
39
  end
35
40
 
36
41
  it 'should write out a field nicely (deprecated write_field signature)' do
37
- @prot.should_receive(:write_field_begin).with('field', 'type', 'fid').ordered
38
- @prot.should_receive(:write_type).with({:name => 'field', :type => 'type'}, 'value').ordered
39
- @prot.should_receive(:write_field_end).ordered
42
+ expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
43
+ expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type'}, 'value').ordered
44
+ expect(@prot).to receive(:write_field_end).ordered
40
45
  @prot.write_field('field', 'type', 'fid', 'value')
41
46
  end
42
47
 
43
48
  it 'should write out a field nicely' do
44
- @prot.should_receive(:write_field_begin).with('field', 'type', 'fid').ordered
45
- @prot.should_receive(:write_type).with({:name => 'field', :type => 'type', :binary => false}, 'value').ordered
46
- @prot.should_receive(:write_field_end).ordered
49
+ expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
50
+ expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type', :binary => false}, 'value').ordered
51
+ expect(@prot).to receive(:write_field_end).ordered
47
52
  @prot.write_field({:name => 'field', :type => 'type', :binary => false}, 'fid', 'value')
48
53
  end
49
54
 
50
55
  it 'should write out the different types (deprecated write_type signature)' do
51
- @prot.should_receive(:write_bool).with('bool').ordered
52
- @prot.should_receive(:write_byte).with('byte').ordered
53
- @prot.should_receive(:write_double).with('double').ordered
54
- @prot.should_receive(:write_i16).with('i16').ordered
55
- @prot.should_receive(:write_i32).with('i32').ordered
56
- @prot.should_receive(:write_i64).with('i64').ordered
57
- @prot.should_receive(:write_string).with('string').ordered
58
- struct = mock('Struct')
59
- struct.should_receive(:write).with(@prot).ordered
56
+ expect(@prot).to receive(:write_bool).with('bool').ordered
57
+ expect(@prot).to receive(:write_byte).with('byte').ordered
58
+ expect(@prot).to receive(:write_double).with('double').ordered
59
+ expect(@prot).to receive(:write_i16).with('i16').ordered
60
+ expect(@prot).to receive(:write_i32).with('i32').ordered
61
+ expect(@prot).to receive(:write_i64).with('i64').ordered
62
+ expect(@prot).to receive(:write_string).with('string').ordered
63
+ struct = double('Struct')
64
+ expect(struct).to receive(:write).with(@prot).ordered
60
65
  @prot.write_type(Thrift::Types::BOOL, 'bool')
61
66
  @prot.write_type(Thrift::Types::BYTE, 'byte')
62
67
  @prot.write_type(Thrift::Types::DOUBLE, 'double')
@@ -72,16 +77,16 @@ describe 'BaseProtocol' do
72
77
  end
73
78
 
74
79
  it 'should write out the different types' do
75
- @prot.should_receive(:write_bool).with('bool').ordered
76
- @prot.should_receive(:write_byte).with('byte').ordered
77
- @prot.should_receive(:write_double).with('double').ordered
78
- @prot.should_receive(:write_i16).with('i16').ordered
79
- @prot.should_receive(:write_i32).with('i32').ordered
80
- @prot.should_receive(:write_i64).with('i64').ordered
81
- @prot.should_receive(:write_string).with('string').ordered
82
- @prot.should_receive(:write_binary).with('binary').ordered
83
- struct = mock('Struct')
84
- struct.should_receive(:write).with(@prot).ordered
80
+ expect(@prot).to receive(:write_bool).with('bool').ordered
81
+ expect(@prot).to receive(:write_byte).with('byte').ordered
82
+ expect(@prot).to receive(:write_double).with('double').ordered
83
+ expect(@prot).to receive(:write_i16).with('i16').ordered
84
+ expect(@prot).to receive(:write_i32).with('i32').ordered
85
+ expect(@prot).to receive(:write_i64).with('i64').ordered
86
+ expect(@prot).to receive(:write_string).with('string').ordered
87
+ expect(@prot).to receive(:write_binary).with('binary').ordered
88
+ struct = double('Struct')
89
+ expect(struct).to receive(:write).with(@prot).ordered
85
90
  @prot.write_type({:type => Thrift::Types::BOOL}, 'bool')
86
91
  @prot.write_type({:type => Thrift::Types::BYTE}, 'byte')
87
92
  @prot.write_type({:type => Thrift::Types::DOUBLE}, 'double')
@@ -98,13 +103,13 @@ describe 'BaseProtocol' do
98
103
  end
99
104
 
100
105
  it 'should read the different types (deprecated read_type signature)' do
101
- @prot.should_receive(:read_bool).ordered
102
- @prot.should_receive(:read_byte).ordered
103
- @prot.should_receive(:read_i16).ordered
104
- @prot.should_receive(:read_i32).ordered
105
- @prot.should_receive(:read_i64).ordered
106
- @prot.should_receive(:read_double).ordered
107
- @prot.should_receive(:read_string).ordered
106
+ expect(@prot).to receive(:read_bool).ordered
107
+ expect(@prot).to receive(:read_byte).ordered
108
+ expect(@prot).to receive(:read_i16).ordered
109
+ expect(@prot).to receive(:read_i32).ordered
110
+ expect(@prot).to receive(:read_i64).ordered
111
+ expect(@prot).to receive(:read_double).ordered
112
+ expect(@prot).to receive(:read_string).ordered
108
113
  @prot.read_type(Thrift::Types::BOOL)
109
114
  @prot.read_type(Thrift::Types::BYTE)
110
115
  @prot.read_type(Thrift::Types::I16)
@@ -120,14 +125,14 @@ describe 'BaseProtocol' do
120
125
  end
121
126
 
122
127
  it 'should read the different types' do
123
- @prot.should_receive(:read_bool).ordered
124
- @prot.should_receive(:read_byte).ordered
125
- @prot.should_receive(:read_i16).ordered
126
- @prot.should_receive(:read_i32).ordered
127
- @prot.should_receive(:read_i64).ordered
128
- @prot.should_receive(:read_double).ordered
129
- @prot.should_receive(:read_string).ordered
130
- @prot.should_receive(:read_binary).ordered
128
+ expect(@prot).to receive(:read_bool).ordered
129
+ expect(@prot).to receive(:read_byte).ordered
130
+ expect(@prot).to receive(:read_i16).ordered
131
+ expect(@prot).to receive(:read_i32).ordered
132
+ expect(@prot).to receive(:read_i64).ordered
133
+ expect(@prot).to receive(:read_double).ordered
134
+ expect(@prot).to receive(:read_string).ordered
135
+ expect(@prot).to receive(:read_binary).ordered
131
136
  @prot.read_type({:type => Thrift::Types::BOOL})
132
137
  @prot.read_type({:type => Thrift::Types::BYTE})
133
138
  @prot.read_type({:type => Thrift::Types::I16})
@@ -144,13 +149,13 @@ describe 'BaseProtocol' do
144
149
  end
145
150
 
146
151
  it "should skip the basic types" do
147
- @prot.should_receive(:read_bool).ordered
148
- @prot.should_receive(:read_byte).ordered
149
- @prot.should_receive(:read_i16).ordered
150
- @prot.should_receive(:read_i32).ordered
151
- @prot.should_receive(:read_i64).ordered
152
- @prot.should_receive(:read_double).ordered
153
- @prot.should_receive(:read_string).ordered
152
+ expect(@prot).to receive(:read_bool).ordered
153
+ expect(@prot).to receive(:read_byte).ordered
154
+ expect(@prot).to receive(:read_i16).ordered
155
+ expect(@prot).to receive(:read_i32).ordered
156
+ expect(@prot).to receive(:read_i64).ordered
157
+ expect(@prot).to receive(:read_double).ordered
158
+ expect(@prot).to receive(:read_string).ordered
154
159
  @prot.skip(Thrift::Types::BOOL)
155
160
  @prot.skip(Thrift::Types::BYTE)
156
161
  @prot.skip(Thrift::Types::I16)
@@ -158,52 +163,51 @@ describe 'BaseProtocol' do
158
163
  @prot.skip(Thrift::Types::I64)
159
164
  @prot.skip(Thrift::Types::DOUBLE)
160
165
  @prot.skip(Thrift::Types::STRING)
161
- @prot.skip(Thrift::Types::STOP) # should do absolutely nothing
162
166
  end
163
167
 
164
168
  it "should skip structs" do
165
169
  real_skip = @prot.method(:skip)
166
- @prot.should_receive(:read_struct_begin).ordered
167
- @prot.should_receive(:read_field_begin).exactly(4).times.and_return(
170
+ expect(@prot).to receive(:read_struct_begin).ordered
171
+ expect(@prot).to receive(:read_field_begin).exactly(4).times.and_return(
168
172
  ['field 1', Thrift::Types::STRING, 1],
169
173
  ['field 2', Thrift::Types::I32, 2],
170
174
  ['field 3', Thrift::Types::MAP, 3],
171
175
  [nil, Thrift::Types::STOP, 0]
172
176
  )
173
- @prot.should_receive(:read_field_end).exactly(3).times
174
- @prot.should_receive(:read_string).exactly(3).times
175
- @prot.should_receive(:read_i32).ordered
176
- @prot.should_receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRING, 1])
177
+ expect(@prot).to receive(:read_field_end).exactly(3).times
178
+ expect(@prot).to receive(:read_string).exactly(3).times
179
+ expect(@prot).to receive(:read_i32).ordered
180
+ expect(@prot).to receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRING, 1])
177
181
  # @prot.should_receive(:read_string).exactly(2).times
178
- @prot.should_receive(:read_map_end).ordered
179
- @prot.should_receive(:read_struct_end).ordered
182
+ expect(@prot).to receive(:read_map_end).ordered
183
+ expect(@prot).to receive(:read_struct_end).ordered
180
184
  real_skip.call(Thrift::Types::STRUCT)
181
185
  end
182
186
 
183
187
  it "should skip maps" do
184
188
  real_skip = @prot.method(:skip)
185
- @prot.should_receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRUCT, 1])
186
- @prot.should_receive(:read_string).ordered
187
- @prot.should_receive(:read_struct_begin).ordered.and_return(["some_struct"])
188
- @prot.should_receive(:read_field_begin).ordered.and_return([nil, Thrift::Types::STOP, nil]);
189
- @prot.should_receive(:read_struct_end).ordered
190
- @prot.should_receive(:read_map_end).ordered
189
+ expect(@prot).to receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRUCT, 1])
190
+ expect(@prot).to receive(:read_string).ordered
191
+ expect(@prot).to receive(:read_struct_begin).ordered.and_return(["some_struct"])
192
+ expect(@prot).to receive(:read_field_begin).ordered.and_return([nil, Thrift::Types::STOP, nil]);
193
+ expect(@prot).to receive(:read_struct_end).ordered
194
+ expect(@prot).to receive(:read_map_end).ordered
191
195
  real_skip.call(Thrift::Types::MAP)
192
196
  end
193
197
 
194
198
  it "should skip sets" do
195
199
  real_skip = @prot.method(:skip)
196
- @prot.should_receive(:read_set_begin).ordered.and_return([Thrift::Types::I64, 9])
197
- @prot.should_receive(:read_i64).ordered.exactly(9).times
198
- @prot.should_receive(:read_set_end)
200
+ expect(@prot).to receive(:read_set_begin).ordered.and_return([Thrift::Types::I64, 9])
201
+ expect(@prot).to receive(:read_i64).ordered.exactly(9).times
202
+ expect(@prot).to receive(:read_set_end)
199
203
  real_skip.call(Thrift::Types::SET)
200
204
  end
201
205
 
202
206
  it "should skip lists" do
203
207
  real_skip = @prot.method(:skip)
204
- @prot.should_receive(:read_list_begin).ordered.and_return([Thrift::Types::DOUBLE, 11])
205
- @prot.should_receive(:read_double).ordered.exactly(11).times
206
- @prot.should_receive(:read_list_end)
208
+ expect(@prot).to receive(:read_list_begin).ordered.and_return([Thrift::Types::DOUBLE, 11])
209
+ expect(@prot).to receive(:read_double).ordered.exactly(11).times
210
+ expect(@prot).to receive(:read_list_end)
207
211
  real_skip.call(Thrift::Types::LIST)
208
212
  end
209
213
  end
@@ -211,7 +215,11 @@ describe 'BaseProtocol' do
211
215
  describe Thrift::BaseProtocolFactory do
212
216
  it "should raise NotImplementedError" do
213
217
  # returning nil since Protocol is just an abstract class
214
- lambda {Thrift::BaseProtocolFactory.new.get_protocol(mock("MockTransport"))}.should raise_error(NotImplementedError)
218
+ expect {Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport"))}.to raise_error(NotImplementedError)
219
+ end
220
+
221
+ it "should provide a reasonable to_s" do
222
+ expect(Thrift::BaseProtocolFactory.new.to_s).to eq("base")
215
223
  end
216
224
  end
217
225
  end