upfluence-thrift 2.6.8 → 2.7.4

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 (167) hide show
  1. checksums.yaml +4 -4
  2. data/benchmark/{gen-rb/benchmark_constants.rb → benchmark_constants.rb} +1 -1
  3. data/benchmark/{gen-rb/benchmark_service.rb → benchmark_service.rb} +2 -2
  4. data/benchmark/{gen-rb/benchmark_types.rb → benchmark_types.rb} +1 -1
  5. data/ext/struct.c +5 -1
  6. data/lib/thrift/base_stream.rb +85 -0
  7. data/lib/thrift/bidi_stream.rb +183 -0
  8. data/lib/thrift/client.rb +84 -17
  9. data/lib/thrift/inbound_stream.rb +72 -0
  10. data/lib/thrift/middleware.rb +42 -0
  11. data/lib/thrift/outbound_stream.rb +52 -0
  12. data/lib/thrift/processor.rb +287 -47
  13. data/lib/thrift/protocol/base_protocol.rb +35 -33
  14. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  15. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  16. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  17. data/lib/thrift/protocol/json_protocol.rb +21 -4
  18. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  19. data/lib/thrift/server/base_server.rb +8 -2
  20. data/lib/thrift/server/nonblocking_server.rb +5 -4
  21. data/lib/thrift/server/simple_server.rb +5 -1
  22. data/lib/thrift/server/thread_pool_server.rb +5 -1
  23. data/lib/thrift/server/threaded_server.rb +5 -1
  24. data/lib/thrift/transport/base_server_transport.rb +1 -1
  25. data/lib/thrift/transport/base_transport.rb +8 -0
  26. data/lib/thrift/transport/buffered_transport.rb +9 -1
  27. data/lib/thrift/transport/framed_transport.rb +9 -1
  28. data/lib/thrift/transport/http_client_transport.rb +4 -0
  29. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  30. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  31. data/lib/thrift/transport/server_socket.rb +5 -0
  32. data/lib/thrift/transport/socket.rb +21 -17
  33. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  34. data/lib/thrift/transport/ssl_socket.rb +51 -0
  35. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  36. data/lib/thrift/transport/unix_socket.rb +5 -1
  37. data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
  38. data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
  39. data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
  40. data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
  41. data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
  42. data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
  43. data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
  44. data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
  45. data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
  46. data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
  47. data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
  48. data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
  49. data/lib/thrift/types/core/core_constants.rb +15 -0
  50. data/lib/thrift/types/core/core_types.rb +58 -0
  51. data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
  52. data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
  53. data/lib/thrift/types/known/any/any_constants.rb +1 -1
  54. data/lib/thrift/types/known/any/any_types.rb +2 -2
  55. data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
  56. data/lib/thrift/types/known/duration/duration_types.rb +2 -2
  57. data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
  58. data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
  59. data/lib/thrift/types/plugin/plugin.rb +139 -0
  60. data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
  61. data/lib/thrift/types/plugin/plugin_types.rb +106 -0
  62. data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
  63. data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
  64. data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
  65. data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
  66. data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
  67. data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
  68. data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
  69. data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
  70. data/lib/thrift/types/value/value_constants.rb +1 -1
  71. data/lib/thrift/types/value/value_types.rb +50 -51
  72. data/lib/thrift/types.rb +11 -3
  73. data/lib/thrift/union.rb +3 -6
  74. data/lib/thrift.rb +6 -0
  75. data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
  76. data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
  77. data/lib/types/annotation/naming/naming_constants.rb +16 -0
  78. data/lib/types/annotation/naming/naming_types.rb +57 -0
  79. data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
  80. data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
  81. data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
  82. data/lib/types/constant_definition/constant_definition_types.rb +290 -0
  83. data/lib/types/core/core_constants.rb +14 -0
  84. data/lib/types/core/core_types.rb +56 -0
  85. data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
  86. data/lib/types/enum_definition/enum_definition_types.rb +104 -0
  87. data/lib/types/known/any/any_constants.rb +16 -0
  88. data/lib/types/known/any/any_types.rb +59 -0
  89. data/lib/types/known/duration/duration_constants.rb +16 -0
  90. data/lib/types/known/duration/duration_types.rb +59 -0
  91. data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
  92. data/lib/types/known/timestamp/timestamp_types.rb +59 -0
  93. data/lib/types/plugin/plugin.rb +137 -0
  94. data/lib/types/plugin/plugin_constants.rb +14 -0
  95. data/lib/types/plugin/plugin_types.rb +104 -0
  96. data/lib/types/program_definition/program_definition_constants.rb +14 -0
  97. data/lib/types/program_definition/program_definition_types.rb +135 -0
  98. data/lib/types/service_definition/service_definition_constants.rb +14 -0
  99. data/lib/types/service_definition/service_definition_types.rb +158 -0
  100. data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
  101. data/lib/types/struct_definition/struct_definition_types.rb +155 -0
  102. data/lib/types/type_definition/type_definition_constants.rb +14 -0
  103. data/lib/types/type_definition/type_definition_types.rb +240 -0
  104. data/lib/types/value/value_constants.rb +14 -0
  105. data/lib/types/value/value_types.rb +330 -0
  106. data/spec/{gen-rb/base → base}/base_service.rb +2 -2
  107. data/spec/{gen-rb/base → base}/base_service_constants.rb +1 -1
  108. data/spec/{gen-rb/base → base}/base_service_types.rb +1 -1
  109. data/spec/base_protocol_spec.rb +79 -71
  110. data/spec/base_transport_spec.rb +155 -117
  111. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  112. data/spec/binary_protocol_spec.rb +16 -8
  113. data/spec/binary_protocol_spec_shared.rb +77 -77
  114. data/spec/bytes_spec.rb +38 -38
  115. data/spec/client_spec.rb +48 -50
  116. data/spec/compact_protocol_spec.rb +59 -46
  117. data/spec/exception_spec.rb +54 -54
  118. data/spec/{gen-rb/extended → extended}/extended_service.rb +2 -2
  119. data/spec/{gen-rb/extended → extended}/extended_service_constants.rb +1 -1
  120. data/spec/{gen-rb/extended → extended}/extended_service_types.rb +1 -1
  121. data/spec/flat_spec.rb +5 -5
  122. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +4 -4
  123. data/spec/gen-rb/flat/referenced_constants.rb +1 -1
  124. data/spec/gen-rb/flat/referenced_types.rb +1 -1
  125. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +1 -1
  126. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +1 -1
  127. data/spec/http_client_spec.rb +96 -43
  128. data/spec/json_protocol_spec.rb +170 -131
  129. data/spec/namespaced_spec.rb +24 -27
  130. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/namespaced_nonblocking_service.rb +4 -4
  131. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_constants.rb +1 -1
  132. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_types.rb +1 -1
  133. data/spec/nonblocking_server_spec.rb +16 -16
  134. data/spec/{gen-rb/nonblocking_service.rb → nonblocking_service.rb} +4 -4
  135. data/spec/{gen-rb/other_namespace → other_namespace}/referenced_constants.rb +1 -1
  136. data/spec/{gen-rb/other_namespace → other_namespace}/referenced_types.rb +1 -1
  137. data/spec/processor_spec.rb +42 -31
  138. data/spec/rack_application_spec.rb +22 -26
  139. data/spec/serializer_spec.rb +20 -20
  140. data/spec/server_socket_spec.rb +27 -22
  141. data/spec/server_spec.rb +91 -51
  142. data/spec/socket_spec.rb +23 -16
  143. data/spec/socket_spec_shared.rb +31 -31
  144. data/spec/spec_helper.rb +1 -1
  145. data/spec/ssl_server_socket_spec.rb +34 -0
  146. data/spec/ssl_socket_spec.rb +78 -0
  147. data/spec/streaming_spec.rb +442 -0
  148. data/spec/struct_nested_containers_spec.rb +24 -24
  149. data/spec/struct_spec.rb +120 -120
  150. data/spec/thin_http_server_spec.rb +71 -28
  151. data/spec/{gen-rb/thrift_spec_constants.rb → thrift_spec_constants.rb} +1 -1
  152. data/spec/{gen-rb/thrift_spec_types.rb → thrift_spec_types.rb} +16 -16
  153. data/spec/types/known/any_spec.rb +2 -2
  154. data/spec/types/known/duration_spec.rb +1 -1
  155. data/spec/types/known/timestamp_spec.rb +1 -1
  156. data/spec/types/value_spec.rb +2 -1
  157. data/spec/types_spec.rb +56 -53
  158. data/spec/union_spec.rb +51 -40
  159. data/spec/unix_socket_spec.rb +43 -34
  160. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +267 -260
  161. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +1481 -1416
  162. data/test/debug_proto/gen-rb/empty_service.rb +31 -27
  163. data/test/debug_proto/gen-rb/inherited.rb +102 -98
  164. data/test/debug_proto/gen-rb/reverse_order_service.rb +112 -108
  165. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +99 -95
  166. data/test/debug_proto/gen-rb/srv.rb +525 -406
  167. metadata +178 -41
