Sha256: d754ab368d2e1423dcf41f41c514c6d53947df416609ce76f4940704d0c1936d

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

# encoding: utf-8
#
require 'spec_helper'

# Shows that lists of categories can be ignored.
#
describe 'ignoring allocations' do

  it 'works' do
    index = Picky::Index.new :books do
      category :author
      category :title
      category :text
    end

    thing = Struct.new :id, :author, :title, :text
    index.add thing.new(1, 'peter', 'some title', 'some text')
    index.add thing.new(2, 'some name', 'some title', 'some text')
    
    try = Picky::Search.new index do
      ignore [:author, :text],
             [:text, :text]
    end
    
    # These allocations are now removed.
    #
    try.search('some some').allocations.to_result.should == [
      # [:books, 1.386, 2, [[:text, "some", "some"],   [:text, "some", "some"]],   [2, 1]],
      [:books, 1.386, 2, [[:text, "some", "some"],   [:title, "some", "some"]],  [2, 1]],
      [:books, 1.386, 2, [[:title, "some", "some"],  [:text, "some", "some"]],   [2, 1]],
      [:books, 1.386, 2, [[:title, "some", "some"],  [:title, "some", "some"]],  [2, 1]],
      [:books, 0.693, 1, [[:title, "some", "some"],  [:author, "some", "some"]], [2]],
      # [:books, 0.693, 1, [[:author, "some", "some"], [:text, "some", "some"]],   [2]],
      [:books, 0.693, 1, [[:author, "some", "some"], [:title, "some", "some"]],  [2]],
      [:books, 0.693, 1, [[:text, "some", "some"],   [:author, "some", "some"]], [2]],
      [:books, 0.0,   1, [[:author, "some", "some"], [:author, "some", "some"]], [2]]
    ]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
picky-4.13.0 spec/functional/only_allocations_spec.rb
picky-4.12.13 spec/functional/only_allocations_spec.rb
picky-4.12.12 spec/functional/only_allocations_spec.rb
picky-4.12.11 spec/functional/only_allocations_spec.rb
picky-4.12.10 spec/functional/only_allocations_spec.rb
picky-4.12.8 spec/functional/only_allocations_spec.rb
picky-4.12.7 spec/functional/only_allocations_spec.rb
picky-4.12.6 spec/functional/only_allocations_spec.rb
picky-4.12.5 spec/functional/only_allocations_spec.rb