<commit_before>require 'spec_helper'
require 'policy_machine_storage_adapters/in_memory'

describe PolicyMachineStorageAdapter::InMemory do
  it_behaves_like 'a policy machine storage adapter with required public methods'
  it_behaves_like 'a policy machine storage adapter'
  
  describe 'find_all_of_type' do
    let(:policy_machine_storage_adapter) { described_class.new }
    
    it 'finds without case sensitivity' do
      ['abcde', 'object1'].each do |name| 
        policy_machine_storage_adapter.add_object("#{name}_uuid", 'some_policy_machine_uuid', name: name) 
      end
      policy_machine_storage_adapter.find_all_of_type_object(name: 'ABCDE').first.unique_identifier.should == 'abcde_uuid'
      policy_machine_storage_adapter.find_all_of_type_object(name: 'oBJeCT1').first.unique_identifier.should == 'object1_uuid'
    end
    
    context 'pagination' do
      before do
        10.times {|i| policy_machine_storage_adapter.add_object("uuid_#{i}", 'some_policy_machine_uuid1', color: 'red') }
      end
      
      it 'paginates the results based on page and per_page' do
        results = policy_machine_storage_adapter.find_all_of_type_object(color: 'red', per_page: 2, page: 3)<commit_msg>Modified to move spec<commit_after>require 'spec_helper'
require 'policy_machine_storage_adapters/in_memory'

describe PolicyMachineStorageAdapter::InMemory do
  it_behaves_like 'a policy machine storage adapter with required public methods'
  it_behaves_like 'a policy machine storage adapter'
  
  describe 'find_all_of_type' do
    let(:policy_machine_storage_adapter) { described_class.new }
    
    context 'pagination' do
      before do
        10.times {|i| policy_machine_storage_adapter.add_object("uuid_#{i}", 'some_policy_machine_uuid1', color: 'red') }
      end
      
      it 'paginates the results based on page and per_page' do
        results = policy_machine_storage_adapter.find_all_of_type_object(color: 'red', per_page: 2, page: 3)
{'fraction_non_alphanumeric': 0.08384146341463415, 'fraction_numerical': 0.0066056910569105695, 'mean_word_length': 4.740524781341108, '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': '4665758', 'n_tokens_mistral': 618, 'n_tokens_neox': 601, 'n_words': 138}