@@ -47,252 +47,257 @@ describe 'JsonProtocol' do
47
47
 
48
48
  it "should write json escaped char" do
49
49
  @prot.write_json_escape_char("\n")
50
- @trans.read(@trans.available).should == '\u000a'
50
+ expect(@trans.read(@trans.available)).to eq('\u000a')
51
51
 
52
52
  @prot.write_json_escape_char(" ")
53
- @trans.read(@trans.available).should == '\u0020'
53
+ expect(@trans.read(@trans.available)).to eq('\u0020')
54
54
  end
55
55
 
56
56
  it "should write json char" do
57
57
  @prot.write_json_char("\n")
58
- @trans.read(@trans.available).should == '\\n'
58
+ expect(@trans.read(@trans.available)).to eq('\\n')
59
59
 
60
60
  @prot.write_json_char(" ")
61
- @trans.read(@trans.available).should == ' '
61
+ expect(@trans.read(@trans.available)).to eq(' ')
62
62
 
63
63
  @prot.write_json_char("\\")
64
- @trans.read(@trans.available).should == "\\\\"
64
+ expect(@trans.read(@trans.available)).to eq("\\\\")
65
65
 
66
66
  @prot.write_json_char("@")
67
- @trans.read(@trans.available).should == '@'
67
+ expect(@trans.read(@trans.available)).to eq('@')
68
68
  end
