<commit_before>require 'helper'
require 'flipper/adapters/memoized'
require 'flipper/adapters/memory'
require 'flipper/spec/shared_adapter_specs'

describe Flipper::Adapters::Memoized do
  let(:cache)   { {} }
  let(:source)  { {} }
  let(:adapter) { Flipper::Adapters::Memory.new(source) }

  subject { described_class.new(adapter, cache) }

  def read_key(key)
    source[key.to_s]
  end

  def write_key(key, value)
    source[key.to_s] = value
  end

  it_should_behave_like 'a flipper adapter'

  describe "#read" do
    before do
      source['foo'] = 'bar'
      subject.read('foo')
    end

    it "memoizes key" do
      cache['foo'].should eq(source['foo'])
      cache['foo'].should eq('bar')
    end
  end

  describe "#set_members" do
    before do
      source['foo'] = Set[1, 2]
      subject.set_members('foo')
    end

    it "memoizes key" do
      cache['foo'].should eq(source['foo'])
      cache['foo'].should eq(Set[1, 2])
    end
  end

  describe "#write" do
    before do
      source['foo'] = 'bar'
      @result = subject.read('foo')
      subject.write('foo', 'bar')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#delete" do
    before do
      source['foo'] = 'bar'
      @result = subject.read('foo')
      subject.delete('foo')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#set_add" do
    before do
      source['foo'] = Set[1, 2]
      @result = subject.set_members('foo')
      subject.set_add('foo', 3)
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#set_delete" do
    before do
      source['foo'] = Set[1, 2]
      subject.set_delete('foo', 2)
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end
end
<commit_msg>Changed memoized specs to use strings.<commit_after>require 'helper'
require 'flipper/adapters/memoized'
require 'flipper/adapters/memory'
require 'flipper/spec/shared_adapter_specs'

describe Flipper::Adapters::Memoized do
  let(:cache)   { {} }
  let(:source)  { {} }
  let(:adapter) { Flipper::Adapters::Memory.new(source) }

  subject { described_class.new(adapter, cache) }

  def read_key(key)
    source[key.to_s]
  end

  def write_key(key, value)
    source[key.to_s] = value
  end

  it_should_behave_like 'a flipper adapter'

  describe "#read" do
    before do
      source['foo'] = 'bar'
      subject.read('foo')
    end

    it "memoizes key" do
      cache['foo'].should eq(source['foo'])
      cache['foo'].should eq('bar')
    end
  end

  describe "#set_members" do
    before do
      source['foo'] = Set['1', '2']
      subject.set_members('foo')
    end

    it "memoizes key" do
      cache['foo'].should eq(source['foo'])
      cache['foo'].should eq(Set['1', '2'])
    end
  end

  describe "#write" do
    before do
      source['foo'] = 'bar'
      @result = subject.read('foo')
      subject.write('foo', 'bar')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#delete" do
    before do
      source['foo'] = 'bar'
      @result = subject.read('foo')
      subject.delete('foo')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#set_add" do
    before do
      source['foo'] = Set['1', '2']
      @result = subject.set_members('foo')
      subject.set_add('foo', '3')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end

  describe "#set_delete" do
    before do
      source['foo'] = Set['1', '2']
      subject.set_delete('foo', '2')
    end

    it "unmemoizes key" do
      cache.key?('foo').should be_false
    end
  end
end

{'fraction_non_alphanumeric': 0.1474887058198246, 'fraction_numerical': 0.005314908317831517, 'mean_word_length': 2.686581782566112, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6424203', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1312, 'n_words': 309}