Sha256: 101a5c6e74d67df3374b66155fed2b106fe5a49a4964a6db2696d3eb0d68897c

Contents?: true

Size: 975 Bytes

Versions: 10

Compression:

Stored size: 975 Bytes

Contents

require File.expand_path('spec/spec_helper')

describe Ruco::FileStore do
  before do
    @folder = 'spec/sessions'
    `rm -rf #{@folder}`
  end

  after do
    `rm -rf #{@folder}`
  end

  let(:store){ Ruco::FileStore.new(@folder, :keep => 3) }

  it "can store stuff" do
    store.set('xxx', 1)
    store.get('xxx').should == 1
  end

  it "can store :keep keys" do
    store.set('xxx', 1)
    store.set('yyy', 1)
    store.set('zzz', 1)
    store.set('aaa', 1)
    store.get('xxx').should == nil
  end

  it "drops least recently used key" do
    store.set('xxx', 1)
    store.set('yyy', 1)
    store.set('xxx', 1)
    store.set('zzz', 1)
    store.set('aaa', 1)
    store.get('xxx').should == 1
    store.get('yyy').should == nil
  end

  it "does not drop if used multiple times" do
    store.set('xxx', 1)
    store.set('yyy', 1)
    store.set('zzz', 1)
    store.set('zzz', 1)
    store.set('zzz', 1)
    store.set('zzz', 1)
    store.get('xxx').should == 1
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruco-0.0.51 spec/ruco/file_store_spec.rb
ruco-0.0.50 spec/ruco/file_store_spec.rb
ruco-0.0.49 spec/ruco/file_store_spec.rb
ruco-0.0.48 spec/ruco/file_store_spec.rb
ruco-0.0.47 spec/ruco/file_store_spec.rb
ruco-0.0.46 spec/ruco/file_store_spec.rb
ruco-0.0.45 spec/ruco/file_store_spec.rb
ruco-0.0.44 spec/ruco/file_store_spec.rb
ruco-0.0.43 spec/ruco/file_store_spec.rb
ruco-0.0.42 spec/ruco/file_store_spec.rb