69
69
 
70
70
  it "should write json string" do
71
71
  @prot.write_json_string("this is a \\ json\nstring")
72
- @trans.read(@trans.available).should == "\"this is a \\\\ json\\nstring\""
72
+ expect(@trans.read(@trans.available)).to eq("\"this is a \\\\ json\\nstring\"")
73
73
  end
74
74
 
75
75
  it "should write json base64" do
76
76
  @prot.write_json_base64("this is a base64 string")
77
- @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
77
+ expect(@trans.read(@trans.available)).to eq("\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\"")
78
78
  end
79
79
 
80
80
  it "should write json integer" do
81
81
  @prot.write_json_integer(45)
82
- @trans.read(@trans.available).should == "45"
82
+ expect(@trans.read(@trans.available)).to eq("45")
83
83
 
84
84
  @prot.write_json_integer(33000)
85
- @trans.read(@trans.available).should == "33000"
85
+ expect(@trans.read(@trans.available)).to eq("33000")
86
86
 
87
87
  @prot.write_json_integer(3000000000)
88
- @trans.read(@trans.available).should == "3000000000"
88
+ expect(@trans.read(@trans.available)).to eq("3000000000")
89
89
 
90
90
  @prot.write_json_integer(6000000000)
91
- @trans.read(@trans.available).should == "6000000000"
91
+ expect(@trans.read(@trans.available)).to eq("6000000000")
92
92
  end
93
93
 
94
94
  it "should write json double" do
95
95
  @prot.write_json_double(12.3)
96
- @trans.read(@trans.available).should == "12.3"
96
+ expect(@trans.read(@trans.available)).to eq("12.3")
97
97
 
98
98
  @prot.write_json_double(-3.21)
99
- @trans.read(@trans.available).should == "-3.21"
99
+ expect(@trans.read(@trans.available)).to eq("-3.21")
100
100
 
101
101
  @prot.write_json_double(((+1.0/0.0)/(+1.0/0.0)))
102
- @trans.read(@trans.available).should == "\"NaN\""
102
+ expect(@trans.read(@trans.available)).to eq("\"NaN\"")
103
103
 
104
104
  @prot.write_json_double((+1.0/0.0))
105
- @trans.read(@trans.available).should == "\"Infinity\""
105
+ expect(@trans.read(@trans.available)).to eq("\"Infinity\"")
106
106
 
107
107
  @prot.write_json_double((-1.0/0.0))
108
- @trans.read(@trans.available).should == "\"-Infinity\""
108
+ expect(@trans.read(@trans.available)).to eq("\"-Infinity\"")
109
109
  end
110
110
 
111
111
  it "should write json object start" do
112
112
  @prot.write_json_object_start
113
- @trans.read(@trans.available).should == "{"
113
+ expect(@trans.read(@trans.available)).to eq("{")
114
114
  end
115
115
 
116
116
  it "should write json object end" do
117
117
  @prot.write_json_object_end
118
- @trans.read(@trans.available).should == "}"
118
+ expect(@trans.read(@trans.available)).to eq("}")
119
119
  end
120
120
 
121
121
  it "should write json array start" do
122
122
  @prot.write_json_array_start
123
- @trans.read(@trans.available).should == "["
123
+ expect(@trans.read(@trans.available)).to eq("[")
124
124
  end
125
125
 
126
126
  it "should write json array end" do
127
127
  @prot.write_json_array_end
128
- @trans.read(@trans.available).should == "]"
128
+ expect(@trans.read(@trans.available)).to eq("]")
129
129
  end
130
130
 
131
131
  it "should write message begin" do
132
132
  @prot.write_message_begin("name", 12, 32)
133
- @trans.read(@trans.available).should == "[1,\"name\",12,32"
133
+ expect(@trans.read(@trans.available)).to eq("[1,\"name\",12,32")
134
134
  end
135
135
 
136
136
  it "should write message end" do
137
137
  @prot.write_message_end
138
- @trans.read(@trans.available).should == "]"
138
+ expect(@trans.read(@trans.available)).to eq("]")
139
139
  end
140
140
 
141
141
  it "should write struct begin" do
142
142
  @prot.write_struct_begin("name")
143
- @trans.read(@trans.available).should == "{"
143
+ expect(@trans.read(@trans.available)).to eq("{")
144
144
  end
145
145
 
146
146
  it "should write struct end" do
147
147
  @prot.write_struct_end
148
- @trans.read(@trans.available).should == "}"
148
+ expect(@trans.read(@trans.available)).to eq("}")
149
149
  end
150
150
 
151
151
  it "should write field begin" do
152
152
  @prot.write_field_begin("name", Thrift::Types::STRUCT, 32)
