arvicco-amqp 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -9,3 +9,7 @@
9
9
  == 0.6.9 / 2010-11-04
10
10
 
11
11
  * Exchange#publish raises error if no connection to broker
12
+
13
+ == 0.6.10 / 2010-11-04
14
+
15
+ * Bacon tests converted to Rspec
data/Rakefile CHANGED
@@ -22,8 +22,3 @@ task :codegen do
22
22
  sh 'ruby protocol/codegen.rb > lib/amqp/spec.rb'
23
23
  sh 'ruby lib/amqp/spec.rb'
24
24
  end
25
-
26
- desc "Run test suite (uses bacon gem)"
27
- task :test do
28
- sh 'bacon lib/amqp.rb'
29
- end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.6.10
data/lib/amqp/buffer.rb CHANGED
@@ -268,128 +268,3 @@ module AMQP
268
268
  end
269
269
  end
270
270
  end
271
-
272
- if $0 =~ /bacon/ or $0 == __FILE__
273
- require 'bacon'
274
- include AMQP
275
-
276
- describe Buffer do
277
- before do
278
- @buf = Buffer.new
279
- end
280
-
281
- should 'have contents' do
282
- @buf.contents.should == ''
283
- end
284
-
285
- should 'initialize with data' do
286
- @buf = Buffer.new('abc')
287
- @buf.contents.should == 'abc'
288
- end
289
-
290
- should 'append raw data' do
291
- @buf << 'abc'
292
- @buf << 'def'
293
- @buf.contents.should == 'abcdef'
294
- end
295
-
296
- should 'append other buffers' do
297
- @buf << Buffer.new('abc')
298
- @buf.data.should == 'abc'
299
- end
300
-
301
- should 'have a position' do
302
- @buf.pos.should == 0
303
- end
304
-
305
- should 'have a length' do
306
- @buf.length.should == 0
307
- @buf << 'abc'
308
- @buf.length.should == 3
309
- end
310
-
311
- should 'know the end' do
312
- @buf.empty?.should == true
313
- end
314
-
315
- should 'read and write data' do
316
- @buf._write('abc')
317
- @buf.rewind
318
- @buf._read(2).should == 'ab'
319
- @buf._read(1).should == 'c'
320
- end
321
-
322
- should 'raise on overflow' do
323
- lambda{ @buf._read(1) }.should.raise Buffer::Overflow
324
- end
325
-
326
- should 'raise on invalid types' do
327
- lambda{ @buf.read(:junk) }.should.raise Buffer::InvalidType
328
- lambda{ @buf.write(:junk, 1) }.should.raise Buffer::InvalidType
329
- end
330
-
331
- { :octet => 0b10101010,
332
- :short => 100,
333
- :long => 100_000_000,
334
- :longlong => 666_555_444_333_222_111,
335
- :shortstr => 'hello',
336
- :longstr => 'bye'*500,
337
- :timestamp => time = Time.at(Time.now.to_i),
338
- :table => { :this => 'is', :a => 'hash', :with => {:nested => 123, :and => time, :also => 123.456} },
339
- :bit => true
340
- }.each do |type, value|
341
-
342
- should "read and write a #{type}" do
343
- @buf.write(type, value)
344
- @buf.rewind
345
- @buf.read(type).should == value
346
- @buf.should.be.empty
347
- end
348
-
349
- end
350
-
351
- should 'read and write multiple bits' do
352
- bits = [true, false, false, true, true, false, false, true, true, false]
353
- @buf.write(:bit, bits)
354
- @buf.write(:octet, 100)
355
-
356
- @buf.rewind
357
-
358
- bits.map do
359
- @buf.read(:bit)
360
- end.should == bits
361
- @buf.read(:octet).should == 100
362
- end
363
-
364
- should 'read and write properties' do
365
- properties = ([
366
- [:octet, 1],
367
- [:shortstr, 'abc'],
368
- [:bit, true],
369
- [:bit, false],
370
- [:shortstr, nil],
371
- [:timestamp, nil],
372
- [:table, { :a => 'hash' }],
373
- ]*5).sort_by{rand}
374
-
375
- @buf.write(:properties, properties)
376
- @buf.rewind
377
- @buf.read(:properties, *properties.map{|type,_| type }).should == properties.map{|_,value| value }
378
- @buf.should.be.empty
379
- end
380
-
381
- should 'do transactional reads with #extract' do
382
- @buf.write :octet, 8
383
- orig = @buf.to_s
384
-
385
- @buf.rewind
386
- @buf.extract do |b|
387
- b.read :octet
388
- b.read :short
389
- end
390
-
391
- @buf.pos.should == 0
392
- @buf.data.should == orig
393
- end
394
- end
395
- end
data/lib/amqp/frame.rb CHANGED
@@ -64,61 +64,3 @@ module AMQP
64
64
  end
