Sha256: 5b040d872d1f3fbf89baf5bf6a03a8613195b7ccad9032de73095a42b3e7ed7d

Contents?: true

Size: 929 Bytes

Versions: 16

Compression:

Stored size: 929 Bytes

Contents

require File.expand_path('spec/spec_helper')

describe Ruco::FileStore do
  def mark_all_as_old
    store.send(:entries).each{|e| File.utime(1,1,e) }
  end

  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)
    mark_all_as_old
    store.set('aaa', 2)
    store.get('aaa').should == 2
    ['xxx','yyy','zzz'].map{|f| store.get(f) }.should =~ [1,1,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)
    mark_all_as_old
    store.set('zzz', 1)
    store.set('zzz', 1)
    store.get('xxx').should == 1
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruco-0.2.0.beta2 spec/ruco/file_store_spec.rb
ruco-0.1.14 spec/ruco/file_store_spec.rb
ruco-0.1.13 spec/ruco/file_store_spec.rb
ruco-0.1.12 spec/ruco/file_store_spec.rb
ruco-0.1.11 spec/ruco/file_store_spec.rb
ruco-0.1.10 spec/ruco/file_store_spec.rb
ruco-0.1.9 spec/ruco/file_store_spec.rb
ruco-0.1.8 spec/ruco/file_store_spec.rb
ruco-0.1.7 spec/ruco/file_store_spec.rb
ruco-0.1.6 spec/ruco/file_store_spec.rb
ruco-0.1.5 spec/ruco/file_store_spec.rb
ruco-0.1.4 spec/ruco/file_store_spec.rb
ruco-0.1.3 spec/ruco/file_store_spec.rb
ruco-0.1.2 spec/ruco/file_store_spec.rb
ruco-0.1.1 spec/ruco/file_store_spec.rb
ruco-0.1.0 spec/ruco/file_store_spec.rb