153
- @trans.read(@trans.available).should == "32{\"rec\""
153
+ expect(@trans.read(@trans.available)).to eq("32{\"rec\"")
154
154
  end
155
155
 
156
156
  it "should write field end" do
157
157
  @prot.write_field_end
158
- @trans.read(@trans.available).should == "}"
158
+ expect(@trans.read(@trans.available)).to eq("}")
159
159
  end
160
160
 
161
161
  it "should write field stop" do
162
162
  @prot.write_field_stop
163
- @trans.read(@trans.available).should == ""
163
+ expect(@trans.read(@trans.available)).to eq("")
164
164
  end
165
165
 
166
166
  it "should write map begin" do
167
167
  @prot.write_map_begin(Thrift::Types::STRUCT, Thrift::Types::LIST, 32)
168
- @trans.read(@trans.available).should == "[\"rec\",\"lst\",32,{"
168
+ expect(@trans.read(@trans.available)).to eq("[\"rec\",\"lst\",32,{")
169
169
  end
170
170
 
171
171
  it "should write map end" do
172
172
  @prot.write_map_end
173
- @trans.read(@trans.available).should == "}]"
173
+ expect(@trans.read(@trans.available)).to eq("}]")
174
174
  end
175
175
 
176
176
  it "should write list begin" do
177
177
  @prot.write_list_begin(Thrift::Types::STRUCT, 32)
178
- @trans.read(@trans.available).should == "[\"rec\",32"
178
+ expect(@trans.read(@trans.available)).to eq("[\"rec\",32")
179
179
  end
180
180
 
181
181
  it "should write list end" do
182
182
  @prot.write_list_end
183
- @trans.read(@trans.available).should == "]"
183
+ expect(@trans.read(@trans.available)).to eq("]")
184
184
  end
185
185
 
186
186
  it "should write set begin" do
187
187
  @prot.write_set_begin(Thrift::Types::STRUCT, 32)
188
- @trans.read(@trans.available).should == "[\"rec\",32"
188
+ expect(@trans.read(@trans.available)).to eq("[\"rec\",32")
189
189
  end
190
190
 
191
191
  it "should write set end" do
192
192
  @prot.write_set_end
193
- @trans.read(@trans.available).should == "]"
193
+ expect(@trans.read(@trans.available)).to eq("]")
194
194
  end
195
195
 
196
196
  it "should write bool" do
197
197
  @prot.write_bool(true)
198
- @trans.read(@trans.available).should == "1"
198
+ expect(@trans.read(@trans.available)).to eq("1")
199
199
 
200
200
  @prot.write_bool(false)
201
- @trans.read(@trans.available).should == "0"
201
+ expect(@trans.read(@trans.available)).to eq("0")
202
202
  end
203
203
 
204
204
  it "should write byte" do
205
205
  @prot.write_byte(100)
206
- @trans.read(@trans.available).should == "100"
206
+ expect(@trans.read(@trans.available)).to eq("100")
207
207
  end
208
208
 
209
209
  it "should write i16" do
210
210
  @prot.write_i16(1000)
211
- @trans.read(@trans.available).should == "1000"
211
+ expect(@trans.read(@trans.available)).to eq("1000")
212
212
  end
213
213
 
214
214
  it "should write i32" do
215
215
  @prot.write_i32(3000000000)
216
- @trans.read(@trans.available).should == "3000000000"
216
+ expect(@trans.read(@trans.available)).to eq("3000000000")
217
217
  end
218
218
 
219
219
  it "should write i64" do
220
220
  @prot.write_i64(6000000000)
221
- @trans.read(@trans.available).should == "6000000000"
221
+ expect(@trans.read(@trans.available)).to eq("6000000000")
222
222
  end
223
223
 
224
224
  it "should write double" do
225
225
  @prot.write_double(1.23)
226
- @trans.read(@trans.available).should == "1.23"
226
+ expect(@trans.read(@trans.available)).to eq("1.23")
227
227
 
228
228
  @prot.write_double(-32.1)
229
- @trans.read(@trans.available).should == "-32.1"
229
+ expect(@trans.read(@trans.available)).to eq("-32.1")
230
230
 
231
231
  @prot.write_double(((+1.0/0.0)/(+1.0/0.0)))
232
- @trans.read(@trans.available).should == "\"NaN\""
232
+ expect(@trans.read(@trans.available)).to eq("\"NaN\"")
233
233
 
234
234
  @prot.write_double((+1.0/0.0))
235
- @trans.read(@trans.available).should == "\"Infinity\""
235
+ expect(@trans.read(@trans.available)).to eq("\"Infinity\"")
236
236
 
237
237
  @prot.write_double((-1.0/0.0))
238
- @trans.read(@trans.available).should == "\"-Infinity\""
238
+ expect(@trans.read(@trans.available)).to eq("\"-Infinity\"")
239
239
  end
240
240
 
241
241
  if RUBY_VERSION >= '1.9'
242
242
  it 'should write string' do
243
243
  @prot.write_string('this is a test string')
