Sha256: 6a622f312522b730dbc35b07b1cff64e76256d85e29d8bddfb646620f3b24e58

Contents?: true

Size: 901 Bytes

Versions: 1

Compression:

Stored size: 901 Bytes

Contents

# encoding: utf-8
#
require 'spec_helper'

describe "Realtime Indexing" do

  Book = Struct.new(:id, :title, :author)

  context 'default index' do
    let(:index) do
      Picky::Index.new(:books) do
        category :title
        category :author, similarity: Picky::Generators::Similarity::DoubleMetaphone.new(3)
      end
    end
    let(:books) { Picky::Search.new index }

    before(:each) do
      index.add Book.new(1, "Title", "Author")
    end

    context 'dumping and loading' do
      it "doesn't find books anymore after dumping and loading and updating" do
        index.replace Book.new(2, "Title New", "Author New")

        books.search("title").ids.should == [2, 1]

        index.dump
        index.load
        index.build_realtime_mapping

        index.replace Book.new(2, "Blah New", "Author New")

        books.search("title").ids.should == [1]
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-4.8.1 spec/functional/reloading_spec.rb