<commit_before>require 'bumbleworks'

describe Bumbleworks::Redis::Adapter do
  before :each do
    Bumbleworks.reset!
  end

  describe 'when added to configuration' do
    it 'adds storage adapter to Bumbleworks' do
      described_class.stub(:auto_register?).and_return(false)
      Bumbleworks.configuration.storage_adapters.should_not include(described_class)
      Bumbleworks.configuration.add_storage_adapter(described_class)
      Bumbleworks.configuration.storage_adapters.should include(described_class)
    end
  end

  describe 'when auto_register is true' do
    it 'is already automatically added to configuration' do
      described_class.stub(:auto_register?).and_return(true)
      Bumbleworks.configuration.storage_adapters.should include(described_class)
    end
  end

  describe '.auto_register?' do
    it 'returns true if auto_register is true' do
      described_class.auto_register = true
      described_class.auto_register?.should be_true
    end

    it 'returns false if auto_register is not true' do
      described_class.auto_register = :ghosts
      described_class.auto_register?.should be_false
    end

    it 'is true by default' do
      described_class.auto_register = nil
      described_class.auto_register?.should be_true
    end
  end

  describe 'use?' do
    it 'returns true if given storage class matches Redis' do
      described_class.use?(Redis.new).should be_true
    end

    it 'returns false if given storage class does not match Redis' do
      described_class.use?({}).should be_false
      described_class.use?(nil).should be_false
      described_class.use?('Redis').should be_false
    end
  end
end<commit_msg>Ensure that adapter supports history storage<commit_after>require 'bumbleworks'

describe Bumbleworks::Redis::Adapter do
  before :each do
    Bumbleworks.reset!
  end

  describe 'when added to configuration' do
    it 'adds storage adapter to Bumbleworks' do
      described_class.stub(:auto_register?).and_return(false)
      Bumbleworks.configuration.storage_adapters.should_not include(described_class)
      Bumbleworks.configuration.add_storage_adapter(described_class)
      Bumbleworks.configuration.storage_adapters.should include(described_class)
    end
  end

  describe 'when auto_register is true' do
    it 'is already automatically added to configuration' do
      described_class.stub(:auto_register?).and_return(true)
      Bumbleworks.configuration.storage_adapters.should include(described_class)
    end
  end

  describe '.auto_register?' do
    it 'returns true if auto_register is true' do
      described_class.auto_register = true
      described_class.auto_register?.should be_true
    end

    it 'returns false if auto_register is not true' do
      described_class.auto_register = :ghosts
      described_class.auto_register?.should be_false
    end

    it 'is true by default' do
      described_class.auto_register = nil
      described_class.auto_register?.should be_true
    end
  end

  describe 'use?' do
    it 'returns true if given storage class matches Redis' do
      described_class.use?(Redis.new).should be_true
    end

    it 'returns false if given storage class does not match Redis' do
      described_class.use?({}).should be_false
      described_class.use?(nil).should be_false
      described_class.use?('Redis').should be_false
    end
  end

  it 'allows history storage' do
    described_class.allow_history_storage?.should be_true
  end
end
{'fraction_non_alphanumeric': 0.0665897953300663, 'fraction_numerical': 0.0, 'mean_word_length': 3.786206896551724, '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': '6333960', 'n_tokens_mistral': 1007, 'n_tokens_neox': 977, 'n_words': 270}