244
244
  a = @trans.read(@trans.available)
245
- a.should == '"this is a test string"'.force_encoding(Encoding::BINARY)
246
- a.encoding.should == Encoding::BINARY
245
+ expect(a).to eq('"this is a test string"'.force_encoding(Encoding::BINARY))
246
+ expect(a.encoding).to eq(Encoding::BINARY)
247
247
  end
248
248
 
249
249
  it 'should write string with unicode characters' do
250
250
  @prot.write_string("this is a test string with unicode characters: \u20AC \u20AD")
251
251
  a = @trans.read(@trans.available)
252
- a.should == "\"this is a test string with unicode characters: \u20AC \u20AD\"".force_encoding(Encoding::BINARY)
253
- a.encoding.should == Encoding::BINARY
252
+ expect(a).to eq("\"this is a test string with unicode characters: \u20AC \u20AD\"".force_encoding(Encoding::BINARY))
253
+ expect(a.encoding).to eq(Encoding::BINARY)
254
254
  end
255
255
  else
256
256
  it 'should write string' do
257
257
  @prot.write_string('this is a test string')
258
- @trans.read(@trans.available).should == '"this is a test string"'
258
+ expect(@trans.read(@trans.available)).to eq('"this is a test string"')
259
259
  end
260
260
  end
261
261
 
262
262
  it "should write binary" do
263
263
  @prot.write_binary("this is a base64 string")
264
- @trans.read(@trans.available).should == "\"\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\\n\"\""
264
+ expect(@trans.read(@trans.available)).to eq("\"dGhpcyBpcyBhIGJhc2U2NCBzdHJpbmc=\"")
265
+ end
266
+
267
+ it "should write long binary" do
268
+ @prot.write_binary((0...256).to_a.pack('C*'))
269
+ expect(@trans.read(@trans.available)).to eq("\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"")
265
270
  end
266
271
 
267
272
  it "should get type name for type id" do
268
273
  expect {@prot.get_type_name_for_type_id(Thrift::Types::STOP)}.to raise_error(NotImplementedError)
269
274
  expect {@prot.get_type_name_for_type_id(Thrift::Types::VOID)}.to raise_error(NotImplementedError)
270
- @prot.get_type_name_for_type_id(Thrift::Types::BOOL).should == "tf"
271
- @prot.get_type_name_for_type_id(Thrift::Types::BYTE).should == "i8"
272
- @prot.get_type_name_for_type_id(Thrift::Types::DOUBLE).should == "dbl"
273
- @prot.get_type_name_for_type_id(Thrift::Types::I16).should == "i16"
274
- @prot.get_type_name_for_type_id(Thrift::Types::I32).should == "i32"
275
- @prot.get_type_name_for_type_id(Thrift::Types::I64).should == "i64"
276
- @prot.get_type_name_for_type_id(Thrift::Types::STRING).should == "str"
277
- @prot.get_type_name_for_type_id(Thrift::Types::STRUCT).should == "rec"
278
- @prot.get_type_name_for_type_id(Thrift::Types::MAP).should == "map"
279
- @prot.get_type_name_for_type_id(Thrift::Types::SET).should == "set"
280
- @prot.get_type_name_for_type_id(Thrift::Types::LIST).should == "lst"
275
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::BOOL)).to eq("tf")
276
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::BYTE)).to eq("i8")
277
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::DOUBLE)).to eq("dbl")
278
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::I16)).to eq("i16")
279
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::I32)).to eq("i32")
280
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::I64)).to eq("i64")
281
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::STRING)).to eq("str")
282
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::STRUCT)).to eq("rec")
283
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::MAP)).to eq("map")
284
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::SET)).to eq("set")
285
+ expect(@prot.get_type_name_for_type_id(Thrift::Types::LIST)).to eq("lst")
281
286
  end
282
287
 
283
288
  it "should get type id for type name" do
284
289
  expect {@prot.get_type_id_for_type_name("pp")}.to raise_error(NotImplementedError)
