amq-protocol 2.5.0 → 2.5.1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +5 -2
  3. data/lib/amq/protocol/version.rb +1 -1
  4. metadata +3 -55
  5. data/.github/ISSUE_TEMPLATE.md +0 -18
  6. data/.github/workflows/ci.yml +0 -31
  7. data/.gitignore +0 -18
  8. data/.gitmodules +0 -3
  9. data/.rspec +0 -1
  10. data/.travis.yml +0 -17
  11. data/AGENTS.md +0 -23
  12. data/CLAUDE.md +0 -1
  13. data/GEMINI.md +0 -1
  14. data/Gemfile +0 -27
  15. data/Rakefile +0 -55
  16. data/amq-protocol.gemspec +0 -27
  17. data/benchmarks/frame_encoding.rb +0 -75
  18. data/benchmarks/int_allocator.rb +0 -34
  19. data/benchmarks/method_encoding.rb +0 -198
  20. data/benchmarks/pack_unpack.rb +0 -158
  21. data/benchmarks/pure/body_framing_with_256k_payload.rb +0 -28
  22. data/benchmarks/pure/body_framing_with_2k_payload.rb +0 -28
  23. data/benchmarks/run_all.rb +0 -64
  24. data/benchmarks/table_encoding.rb +0 -110
  25. data/codegen/__init__.py +0 -0
  26. data/codegen/amqp_0.9.1_changes.json +0 -1
  27. data/codegen/codegen.py +0 -151
  28. data/codegen/codegen_helpers.py +0 -162
  29. data/codegen/protocol.rb.pytemplate +0 -320
  30. data/generate.rb +0 -24
  31. data/profiling/README.md +0 -9
  32. data/profiling/stackprof/body_framing_with_2k_payload.rb +0 -33
  33. data/spec/amq/bit_set_spec.rb +0 -249
  34. data/spec/amq/endianness_spec.rb +0 -23
  35. data/spec/amq/int_allocator_spec.rb +0 -136
  36. data/spec/amq/pack_spec.rb +0 -58
  37. data/spec/amq/protocol/basic_spec.rb +0 -325
  38. data/spec/amq/protocol/blank_body_encoding_spec.rb +0 -9
  39. data/spec/amq/protocol/channel_spec.rb +0 -127
  40. data/spec/amq/protocol/confirm_spec.rb +0 -41
  41. data/spec/amq/protocol/connection_spec.rb +0 -146
  42. data/spec/amq/protocol/constants_spec.rb +0 -10
  43. data/spec/amq/protocol/exceptions_spec.rb +0 -70
  44. data/spec/amq/protocol/exchange_spec.rb +0 -106
  45. data/spec/amq/protocol/float_32bit_spec.rb +0 -27
  46. data/spec/amq/protocol/frame_spec.rb +0 -156
  47. data/spec/amq/protocol/method_spec.rb +0 -43
  48. data/spec/amq/protocol/queue_spec.rb +0 -126
  49. data/spec/amq/protocol/table_spec.rb +0 -291
  50. data/spec/amq/protocol/tx_spec.rb +0 -55
  51. data/spec/amq/protocol/value_decoder_spec.rb +0 -183
  52. data/spec/amq/protocol/value_encoder_spec.rb +0 -161
  53. data/spec/amq/protocol_spec.rb +0 -812
  54. data/spec/amq/settings_spec.rb +0 -58
  55. data/spec/amq/uri_parsing_spec.rb +0 -287
  56. data/spec/spec_helper.rb +0 -29
