Sha256: 3184bbe9e067922c1993749f34059dfa1a4bdafdd48200325b4b8a139fd5e0a0

Contents?: true

Size: 815 Bytes

Versions: 15

Compression:

Stored size: 815 Bytes

Contents

require 'spec_helper'

describe Celluloid::RingBuffer do
  subject { Celluloid::RingBuffer.new(2) }

  it { should be_empty }
  it { should_not be_full }

  it 'should push and shift' do
    subject.push('foo')
    subject.push('foo2')
    subject.shift.should eq('foo')
    subject.shift.should eq('foo2')
  end

  it 'should push past the end' do
    subject.push('foo')
    subject.push('foo2')
    subject.push('foo3')
    subject.should be_full
  end

  it 'should shift the most recent' do
    (1..5).each { |i| subject.push(i) }
    subject.shift.should be 4
    subject.shift.should be 5
    subject.shift.should be_nil
  end

  it 'should return nil when shifting empty' do
    subject.should be_empty
    subject.shift.should be_nil
  end

  it 'should be thread-safe' do
    #TODO how to test?
  end
end

Version data entries

15 entries across 13 versions & 5 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/celluloid-0.16.0/spec/celluloid/logging/ring_buffer_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/celluloid-0.16.0/spec/celluloid/logging/ring_buffer_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/celluloid-0.16.0/spec/celluloid/logging/ring_buffer_spec.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/celluloid-0.16.0/spec/celluloid/logging/ring_buffer_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/celluloid-0.16.0/spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.16.0 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.16.0.pre3 spec/celluloid/logging/ring_buffer_spec.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/celluloid-0.15.2/spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.16.0.pre2 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.16.0.pre spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.15.2 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.15.1 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.15.0 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.15.0.pre2 spec/celluloid/logging/ring_buffer_spec.rb
celluloid-0.15.0.pre spec/celluloid/logging/ring_buffer_spec.rb