285
- @prot.get_type_id_for_type_name("tf").should == Thrift::Types::BOOL
286
- @prot.get_type_id_for_type_name("i8").should == Thrift::Types::BYTE
287
- @prot.get_type_id_for_type_name("dbl").should == Thrift::Types::DOUBLE
288
- @prot.get_type_id_for_type_name("i16").should == Thrift::Types::I16
289
- @prot.get_type_id_for_type_name("i32").should == Thrift::Types::I32
290
- @prot.get_type_id_for_type_name("i64").should == Thrift::Types::I64
291
- @prot.get_type_id_for_type_name("str").should == Thrift::Types::STRING
292
- @prot.get_type_id_for_type_name("rec").should == Thrift::Types::STRUCT
293
- @prot.get_type_id_for_type_name("map").should == Thrift::Types::MAP
294
- @prot.get_type_id_for_type_name("set").should == Thrift::Types::SET
295
- @prot.get_type_id_for_type_name("lst").should == Thrift::Types::LIST
290
+ expect(@prot.get_type_id_for_type_name("tf")).to eq(Thrift::Types::BOOL)
291
+ expect(@prot.get_type_id_for_type_name("i8")).to eq(Thrift::Types::BYTE)
292
+ expect(@prot.get_type_id_for_type_name("dbl")).to eq(Thrift::Types::DOUBLE)
293
+ expect(@prot.get_type_id_for_type_name("i16")).to eq(Thrift::Types::I16)
294
+ expect(@prot.get_type_id_for_type_name("i32")).to eq(Thrift::Types::I32)
295
+ expect(@prot.get_type_id_for_type_name("i64")).to eq(Thrift::Types::I64)
296
+ expect(@prot.get_type_id_for_type_name("str")).to eq(Thrift::Types::STRING)
297
+ expect(@prot.get_type_id_for_type_name("rec")).to eq(Thrift::Types::STRUCT)
298
+ expect(@prot.get_type_id_for_type_name("map")).to eq(Thrift::Types::MAP)
299
+ expect(@prot.get_type_id_for_type_name("set")).to eq(Thrift::Types::SET)
300
+ expect(@prot.get_type_id_for_type_name("lst")).to eq(Thrift::Types::LIST)
296
301
  end
297
302
 
298
303
  it "should read json syntax char" do
@@ -304,47 +309,68 @@ describe 'JsonProtocol' do
304
309
 
305
310
  it "should read json escape char" do
306
311
  @trans.write('0054')
307
- @prot.read_json_escape_char.should == 'T'
312
+ expect(@prot.read_json_escape_char).to eq('T')
313
+
314
+ @trans.write("\"\\\"\"")
315
+ expect(@prot.read_json_string(false)).to eq("\"")
316
+
317
+ @trans.write("\"\\\\\"")
318
+ expect(@prot.read_json_string(false)).to eq("\\")
319
+
320
+ @trans.write("\"\\/\"")
321
+ expect(@prot.read_json_string(false)).to eq("\/")
322
+
323
+ @trans.write("\"\\b\"")
324
+ expect(@prot.read_json_string(false)).to eq("\b")
325
+
326
+ @trans.write("\"\\f\"")
327
+ expect(@prot.read_json_string(false)).to eq("\f")
328
+
329
+ @trans.write("\"\\n\"")
330
+ expect(@prot.read_json_string(false)).to eq("\n")
331
+
332
+ @trans.write("\"\\r\"")
333
+ expect(@prot.read_json_string(false)).to eq("\r")
334
+
335
+ @trans.write("\"\\t\"")
336
+ expect(@prot.read_json_string(false)).to eq("\t")
308
337
  end
309
338
 
310
339
  it "should read json string" do
311
340
  @trans.write("\"\\P")
312
341
  expect {@prot.read_json_string(false)}.to raise_error(Thrift::ProtocolException)
313
342
 
314
- @trans.write("\"\\n\"")
315
- @prot.read_json_string(false).should == "\\n"
316
-
317
343
  @trans.write("\"this is a test string\"")
318
- @prot.read_json_string.should == "this is a test string"
344
+ expect(@prot.read_json_string).to eq("this is a test string")
319
345
  end
320
346
 
321
347
  it "should read json base64" do
322
348
  @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
323
- @prot.read_json_base64.should == "this is a test string"
349
+ expect(@prot.read_json_base64).to eq("this is a test string")
324
350
  end
325
351
 
326
352
  it "should is json numeric" do
327
- @prot.is_json_numeric("A").should == false
328
- @prot.is_json_numeric("+").should == true
329
- @prot.is_json_numeric("-").should == true
330
- @prot.is_json_numeric(".").should == true
331
- @prot.is_json_numeric("0").should == true
332
- @prot.is_json_numeric("1").should == true
333
- @prot.is_json_numeric("2").should == true
334
- @prot.is_json_numeric("3").should == true
335
- @prot.is_json_numeric("4").should == true
336
- @prot.is_json_numeric("5").should == true
337
- @prot.is_json_numeric("6").should == true
338
- @prot.is_json_numeric("7").should == true
339
- @prot.is_json_numeric("8").should == true
340
- @prot.is_json_numeric("9").should == true
341
- @prot.is_json_numeric("E").should == true
342
- @prot.is_json_numeric("e").should == true
353
+ expect(@prot.is_json_numeric("A")).to eq(false)
354
+ expect(@prot.is_json_numeric("+")).to eq(true)
355
+ expect(@prot.is_json_numeric("-")).to eq(true)
356
+ expect(@prot.is_json_numeric(".")).to eq(true)
357
+ expect(@prot.is_json_numeric("0")).to eq(true)
358
+ expect(@prot.is_json_numeric("1")).to eq(true)
359
+ expect(@prot.is_json_numeric("2")).to eq(true)
360
+ expect(@prot.is_json_numeric("3")).to eq(true)
361
+ expect(@prot.is_json_numeric("4")).to eq(true)
362
+ expect(@prot.is_json_numeric("5")).to eq(true)
363
+ expect(@prot.is_json_numeric("6")).to eq(true)
364
+ expect(@prot.is_json_numeric("7")).to eq(true)
365
+ expect(@prot.is_json_numeric("8")).to eq(true)
366
+ expect(@prot.is_json_numeric("9")).to eq(true)
367
+ expect(@prot.is_json_numeric("E")).to eq(true)
368
+ expect(@prot.is_json_numeric("e")).to eq(true)
343
369
  end