@@ -1,325 +0,0 @@
1
- # encoding: binary
2
-
3
- module AMQ
4
- module Protocol
5
- RSpec.describe AMQ::Protocol::Basic do
6
- describe '.encode_timestamp' do
7
- it 'encodes the timestamp as a 64 byte big endian integer' do
8
- expect(Basic.encode_timestamp(12345).last).to eq("\x00\x00\x00\x00\x00\x0009")
9
- end
10
- end
11
-
12
- # describe '.decode_timestamp' do
13
- # it 'decodes the timestamp from a 64 byte big endian integer and returns a Time object' do
14
- # expect(Basic.decode_timestamp("\x00\x00\x00\x00\x00\x0009")).to eq(Time.at(12345))
15
- # end
16
- # end
17
-
18
- describe '.encode_headers' do
19
- it 'encodes the headers as a table' do
20
- expect(Basic.encode_headers(:hello => 'world').last).to eq("\x00\x00\x00\x10\x05helloS\x00\x00\x00\x05world")
21
- end
22
- end
23
-
24
- # describe '.decode_headers' do
25
- # it 'decodes the headers from a table' do
26
- # expect(Basic.decode_headers("\x00\x00\x00\x10\x05helloS\x00\x00\x00\x05world")).to eq({'hello' => 'world'})
27
- # end
28
- # end
29
-
30
- describe '.encode_properties' do
31
- it 'packs the parameters into a byte array using the other encode_* methods' do
32
- result = Basic.encode_properties(10, {:priority => 0, :delivery_mode => 2, :content_type => 'application/octet-stream'})
33
- expect(result).to eq("\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0a\x98\x00\x18application/octet-stream\x02\x00")
34
- end
35
- end
36
-
37
- describe '.decode_properties' do
38
- it 'unpacks the properties from a byte array using the decode_* methods' do
39
- result = Basic.decode_properties("\x98@\x18application/octet-stream\x02\x00\x00\x00\x00\x00\x00\x00\x00{")
40
- expect(result).to eq({:priority => 0, :delivery_mode => 2, :content_type => 'application/octet-stream', :timestamp => Time.at(123)})
41
- end
42
-
43
- it 'unpacks the properties from a byte array using the decode_* methods, including a table' do
44
- result = Basic.decode_properties("\xB8@\x18application/octet-stream\x00\x00\x00\x10\x05helloS\x00\x00\x00\x05world\x02\x00\x00\x00\x00\x00\x00\x00\x00{")
45
- expect(result).to eq({:priority => 0, :delivery_mode => 2, :content_type => 'application/octet-stream', :timestamp => Time.at(123), :headers => {'hello' => 'world'}})
46
- end
47
- end
48
-
49
- %w(content_type content_encoding correlation_id reply_to expiration message_id type user_id app_id cluster_id).each do |method|
50
- describe ".encode_#{method}" do
51
- it 'encodes the parameter as a Pascal string' do
52
- expect(Basic.send("encode_#{method}", 'hello world').last).to eq("\x0bhello world")
53
- end
54
- end
55
-
56
- # describe ".decode_#{method}" do
57
- # it 'returns the string' do
58
- # # the length has been stripped in .decode_properties
59
- # expect(Basic.send("decode_#{method}", 'hello world')).to eq('hello world')
60
- # end
61
- # end
62
- end
63
-
64
- %w(delivery_mode priority).each do |method|
65
- describe ".encode_#{method}" do
66
- it 'encodes the parameter as a char' do
67
- expect(Basic.send("encode_#{method}", 10).last).to eq("\x0a")
68
- end
69
- end
70
-
71
- # describe ".decode_#{method}" do
72
- # it 'decodes the value from a char' do
73
- # expect(Basic.send("decode_#{method}", "\x10")).to eq(16)
74
- # end
75
- # end
76
- end
77
- end
78
-
79
- class Basic
80
- RSpec.describe Qos do
81
- describe '.encode' do
82
- it 'encodes the parameters into a MethodFrame' do
83
- channel = 1
84
- prefetch_size = 3
85
- prefetch_count = 5
86
- global = false
87
- method_frame = Qos.encode(channel, prefetch_size, prefetch_count, global)
88
- expect(method_frame.payload).to eq("\x00<\x00\n\x00\x00\x00\x03\x00\x05\x00")
89
- expect(method_frame.channel).to eq(1)
90
- end
91
- end
92
- end
93
-
94
- # RSpec.describe QosOk do
95
- # describe '.decode' do
96
- # end
97
- # end
98
-
99
- RSpec.describe Consume do
100
- describe '.encode' do
101
- it 'encodes the parameters into a MethodFrame' do
102
- channel = 1
103
- queue = 'foo'
104
- consumer_tag = 'me'
105
- no_local = false
106
- no_ack = false
107
- exclusive = true
108
- nowait = false
109
- arguments = nil
110
- method_frame = Consume.encode(channel, queue, consumer_tag, no_local, no_ack, exclusive, nowait, arguments)
111
- expect(method_frame.payload).to eq("\x00<\x00\x14\x00\x00\x03foo\x02me\x04\x00\x00\x00\x00")
112
- expect(method_frame.channel).to eq(1)
113
- end
114
- end
115
- end
116
-
117
- RSpec.describe ConsumeOk do
118
- describe '.decode' do
119
- subject do
120
- ConsumeOk.decode("\x03foo")
121
- end
122
-
123
- its(:consumer_tag) { should eq('foo') }
124
- end
125
- end
126
-
127
- RSpec.describe Cancel do
128
- describe '.encode' do
129
- it 'encodes the parameters into a MethodFrame' do
130
- channel = 1
131
- consumer_tag = 'foo'
132
- nowait = true
133
- method_frame = Cancel.encode(channel, consumer_tag, nowait)
134
- expect(method_frame.payload).to eq("\x00<\x00\x1E\x03foo\x01")
135
- expect(method_frame.channel).to eq(1)
136
- end
137
- end
138
-
139
- describe '.decode' do
140
- subject do
141
- CancelOk.decode("\x03foo\x01")
142
- end
143
-
144
- its(:consumer_tag) { should eq('foo') }
145
- end
146
- end
147
-
148
- RSpec.describe CancelOk do
149
- describe '.decode' do
150
- subject do
151
- CancelOk.decode("\x03foo")
152
- end
153
-
154
- its(:consumer_tag) { should eq('foo') }
155
- end
156
- end
157
-
158
- RSpec.describe Publish do
159
- describe '.encode' do
160
- it 'encodes the parameters into a list of MethodFrames' do
161
- channel = 1
162
- payload = 'Hello World!'
163
- user_headers = {:priority => 0, :content_type => 'application/octet-stream'}
164
- exchange = 'foo'
165
- routing_key = 'xyz'
166
- mandatory = false
167
- immediate = true
168
- frame_size = 512
169
- method_frames = Publish.encode(channel, payload, user_headers, exchange, routing_key, mandatory, immediate, frame_size)
170
- expect(method_frames[0].payload).to eq("\x00<\x00(\x00\x00\x03foo\x03xyz\x02")
171
- expect(method_frames[1].payload).to eq("\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\f\x88\x00\x18application/octet-stream\x00")
172
- expect(method_frames[2].payload).to eq("Hello World!")
173
- expect(method_frames[0].channel).to eq(1)
174
- expect(method_frames[1].channel).to eq(1)
175
- expect(method_frames[2].channel).to eq(1)
176
- expect(method_frames.size).to eq(3)
177
- end
178
- end
179
- end
180
-
181
- RSpec.describe Return do
182
- describe '.decode' do
183
- subject do
184
- Return.decode("\x019\fNO_CONSUMERS\namq.fanout\x00")
185
- end
186
-
187
- its(:reply_code) { should eq(313) }
188
- its(:reply_text) { should eq('NO_CONSUMERS') }
189
- its(:exchange) { should eq('amq.fanout') }
190
- its(:routing_key) { should eq('') }
191
- end
192
- end
193
-
194
- RSpec.describe Deliver do
195
- describe '.decode' do
196
- subject do
197
- Deliver.decode("\e-1300560114000-445586772970\x00\x00\x00\x00\x00\x00\x00c\x00\namq.fanout\x00")
198
- end
199
-
200
- its(:consumer_tag) { should eq('-1300560114000-445586772970') }
201
- its(:delivery_tag) { should eq(99) }
202
- its(:redelivered) { should eq(false) }
203
- its(:exchange) { should eq('amq.fanout') }
204
- its(:routing_key) { should eq('') }
205
- end
206
- end
207
-
208
- RSpec.describe Get do
209
- describe '.encode' do
210
- it 'encodes the parameters into a MethodFrame' do
211
- channel = 1
212
- queue = 'foo'
213
- no_ack = true
214
- method_frame = Get.encode(channel, queue, no_ack)
215
- expect(method_frame.payload).to eq("\x00\x3c\x00\x46\x00\x00\x03foo\x01")
216
- expect(method_frame.channel).to eq(1)
217
- end
218
- end
219
- end
220
-
221
- RSpec.describe GetOk do
222
- describe '.decode' do
223
- subject do
224
- GetOk.decode("\x00\x00\x00\x00\x00\x00\x00\x06\x00\namq.fanout\x00\x00\x00\x00^")
225
- end
226
-
227
- its(:delivery_tag) { should eq(6) }
228
- its(:redelivered) { should eq(false) }
229
- its(:exchange) { should eq('amq.fanout') }
230
- its(:routing_key) { should eq('') }
231
- its(:message_count) { should eq(94) }
232
- end
233
- end
234
-
235
- RSpec.describe GetEmpty do
236
- describe '.decode' do
237
- subject do
238
- GetEmpty.decode("\x03foo")
239
- end
240
-
241
- its(:cluster_id) { should eq('foo') }
242
- end
243
- end
244
-
245
- RSpec.describe Ack do
246
- describe '.encode' do
247
- it 'encodes the parameters into a MethodFrame' do
248
- channel = 1
249
- delivery_tag = 6
250
- multiple = false
251
- method_frame = Ack.encode(channel, delivery_tag, multiple)
252
- expect(method_frame.payload).to eq("\x00<\x00P\x00\x00\x00\x00\x00\x00\x00\x06\x00")
253
- expect(method_frame.channel).to eq(1)
254
- end
255
- end
256
- end
257
-
258
- RSpec.describe Reject do
259
- describe '.encode' do
260
- it 'encodes the parameters into a MethodFrame' do
261
- channel = 1
262
- delivery_tag = 8
263
- requeue = true
264
- method_frame = Reject.encode(channel, delivery_tag, requeue)
265
- expect(method_frame.payload).to eq("\x00<\x00Z\x00\x00\x00\x00\x00\x00\x00\x08\x01")
266
- expect(method_frame.channel).to eq(1)
267
- end
268
- end
269
- end
270
-
271
- RSpec.describe RecoverAsync do
272
- describe '.encode' do
273
- it 'encodes the parameters into a MethodFrame' do
274
- channel = 1
275
- requeue = true
276
- method_frame = RecoverAsync.encode(channel, requeue)
277
- expect(method_frame.payload).to eq("\x00<\x00d\x01")
278
- expect(method_frame.channel).to eq(1)
279
- end
280
- end
281
- end
282
-
283
- RSpec.describe Recover do
284
- describe '.encode' do
285
- it 'encodes the parameters into a MethodFrame' do
286
- channel = 1
287
- requeue = true
288
- method_frame = Recover.encode(channel, requeue)
289
- expect(method_frame.payload).to eq("\x00<\x00n\x01")
290
- expect(method_frame.channel).to eq(1)
291
- end
292
- end
293
- end
294
-
295
- # RSpec.describe RecoverOk do
296
- # describe '.decode' do
297
- # end
298
- # end
299
-
300
- RSpec.describe Nack do
301
- describe '.decode' do
302
- subject do
303
- Nack.decode("\x00\x00\x00\x00\x00\x00\x00\x09\x03")
304
- end
305
-
306
- its(:delivery_tag) { should eq(9) }
307
- its(:multiple) { should eq(true) }
308
- its(:requeue) { should eq(true) }
309
- end
310
-
311
- describe '.encode' do
312
- it 'encodes the parameters into a MethodFrame' do
313
- channel = 1
314
- delivery_tag = 10
315
- multiple = false
316
- requeue = true
317
- method_frame = Nack.encode(channel, delivery_tag, multiple, requeue)
318
- expect(method_frame.payload).to eq("\x00<\x00x\x00\x00\x00\x00\x00\x00\x00\x0a\x02")
319
- expect(method_frame.channel).to eq(1)
320
- end
321
- end
322
- end
323
- end
324
- end
325
- end
@@ -1,9 +0,0 @@
1
- RSpec.describe AMQ::Protocol::Method, ".encode_body" do
2
- it "encodes 1-byte long payload as exactly 1 body frame" do
3
- expect(described_class.encode_body('1', 1, 65536).size).to eq(1)
4
- end
5
-
6
- it "encodes 0-byte long (blank) payload as exactly 0 body frame" do
7
- expect(described_class.encode_body('', 1, 65536).size).to eq(0)
8
- end
9
- end
@@ -1,127 +0,0 @@
1
- # encoding: binary
2
-
3
- module AMQ
4
- module Protocol
5
- class Channel
6
- RSpec.describe Open do
7
- describe '.encode' do
8
- it 'encodes the parameters into a MethodFrame' do
9
- channel = 1
10
- out_of_band = ''
11
- method_frame = Open.encode(channel, out_of_band)
12
- expect(method_frame.payload).to eq("\x00\x14\x00\n\x00")
13
- expect(method_frame.channel).to eq(1)
14
- end
15
- end
16
- end
17
-
18
- RSpec.describe OpenOk do
19
- describe '.decode' do
20
- subject do
21
- OpenOk.decode("\x00\x00\x00\x03foo")
22
- end
23
-
24
- its(:channel_id) { should eq('foo') }
25
- end
26
- end
27
-
28
- RSpec.describe Flow do
29
- describe '.decode' do
30
- subject do
31
- Flow.decode("\x01")
32
- end
33
-
34
- its(:active) { should be_truthy }
35
- end
36
-
37
- describe '.encode' do
38
- it 'encodes the parameters as a MethodFrame' do
39
- channel = 1
40
- active = true
41
- method_frame = Flow.encode(channel, active)
42
- expect(method_frame.payload).to eq("\x00\x14\x00\x14\x01")
43
- expect(method_frame.channel).to eq(1)
44
- end
45
- end
46
- end
47
-
48
- RSpec.describe FlowOk do
49
- describe '.decode' do
50
- subject do
51
- FlowOk.decode("\x00")
52
- end
53
-
54
- its(:active) { should be_falsey }
55
- end
56
-
57
- describe '.encode' do
58
- it 'encodes the parameters as a MethodFrame' do
59
- channel = 1
60
- active = true
61
- method_frame = FlowOk.encode(channel, active)
62
- expect(method_frame.payload).to eq("\x00\x14\x00\x15\x01")
63
- expect(method_frame.channel).to eq(1)
64
- end
65
- end
66
- end
67
-
68
- RSpec.describe Close do
69
- describe '.decode' do
70
- context 'with code 200' do
71
- subject do
72
- Close.decode("\x00\xc8\x07KTHXBAI\x00\x05\x00\x06")
73
- end
74
-
75
- its(:reply_code) { should eq(200) }
76
- its(:reply_text) { should eq('KTHXBAI') }
77
- its(:class_id) { should eq(5) }
78
- its(:method_id) { should eq(6) }
79
- end
80
-
81
-
82
- context 'with code 404 and reply_text length > 127 characters' do
83
- subject do
84
- raw = "\x01\x94\x80NOT_FOUND - no binding 123456789012345678901234567890123 between exchange 'amq.topic' in vhost '/' and queue 'test' in vhost '/'\x002\x002"
85
- Close.decode(raw)
86
- end
87
-
88
- its(:reply_code) { should eq(404) }
89
- its(:reply_text) { should eq(%q{NOT_FOUND - no binding 123456789012345678901234567890123 between exchange 'amq.topic' in vhost '/' and queue 'test' in vhost '/'}) }
90
- its(:class_id) { should eq(50) }
91
- its(:method_id) { should eq(50) }
92
- end
93
-
94
- context 'with an error code' do
95
- it 'returns frame and lets calling code handle the issue' do
96
- Close.decode("\x01\x38\x08NO_ROUTE\x00\x00")
97
- end
98
- end
99
- end
100
-
101
- describe '.encode' do
102
- it 'encodes the parameters into a MethodFrame' do
103
- channel = 1
104
- reply_code = 540
105
- reply_text = 'NOT_IMPLEMENTED'
106
- class_id = 0
107
- method_id = 0
108
- method_frame = Close.encode(channel, reply_code, reply_text, class_id, method_id)
109
- expect(method_frame.payload).to eq("\x00\x14\x00(\x02\x1c\x0fNOT_IMPLEMENTED\x00\x00\x00\x00")
110
- expect(method_frame.channel).to eq(1)
111
- end
112
- end
113
- end
114
-
115
- RSpec.describe CloseOk do
116
- describe '.encode' do
117
- it 'encodes the parameters into a MethodFrame' do
118
- channel = 1
119
- method_frame = CloseOk.encode(channel)
120
- expect(method_frame.payload).to eq("\x00\x14\x00\x29")
121
- expect(method_frame.channel).to eq(channel)
122
- end
123
- end
124
- end
125
- end
126
- end
127
- end
@@ -1,41 +0,0 @@
1
- # encoding: binary
2
-
3
- module AMQ
4
- module Protocol
5
- class Confirm
6
- RSpec.describe Select do
7
- describe '.decode' do
8
- subject do
9
- Select.decode("\x01")
10
- end
11
-
12
- its(:nowait) { should be_truthy }
13
- end
14
-
15
- describe '.encode' do
16
- it 'encodes the parameters into a MethodFrame' do
17
- channel = 1
18
- nowait = true
19
- method_frame = Select.encode(channel, nowait)
20
- expect(method_frame.payload).to eq("\x00U\x00\n\x01")
21
- expect(method_frame.channel).to eq(1)
22
- end
23
- end
24
- end
25
-
26
- RSpec.describe SelectOk do
27
- # describe '.decode' do
28
- # end
29
-
30
- describe '.encode' do
31
- it 'encodes the parameters into a MethodFrame' do
32
- channel = 1
33
- method_frame = SelectOk.encode(channel)
34
- expect(method_frame.payload).to eq("\000U\000\v")
35
- expect(method_frame.channel).to eq(1)
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,146 +0,0 @@
1
- # encoding: binary
2
-
3
- module AMQ
4
- module Protocol
5
- class Connection
6
- RSpec.describe Start do
7
- describe '.decode' do
8
- subject do
9
- Start.decode("\x00\t\x00\x00\x00\xFB\tcopyrightS\x00\x00\x00gCopyright (C) 2007-2010 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.\vinformationS\x00\x00\x005Licensed under the MPL. See http://www.rabbitmq.com/\bplatformS\x00\x00\x00\nErlang/OTP\aproductS\x00\x00\x00\bRabbitMQ\aversionS\x00\x00\x00\x052.2.0\x00\x00\x00\x0EPLAIN AMQPLAIN\x00\x00\x00\x05en_US")
10
- end
11
-
12
- its(:version_major) { should == 0 }
13
- its(:version_minor) { should == 9 }
14
- its(:server_properties) { should == {'copyright' => 'Copyright (C) 2007-2010 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.', 'information' => 'Licensed under the MPL. See http://www.rabbitmq.com/', 'platform' => 'Erlang/OTP', 'product' => 'RabbitMQ', 'version' => '2.2.0'} }
15
- its(:mechanisms) { should == 'PLAIN AMQPLAIN' }
16
- its(:locales) { should == 'en_US' }
17
- end
18
- end
19
-
20
- RSpec.describe StartOk do
21
- describe '.encode' do
22
- it 'encodes the parameters into a MethodFrame' do
23
- client_properties = {:platform => 'Ruby 1.9.2', :product => 'AMQ Client', :information => 'http://github.com/ruby-amqp/amq-client', :version => '0.2.0'}
24
- mechanism = 'PLAIN'
25
- response = "\x00guest\x00guest"
26
- locale = 'en_GB'
27
- method_frame = StartOk.encode(client_properties, mechanism, response, locale)
28
- # the order of the table parts isn't deterministic in Ruby 1.8
29
- expect(method_frame.payload[0, 8]).to eq("\x00\n\x00\v\x00\x00\x00x")
30
- expect(method_frame.payload).to include("\bplatformS\x00\x00\x00\nRuby 1.9.2")
31
- expect(method_frame.payload).to include("\aproductS\x00\x00\x00\nAMQ Client")
32
- expect(method_frame.payload).to include("\vinformationS\x00\x00\x00&http://github.com/ruby-amqp/amq-client")
33
- expect(method_frame.payload).to include("\aversionS\x00\x00\x00\x050.2.0")
34
- expect(method_frame.payload[-28, 28]).to eq("\x05PLAIN\x00\x00\x00\f\x00guest\x00guest\x05en_GB")
35
- expect(method_frame.payload.length).to eq(156)
36
- end
37
- end
38
- end
39
-
40
- RSpec.describe Secure do
41
- describe '.decode' do
42
- subject do
43
- Secure.decode("\x00\x00\x00\x03foo")
44
- end
45
-
46
- its(:challenge) { should eq('foo') }
47
- end
48
- end
49
-
50
- RSpec.describe SecureOk do
51
- describe '.encode' do
52
- it 'encodes the parameters as a MethodFrame' do
53
- response = 'bar'
54
- method_frame = SecureOk.encode(response)
55
- expect(method_frame.payload).to eq("\x00\x0a\x00\x15\x00\x00\x00\x03bar")
56
- end
57
- end
58
- end
59
-
60
- RSpec.describe Tune do
61
- describe '.decode' do
62
- subject do
63
- Tune.decode("\x00\x00\x00\x02\x00\x00\x00\x00")
64
- end
65
-
66
- its(:channel_max) { should eq(0) }
67
- its(:frame_max) { should eq(131072) }
68
- its(:heartbeat) { should eq(0) }
69
- end
70
- end
71
-
72
- RSpec.describe TuneOk do
73
- describe '.encode' do
74
- it 'encodes the parameters into a MethodFrame' do
75
- channel_max = 0
76
- frame_max = 65536
77
- heartbeat = 1
78
- method_frame = TuneOk.encode(channel_max, frame_max, heartbeat)
79
- expect(method_frame.payload).to eq("\x00\n\x00\x1F\x00\x00\x00\x01\x00\x00\x00\x01")
80
- end
81
- end
82
- end
83
-
84
- RSpec.describe Open do
85
- describe '.encode' do
86
- it 'encodes the parameters into a MethodFrame' do
87
- vhost = '/test'
88
- method_frame = Open.encode(vhost)
89
- expect(method_frame.payload).to eq("\x00\n\x00(\x05/test\x00\x00")
90
- end
91
- end
92
- end
93
-
94
- RSpec.describe OpenOk do
95
- describe '.decode' do
96
- subject do
97
- OpenOk.decode("\x00")
98
- end
99
-
100
- its(:known_hosts) { should eq('') }
101
- end
102
- end
103
-
104
- RSpec.describe Close do
105
- describe '.decode' do
106
- context 'with code 200' do
107
- subject do
108
- Close.decode("\x00\xc8\x07KTHXBAI\x00\x05\x00\x06")
109
- end
110
-
111
- its(:reply_code) { should eq(200) }
112
- its(:reply_text) { should eq('KTHXBAI') }
113
- its(:class_id) { should eq(5) }
114
- its(:method_id) { should eq(6) }
115
- end
116
-
117
- context 'with an error code' do
118
- it 'returns method frame and lets calling code handle the issue' do
119
- Close.decode("\x01\x38\x08NO_ROUTE\x00\x00")
120
- end
121
- end
122
- end
123
-
124
- describe '.encode' do
125
- it 'encodes the parameters into a MethodFrame' do
126
- reply_code = 540
127
- reply_text = 'NOT_IMPLEMENTED'
128
- class_id = 0
129
- method_id = 0
130
- method_frame = Close.encode(reply_code, reply_text, class_id, method_id)
131
- expect(method_frame.payload).to eq("\x00\x0a\x002\x02\x1c\x0fNOT_IMPLEMENTED\x00\x00\x00\x00")
132
- end
133
- end
134
- end
135
-
136
- RSpec.describe CloseOk do
137
- describe '.encode' do
138
- it 'encodes a MethodFrame' do
139
- method_frame = CloseOk.encode
140
- expect(method_frame.payload).to eq("\x00\n\x003")
141
- end
142
- end
143
- end
144
- end
145
- end
146
- end
@@ -1,10 +0,0 @@
1
- RSpec.describe "(Some) AMQ::Protocol constants" do
2
- it "include regular port" do
3
- expect(AMQ::Protocol::DEFAULT_PORT).to eq(5672)
4
- end
5
-
6
- it "provides TLS/SSL port" do
7
- expect(AMQ::Protocol::TLS_PORT).to eq(5671)
8
- expect(AMQ::Protocol::SSL_PORT).to eq(5671)
9
- end
10
- end