Sha256: bc019177a1cf101b3208e2dceded6ff74230442a2267d0ed72a7eef2afc4cfc8

Contents?: true

Size: 947 Bytes

Versions: 15

Compression:

Stored size: 947 Bytes

Contents

require 'volt/utils/generic_counting_pool'

class CountingPoolTest < Volt::GenericCountingPool
  def create(id, name = nil)
    Object.new
  end
end

describe Volt::GenericCountingPool do
  before do
    @count_pool = CountingPoolTest.new
  end

  it 'should lookup and retrieve' do
    item1 = @count_pool.find('one')

    item2 = @count_pool.find('one')
    item3 = @count_pool.find('two')

    expect(item1).to eq(item2)
    expect(item2).to_not eq(item3)
  end

  it 'should only remove items when the same number have been removed as have been added' do
    item1 = @count_pool.find('_items', 'one')
    item2 = @count_pool.find('_items', 'one')
    expect(@count_pool.instance_variable_get('@pool')).to_not eq({})

    @count_pool.remove('_items', 'one')
    expect(@count_pool.instance_variable_get('@pool')).to_not eq({})

    @count_pool.remove('_items', 'one')
    expect(@count_pool.instance_variable_get('@pool')).to eq({})

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
volt-0.8.27.beta2 spec/utils/generic_counting_pool_spec.rb
volt-0.8.27.beta1 spec/utils/generic_counting_pool_spec.rb
volt-0.8.26.beta1 spec/utils/generic_counting_pool_spec.rb
volt-0.8.26 spec/utils/generic_counting_pool_spec.rb
volt-0.8.24 spec/utils/generic_counting_pool_spec.rb
volt-0.8.23 spec/utils/generic_counting_pool_spec.rb
volt-0.8.22 spec/utils/generic_counting_pool_spec.rb
volt-0.8.22.beta2 spec/utils/generic_counting_pool_spec.rb
volt-0.8.22.beta1 spec/utils/generic_counting_pool_spec.rb
volt-0.8.21 spec/utils/generic_counting_pool_spec.rb
volt-0.8.20 spec/utils/generic_counting_pool_spec.rb
volt-0.8.19 spec/utils/generic_counting_pool_spec.rb
volt-0.8.18 spec/utils/generic_counting_pool_spec.rb
volt-0.8.17 spec/utils/generic_counting_pool_spec.rb
volt-0.8.16 spec/utils/generic_counting_pool_spec.rb