344
370
 
345
371
  it "should read json numeric chars" do
346
372
  @trans.write("1.453E45T")
347
- @prot.read_json_numeric_chars.should == "1.453E45"
373
+ expect(@prot.read_json_numeric_chars).to eq("1.453E45")
348
374
  end
349
375
 
350
376
  it "should read json integer" do
@@ -353,7 +379,7 @@ describe 'JsonProtocol' do
353
379
  @prot.read_string
354
380
 
355
381
  @trans.write("1453T")
356
- @prot.read_json_integer.should == 1453
382
+ expect(@prot.read_json_integer).to eq(1453)
357
383
  end
358
384
 
359
385
  it "should read json double" do
@@ -365,37 +391,37 @@ describe 'JsonProtocol' do
365
391
  expect {@prot.read_json_double}.to raise_error(Thrift::ProtocolException)
366
392
 
367
393
  @trans.write("1.453e01\"\"")
368
- @prot.read_json_double.should == 14.53
394
+ expect(@prot.read_json_double).to eq(14.53)
369
395
  @prot.read_string
370
396
 
371
397
  @trans.write("\"NaN\"")
372
- @prot.read_json_double.nan?.should == true
398
+ expect(@prot.read_json_double.nan?).to eq(true)
373
399
 
374
400
  @trans.write("\"Infinity\"")
375
- @prot.read_json_double.should == +1.0/0.0
401
+ expect(@prot.read_json_double).to eq(+1.0/0.0)
376
402
 
377
403
  @trans.write("\"-Infinity\"")
378
- @prot.read_json_double.should == -1.0/0.0
404
+ expect(@prot.read_json_double).to eq(-1.0/0.0)
379
405
  end
380
406
 
381
407
  it "should read json object start" do
382
408
  @trans.write("{")
383
- @prot.read_json_object_start.should == nil
409
+ expect(@prot.read_json_object_start).to eq(nil)
384
410
  end
385
411
 
386
412
  it "should read json object end" do
387
413
  @trans.write("}")
388
- @prot.read_json_object_end.should == nil
414
+ expect(@prot.read_json_object_end).to eq(nil)
389
415
  end
390
416
 
391
417
  it "should read json array start" do
392
418
  @trans.write("[")
393
- @prot.read_json_array_start.should == nil
419
+ expect(@prot.read_json_array_start).to eq(nil)
394
420
  end
395
421
 
396
422
  it "should read json array end" do
397
423
  @trans.write("]")
398
- @prot.read_json_array_end.should == nil
424
+ expect(@prot.read_json_array_end).to eq(nil)
399
425
  end
400
426
 
401
427
  it "should read_message_begin" do
@@ -403,128 +429,141 @@ describe 'JsonProtocol' do
403
429
  expect {@prot.read_message_begin}.to raise_error(Thrift::ProtocolException)
404
430
 
405
431
  @trans.write("[1,\"name\",12,32\"\"")
406
- @prot.read_message_begin.should == ["name", 12, 32]
432
+ expect(@prot.read_message_begin).to eq(["name", 12, 32])
407
433
  end
408
434
 
409
435
  it "should read message end" do
410
436
  @trans.write("]")
411
- @prot.read_message_end.should == nil
437
+ expect(@prot.read_message_end).to eq(nil)
412
438
  end
413
439
 
414
440
  it "should read struct begin" do
415
441
  @trans.write("{")
416
- @prot.read_struct_begin.should == nil
442
+ expect(@prot.read_struct_begin).to eq(nil)
417
443
  end
418
444
 
419
445
  it "should read struct end" do
420
446
  @trans.write("}")
421
- @prot.read_struct_end.should == nil
447
+ expect(@prot.read_struct_end).to eq(nil)
422
448
  end
423
449
 
424
450
  it "should read field begin" do
425
451
  @trans.write("1{\"rec\"")
426
- @prot.read_field_begin.should == [nil, 12, 1]
452
+ expect(@prot.read_field_begin).to eq([nil, 12, 1])
427
453
  end
428
454
 
429
455
  it "should read field end" do
430
456
  @trans.write("}")
431
- @prot.read_field_end.should == nil
457
+ expect(@prot.read_field_end).to eq(nil)
432
458
  end
433
459
 
434
460
  it "should read map begin" do
435
461
  @trans.write("[\"rec\",\"lst\",2,{")
436
- @prot.read_map_begin.should == [12, 15, 2]
462
+ expect(@prot.read_map_begin).to eq([12, 15, 2])
437
463
  end
438
464
 
439
465
  it "should read map end" do
440
466
  @trans.write("}]")
441
- @prot.read_map_end.should == nil
467
+ expect(@prot.read_map_end).to eq(nil)
442
468
  end
443
469
 