65
65
  end
66
66
  end
67
-
68
- if $0 =~ /bacon/ or $0 == __FILE__
69
- require 'bacon'
70
- include AMQP
71
-
72
- describe Frame do
73
- should 'handle basic frame types' do
74
- Frame::Method.new.id.should == 1
75
- Frame::Header.new.id.should == 2
76
- Frame::Body.new.id.should == 3
77
- end
78
-
79
- should 'convert method frames to binary' do
80
- meth = Protocol::Connection::Secure.new :challenge => 'secret'
81
-
82
- frame = Frame::Method.new(meth)
83
- frame.to_binary.should.be.kind_of? Buffer
84
- frame.to_s.should == [ 1, 0, meth.to_s.length, meth.to_s, 206 ].pack('CnNa*C')
85
- end
86
-
87
- should 'convert binary to method frames' do
88
- orig = Frame::Method.new Protocol::Connection::Secure.new(:challenge => 'secret')
89
-
90
- copy = Frame.parse(orig.to_binary)
91
- copy.should == orig
92
- end
93
-
94
- should 'ignore partial frames until ready' do
95
- frame = Frame::Method.new Protocol::Connection::Secure.new(:challenge => 'secret')
96
- data = frame.to_s
97
-
98
- buf = Buffer.new
99
- Frame.parse(buf).should == nil
100
-
101
- buf << data[0..5]
102
- Frame.parse(buf).should == nil
103
-
104
- buf << data[6..-1]
105
- Frame.parse(buf).should == frame
106
-
107
- Frame.parse(buf).should == nil
108
- end
109
-
110
- should 'convert header frames to binary' do
111
- head = Protocol::Header.new(Protocol::Basic, :priority => 1)
112
-
113
- frame = Frame::Header.new(head)
114
- frame.to_s.should == [ 2, 0, head.to_s.length, head.to_s, 206 ].pack('CnNa*C')
115
- end
116
-
117
- should 'convert binary to header frame' do
118
- orig = Frame::Header.new Protocol::Header.new(Protocol::Basic, :priority => 1)
119
-
120
- copy = Frame.parse(orig.to_binary)
121
- copy.should == orig
122
- end
123
- end
124
- end
data/lib/amqp/protocol.rb CHANGED
@@ -159,54 +159,3 @@ module AMQP
159
159
  #:stopdoc:
160
160
  end
161
161
  end
162
-
163
- if $0 =~ /bacon/ or $0 == __FILE__
164
- require 'bacon'
165
- include AMQP
166
-
167
- describe Protocol do
168
- should 'instantiate methods with arguments' do
169
- meth = Protocol::Connection::StartOk.new nil, 'PLAIN', nil, 'en_US'
170
- meth.locale.should == 'en_US'
171
- end
172
-
173
- should 'instantiate methods with named parameters' do
174
- meth = Protocol::Connection::StartOk.new :locale => 'en_US',
175
- :mechanism => 'PLAIN'
176
- meth.locale.should == 'en_US'
177
- end
178
-
179
- should 'convert methods to binary' do
180
- meth = Protocol::Connection::Secure.new :challenge => 'secret'
181
- meth.to_binary.should.be.kind_of? Buffer
182
-
183
- meth.to_s.should == [ 10, 20, 6, 'secret' ].pack('nnNa*')
184
- end
185
-
186
- should 'convert binary to method' do
187
- orig = Protocol::Connection::Secure.new :challenge => 'secret'
188
- copy = Protocol.parse orig.to_binary
189
- orig.should == copy
190
- end
191
-
192
- should 'convert headers to binary' do
193
- head = Protocol::Header.new Protocol::Basic,
194
- size = 5,
195
- weight = 0,
196
- :content_type => 'text/json',
197
- :delivery_mode => 1,
198
- :priority => 1
199
- head.to_s.should == [ 60, weight, 0, size, 0b1001_1000_0000_0000, 9, 'text/json', 1, 1 ].pack('nnNNnCa*CC')
200
- end
201
-
202
- should 'convert binary to header' do
203
- orig = Protocol::Header.new Protocol::Basic,
204
- size = 5,
205
- weight = 0,
206
- :content_type => 'text/json',
207
- :delivery_mode => 1,
208
- :priority => 1
209
- Protocol::Header.new(orig.to_binary).should == orig
210
- end
211
- end
212
- end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvicco-amqp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 9
10
- version: 0.6.9
9
+ - 10
10
+ version: 0.6.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta