<commit_before>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<commit_msg>fix file_store spec<commit_after>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)
    sleep(0.1)
    store.set('yyy', 1)
    sleep(0.1)
    store.set('xxx', 1)
    sleep(0.1)
    store.set('zzz', 1)
    sleep(0.1)
    store.set('aaa', 1)
    sleep(0.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
{'fraction_non_alphanumeric': 0.18944844124700239, 'fraction_numerical': 0.023980815347721823, 'mean_word_length': 2.705150976909414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7530390', 'n_tokens_mistral': 865, 'n_tokens_neox': 814, 'n_words': 200}