444
470
  it "should read list begin" do
445
471
  @trans.write("[\"rec\",2\"\"")
446
- @prot.read_list_begin.should == [12, 2]
472
+ expect(@prot.read_list_begin).to eq([12, 2])
447
473
  end
448
474
 
449
475
  it "should read list end" do
450
476
  @trans.write("]")
451
- @prot.read_list_end.should == nil
477
+ expect(@prot.read_list_end).to eq(nil)
452
478
  end
453
479
 
454
480
  it "should read set begin" do
455
481
  @trans.write("[\"rec\",2\"\"")
456
- @prot.read_set_begin.should == [12, 2]
482
+ expect(@prot.read_set_begin).to eq([12, 2])
457
483
  end
458
484
 
459
485
  it "should read set end" do
460
486
  @trans.write("]")
461
- @prot.read_set_end.should == nil
487
+ expect(@prot.read_set_end).to eq(nil)
462
488
  end
463
489
 
464
490
  it "should read bool" do
465
491
  @trans.write("0\"\"")
466
- @prot.read_bool.should == false
492
+ expect(@prot.read_bool).to eq(false)
467
493
  @prot.read_string
468
494
 
469
495
  @trans.write("1\"\"")
470
- @prot.read_bool.should == true
496
+ expect(@prot.read_bool).to eq(true)
471
497
  end
472
498
 
473
499
  it "should read byte" do
474
500
  @trans.write("60\"\"")
475
- @prot.read_byte.should == 60
501
+ expect(@prot.read_byte).to eq(60)
476
502
  end
477
503
 
478
504
  it "should read i16" do
479
505
  @trans.write("1000\"\"")
480
- @prot.read_i16.should == 1000
506
+ expect(@prot.read_i16).to eq(1000)
481
507
  end
482
508
 
483
509
  it "should read i32" do
484
510
  @trans.write("3000000000\"\"")
485
- @prot.read_i32.should == 3000000000
511
+ expect(@prot.read_i32).to eq(3000000000)
486
512
  end
487
513
 
488
514
  it "should read i64" do
489
515
  @trans.write("6000000000\"\"")
490
- @prot.read_i64.should == 6000000000
516
+ expect(@prot.read_i64).to eq(6000000000)
491
517
  end
492
518
 
493
519
  it "should read double" do
494
520
  @trans.write("12.23\"\"")
495
- @prot.read_double.should == 12.23
521
+ expect(@prot.read_double).to eq(12.23)
496
522
  end
497
523
 
498
524
  if RUBY_VERSION >= '1.9'
499
525
  it 'should read string' do
500
526
  @trans.write('"this is a test string"'.force_encoding(Encoding::BINARY))
501
527
  a = @prot.read_string
502
- a.should == 'this is a test string'
503
- a.encoding.should == Encoding::UTF_8
528
+ expect(a).to eq('this is a test string')
529
+ expect(a.encoding).to eq(Encoding::UTF_8)
504
530
  end
505
531
 
506
532
  it 'should read string with unicode characters' do
507
533
  @trans.write('"this is a test string with unicode characters: \u20AC \u20AD"'.force_encoding(Encoding::BINARY))
508
534
  a = @prot.read_string
509
- a.should == "this is a test string with unicode characters: \u20AC \u20AD"
510
- a.encoding.should == Encoding::UTF_8
535
+ expect(a).to eq("this is a test string with unicode characters: \u20AC \u20AD")
536
+ expect(a.encoding).to eq(Encoding::UTF_8)
511
537
  end
512
538
  else
513
539
  it 'should read string' do
514
540
  @trans.write('"this is a test string"')
515
- @prot.read_string.should == 'this is a test string'
541
+ expect(@prot.read_string).to eq('this is a test string')
516
542
  end
517
543
  end
518
544
 
519
545
  it "should read binary" do
520
546
  @trans.write("\"dGhpcyBpcyBhIHRlc3Qgc3RyaW5n\"")
521
- @prot.read_binary.should == "this is a test string"
547
+ expect(@prot.read_binary).to eq("this is a test string")
548
+ end
549
+
550
+ it "should read long binary" do
551
+ @trans.write("\"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w==\"")
552
+ expect(@prot.read_binary.bytes.to_a).to eq((0...256).to_a)
553
+ end
554
+
555
+ it "should provide a reasonable to_s" do
556
+ expect(@prot.to_s).to eq("json(memory)")
522
557
  end
523
558
  end
524
559
 
525
560
  describe Thrift::JsonProtocolFactory do
526
561
  it "should create a JsonProtocol" do
527
- Thrift::JsonProtocolFactory.new.get_protocol(mock("MockTransport")).should be_instance_of(Thrift::JsonProtocol)
562
+ expect(Thrift::JsonProtocolFactory.new.get_protocol(double("MockTransport"))).to be_instance_of(Thrift::JsonProtocol)
563
+ end
564
+
565
+ it "should provide a reasonable to_s" do
566
+ expect(Thrift::JsonProtocolFactory.new.to_s).to eq("json")
528
567
  end
529
568
  end
530
569
  end