picky 3.5.4 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/picky/backends/backend.rb +1 -1
- data/lib/picky/backends/file/basic.rb +0 -36
- data/lib/picky/backends/file/json.rb +1 -1
- data/lib/picky/backends/file.rb +4 -4
- data/lib/picky/backends/helpers/file.rb +0 -26
- data/lib/picky/backends/memory/basic.rb +0 -35
- data/lib/picky/backends/memory.rb +4 -4
- data/lib/picky/backends/redis/basic.rb +0 -33
- data/lib/picky/backends/redis.rb +4 -4
- data/lib/picky/backends/sqlite/db.rb +84 -0
- data/lib/picky/backends/sqlite.rb +75 -0
- data/lib/picky/bundle.rb +15 -87
- data/lib/picky/bundle_realtime.rb +1 -1
- data/lib/picky/categories.rb +1 -0
- data/lib/picky/categories_indexed.rb +1 -1
- data/lib/picky/categories_indexing.rb +1 -3
- data/lib/picky/category.rb +16 -2
- data/lib/picky/category_indexed.rb +5 -3
- data/lib/picky/category_indexing.rb +0 -26
- data/lib/picky/category_realtime.rb +2 -0
- data/lib/picky/extensions/string.rb +20 -0
- data/lib/picky/extensions/symbol.rb +22 -0
- data/lib/picky/generators/similarity/double_metaphone.rb +1 -2
- data/lib/picky/generators/similarity/metaphone.rb +1 -2
- data/lib/picky/generators/similarity/phonetic.rb +0 -10
- data/lib/picky/generators/similarity/soundex.rb +1 -2
- data/lib/picky/index.rb +9 -2
- data/lib/picky/index_indexed.rb +4 -4
- data/lib/picky/index_indexing.rb +1 -5
- data/lib/picky/indexes_indexed.rb +7 -6
- data/lib/picky/indexes_indexing.rb +1 -7
- data/lib/picky/loader.rb +4 -1
- data/lib/picky/sources/couch.rb +1 -1
- data/lib/picky/sources/mongo.rb +1 -1
- data/lib/picky/wrappers/bundle/calculation.rb +1 -1
- data/lib/picky/wrappers/bundle/exact_partial.rb +3 -12
- data/lib/picky/wrappers/bundle/location.rb +1 -0
- data/lib/tasks/index.rake +0 -4
- data/spec/lib/backends/file/basic_spec.rb +5 -17
- data/spec/lib/backends/memory/basic_spec.rb +5 -17
- data/spec/lib/backends/redis/basic_spec.rb +5 -52
- data/spec/lib/backends/sqlite/db_spec.rb +80 -0
- data/spec/lib/backends/sqlite_spec.rb +131 -0
- data/spec/lib/category_indexed_spec.rb +2 -2
- data/spec/lib/category_indexing_spec.rb +0 -24
- data/spec/lib/extensions/string_spec.rb +16 -0
- data/spec/lib/extensions/symbol_spec.rb +16 -0
- data/spec/lib/index_indexed_spec.rb +16 -16
- data/spec/lib/indexes_indexed_spec.rb +13 -7
- data/spec/lib/indexes_indexing_spec.rb +3 -6
- data/spec/lib/indexing/bundle_spec.rb +6 -125
- data/spec/lib/sources/couch_spec.rb +8 -8
- data/spec/lib/sources/mongo_spec.rb +5 -5
- data/spec/specific/realtime_spec.rb +397 -173
- metadata +44 -29
- data/lib/picky/bundling.rb +0 -10
- data/lib/tasks/checks.rake +0 -13
| @@ -3,231 +3,455 @@ | |
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 5 | 
             
            describe "Realtime Indexing" do
         | 
| 6 | 
            -
             | 
| 6 | 
            +
             | 
| 7 7 | 
             
              class Book
         | 
| 8 8 | 
             
                attr_reader :id, :title, :author
         | 
| 9 9 | 
             
                def initialize id, title, author
         | 
| 10 10 | 
             
                  @id, @title, @author = id, title, author
         | 
| 11 11 | 
             
                end
         | 
| 12 12 | 
             
              end
         | 
| 13 | 
            -
             | 
| 14 | 
            -
               | 
| 15 | 
            -
                 | 
| 16 | 
            -
                   | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
              let(:books) { Picky::Search.new index }
         | 
| 22 | 
            -
              
         | 
| 23 | 
            -
              before(:each) do
         | 
| 24 | 
            -
                index.add Book.new(1, "Title", "Author")
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
              
         | 
| 27 | 
            -
              context 'single category updating' do
         | 
| 28 | 
            -
                it 'finds the first entry' do
         | 
| 29 | 
            -
                  books.search('title:Titl').ids.should == [1]
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
                
         | 
| 32 | 
            -
                it 'allows removing a single category and leaving the others alone' do
         | 
| 33 | 
            -
                  index[:title].remove 1
         | 
| 34 | 
            -
                  
         | 
| 35 | 
            -
                  books.search('Title').ids.should == []
         | 
| 36 | 
            -
                  books.search('Author').ids.should == [1]
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
                
         | 
| 39 | 
            -
                it 'allows adding a single category and leaving the others alone' do
         | 
| 40 | 
            -
                  index[:title].add Book.new(2, "Newtitle", "Newauthor")
         | 
| 41 | 
            -
                  
         | 
| 42 | 
            -
                  books.search('Title').ids.should == [1]
         | 
| 43 | 
            -
                  books.search('Newtitle').ids.should == [2]
         | 
| 44 | 
            -
                  
         | 
| 45 | 
            -
                  books.search('Author').ids.should == [1]
         | 
| 46 | 
            -
                  books.search('Newauthor').ids.should == []
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
                
         | 
| 49 | 
            -
                it 'allows replacing a single category and leaving the others alone' do
         | 
| 50 | 
            -
                  index[:title].replace Book.new(1, "Replaced", "Notindexed")
         | 
| 51 | 
            -
                  
         | 
| 52 | 
            -
                  books.search('Title').ids.should == []
         | 
| 53 | 
            -
                  books.search('Replaced').ids.should == [1]
         | 
| 54 | 
            -
                  
         | 
| 55 | 
            -
                  books.search('Notindexed').ids.should == []
         | 
| 56 | 
            -
                  books.search('Author').ids.should == [1]
         | 
| 57 | 
            -
                end
         | 
| 58 | 
            -
              end
         | 
| 59 | 
            -
              
         | 
| 60 | 
            -
              context 'with partial' do
         | 
| 61 | 
            -
                it 'finds the first entry' do
         | 
| 62 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              context 'default index' do
         | 
| 15 | 
            +
                let(:index) do
         | 
| 16 | 
            +
                  Picky::Index.new(:books) do
         | 
| 17 | 
            +
                    source []
         | 
| 18 | 
            +
                    category :title
         | 
| 19 | 
            +
                    category :author, similarity: Picky::Generators::Similarity::DoubleMetaphone.new(3)
         | 
| 20 | 
            +
                  end
         | 
| 63 21 | 
             
                end
         | 
| 22 | 
            +
                let(:books) { Picky::Search.new index }
         | 
| 64 23 |  | 
| 65 | 
            -
                 | 
| 66 | 
            -
                  index. | 
| 24 | 
            +
                before(:each) do
         | 
| 25 | 
            +
                  index.add Book.new(1, "Title", "Author")
         | 
| 67 26 | 
             
                end
         | 
| 68 | 
            -
                it 'is not findable anymore after removing' do
         | 
| 69 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 70 27 |  | 
| 71 | 
            -
             | 
| 28 | 
            +
                context 'single category updating' do
         | 
| 29 | 
            +
                  it 'finds the first entry' do
         | 
| 30 | 
            +
                    books.search('title:Titl').ids.should == [1]
         | 
| 31 | 
            +
                  end
         | 
| 72 32 |  | 
| 73 | 
            -
                   | 
| 74 | 
            -
             | 
| 33 | 
            +
                  it 'allows removing a single category and leaving the others alone' do
         | 
| 34 | 
            +
                    index[:title].remove 1
         | 
| 75 35 |  | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
             | 
| 79 | 
            -
                it 'is findable after adding' do
         | 
| 80 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 36 | 
            +
                    books.search('Title').ids.should == []
         | 
| 37 | 
            +
                    books.search('Author').ids.should == [1]
         | 
| 38 | 
            +
                  end
         | 
| 81 39 |  | 
| 82 | 
            -
                   | 
| 40 | 
            +
                  it 'allows adding a single category and leaving the others alone' do
         | 
| 41 | 
            +
                    index[:title].add Book.new(2, "Newtitle", "Newauthor")
         | 
| 83 42 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 43 | 
            +
                    books.search('Title').ids.should == [1]
         | 
| 44 | 
            +
                    books.search('Newtitle').ids.should == [2]
         | 
| 86 45 |  | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
                it 'is findable after replacing' do
         | 
| 91 | 
            -
                  books.search('Ne').ids.should == []
         | 
| 46 | 
            +
                    books.search('Author').ids.should == [1]
         | 
| 47 | 
            +
                    books.search('Newauthor').ids.should == []
         | 
| 48 | 
            +
                  end
         | 
| 92 49 |  | 
| 93 | 
            -
                   | 
| 50 | 
            +
                  it 'allows replacing a single category and leaving the others alone' do
         | 
| 51 | 
            +
                    index[:title].replace Book.new(1, "Replaced", "Notindexed")
         | 
| 94 52 |  | 
| 95 | 
            -
             | 
| 53 | 
            +
                    books.search('Title').ids.should == []
         | 
| 54 | 
            +
                    books.search('Replaced').ids.should == [1]
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                    books.search('Notindexed').ids.should == []
         | 
| 57 | 
            +
                    books.search('Author').ids.should == [1]
         | 
| 58 | 
            +
                  end
         | 
| 96 59 | 
             
                end
         | 
| 97 | 
            -
                it 'handles more complex cases' do
         | 
| 98 | 
            -
                  books.search('Ne').ids.should == []
         | 
| 99 60 |  | 
| 100 | 
            -
             | 
| 61 | 
            +
                context 'with partial' do
         | 
| 62 | 
            +
                  it 'finds the first entry' do
         | 
| 63 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 64 | 
            +
                  end
         | 
| 101 65 |  | 
| 102 | 
            -
                   | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
                   | 
| 106 | 
            -
             | 
| 107 | 
            -
                  books.search('Titl').ids.should == []
         | 
| 108 | 
            -
                  
         | 
| 109 | 
            -
                  index.replace Book.new(1, "Title New", "Author New")
         | 
| 110 | 
            -
             | 
| 111 | 
            -
                  books.search('title:Ne').ids.should == [1]
         | 
| 112 | 
            -
                end
         | 
| 113 | 
            -
              end
         | 
| 114 | 
            -
              
         | 
| 115 | 
            -
              context 'non-partial' do
         | 
| 116 | 
            -
                it 'finds the first entry' do
         | 
| 117 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 118 | 
            -
                end
         | 
| 66 | 
            +
                  it 'allows removing something' do
         | 
| 67 | 
            +
                    index.remove 1
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 70 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 119 71 |  | 
| 120 | 
            -
             | 
| 121 | 
            -
                  index.remove 1
         | 
| 122 | 
            -
                end
         | 
| 123 | 
            -
                it 'is not findable anymore after removing' do
         | 
| 124 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 72 | 
            +
                    index.remove 1
         | 
| 125 73 |  | 
| 126 | 
            -
             | 
| 74 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 75 | 
            +
                  end
         | 
| 127 76 |  | 
| 128 | 
            -
                   | 
| 129 | 
            -
             | 
| 77 | 
            +
                  it 'allows adding something' do
         | 
| 78 | 
            +
                    index.add Book.new(2, "Title2", "Author2")
         | 
| 79 | 
            +
                  end
         | 
| 80 | 
            +
                  it 'is findable after adding' do
         | 
| 81 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 130 82 |  | 
| 131 | 
            -
             | 
| 132 | 
            -
                  index.add Book.new(2, "Title2", "Author2")
         | 
| 133 | 
            -
                end
         | 
| 134 | 
            -
                it 'is findable after adding' do
         | 
| 135 | 
            -
                  books.search('Titl').ids.should == [1]
         | 
| 83 | 
            +
                    index.add Book.new(2, "Title New", "Author New")
         | 
| 136 84 |  | 
| 137 | 
            -
             | 
| 85 | 
            +
                    books.search('Titl').ids.should == [2,1]
         | 
| 86 | 
            +
                  end
         | 
| 138 87 |  | 
| 139 | 
            -
                   | 
| 140 | 
            -
             | 
| 88 | 
            +
                  it 'allows replacing something' do
         | 
| 89 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
                  it 'is findable after replacing' do
         | 
| 92 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 141 93 |  | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
                   | 
| 94 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                    books.search('Ne').ids.should == [1, 1]
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
                  it 'handles more complex cases' do
         | 
| 99 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                    books.search('title:Ne').ids.should == [1]
         | 
| 104 | 
            +
                  end
         | 
| 105 | 
            +
                  it 'handles more complex cases' do
         | 
| 106 | 
            +
                    index.remove 1
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 147 109 |  | 
| 148 | 
            -
             | 
| 110 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 149 111 |  | 
| 150 | 
            -
             | 
| 112 | 
            +
                    books.search('title:Ne').ids.should == [1]
         | 
| 113 | 
            +
                  end
         | 
| 151 114 | 
             
                end
         | 
| 152 | 
            -
                it 'handles more complex cases' do
         | 
| 153 | 
            -
                  books.search('Ne').ids.should == []
         | 
| 154 115 |  | 
| 155 | 
            -
             | 
| 116 | 
            +
                context 'non-partial' do
         | 
| 117 | 
            +
                  it 'finds the first entry' do
         | 
| 118 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 119 | 
            +
                  end
         | 
| 156 120 |  | 
| 157 | 
            -
                   | 
| 121 | 
            +
                  it 'allows removing something' do
         | 
| 122 | 
            +
                    index.remove 1
         | 
| 123 | 
            +
                  end
         | 
| 124 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 125 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                    index.remove 1
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  it 'allows adding something' do
         | 
| 133 | 
            +
                    index.add Book.new(2, "Title2", "Author2")
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
                  it 'is findable after adding' do
         | 
| 136 | 
            +
                    books.search('Titl').ids.should == [1]
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                    index.add Book.new(2, "Title New", "Author New")
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                    books.search('Titl').ids.should == [2,1]
         | 
| 141 | 
            +
                  end
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                  it 'allows replacing something' do
         | 
| 144 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 145 | 
            +
                  end
         | 
| 146 | 
            +
                  it 'is findable after replacing' do
         | 
| 147 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    books.search('Ne').ids.should == [1, 1]
         | 
| 152 | 
            +
                  end
         | 
| 153 | 
            +
                  it 'handles more complex cases' do
         | 
| 154 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                    books.search('title:Ne').ids.should == [1]
         | 
| 159 | 
            +
                  end
         | 
| 160 | 
            +
                  it 'handles more complex cases' do
         | 
| 161 | 
            +
                    index.remove 1
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 166 | 
            +
             | 
| 167 | 
            +
                    books.search('title:Ne').ids.should == [1]
         | 
| 168 | 
            +
                  end
         | 
| 158 169 | 
             
                end
         | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
                  
         | 
| 162 | 
            -
             | 
| 163 | 
            -
                  
         | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 170 | 
            +
             | 
| 171 | 
            +
                context 'similarity' do
         | 
| 172 | 
            +
                  it 'finds the first entry' do
         | 
| 173 | 
            +
                    books.search('Authr~').ids.should == [1]
         | 
| 174 | 
            +
                  end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                  it 'allows removing something' do
         | 
| 177 | 
            +
                    index.remove 1
         | 
| 178 | 
            +
                  end
         | 
| 179 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 180 | 
            +
                    books.search('Authr~').ids.should == [1]
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                    index.remove 1
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                    books.search('Authr~').ids.should == []
         | 
| 185 | 
            +
                  end
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                  it 'allows adding something' do
         | 
| 188 | 
            +
                    index.add Book.new(2, "Title2", "Author2")
         | 
| 189 | 
            +
                  end
         | 
| 190 | 
            +
                  it 'is findable after adding' do
         | 
| 191 | 
            +
                    books.search('Authr~').ids.should == [1]
         | 
| 192 | 
            +
             | 
| 193 | 
            +
                    index.add Book.new(2, "Title New", "Author New")
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                    books.search('Authr~').ids.should == [2,1]
         | 
| 196 | 
            +
                  end
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                  it 'allows replacing something' do
         | 
| 199 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 200 | 
            +
                  end
         | 
| 201 | 
            +
                  it 'is findable after replacing' do
         | 
| 202 | 
            +
                    books.search('Nuw~').ids.should == []
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                    books.search('Nuw~').ids.should == [1, 1] # TODO FIXME Not really what I'd expect.
         | 
| 207 | 
            +
                  end
         | 
| 208 | 
            +
                  it 'handles more complex cases' do
         | 
| 209 | 
            +
                    books.search('Now~').ids.should == []
         | 
| 210 | 
            +
             | 
| 211 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                    books.search('author:Now~').ids.should == [1]
         | 
| 214 | 
            +
                  end
         | 
| 215 | 
            +
                  it 'handles more complex cases' do
         | 
| 216 | 
            +
                    index.remove 1
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                    books.search('Athr~').ids.should == []
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                    index.replace Book.new(1, "Title New", "Author New")
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                    books.search('author:Athr~').ids.should == [1]
         | 
| 223 | 
            +
                  end
         | 
| 224 | 
            +
                  it 'handles more complex cases' do
         | 
| 225 | 
            +
                    books.search('Athr~').ids.should == [1]
         | 
| 226 | 
            +
             | 
| 227 | 
            +
                    index.replace Book.new(2, "Title New", "Author New")
         | 
| 228 | 
            +
                    index.add Book.new(3, "TTL", "AUTHR")
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                    books.search('author:Athr~').ids.should == [2, 1, 3] # TODO Is that what I'd expect?
         | 
| 231 | 
            +
                  end
         | 
| 167 232 | 
             
                end
         | 
| 168 233 | 
             
              end
         | 
| 169 | 
            -
             | 
| 170 | 
            -
              context ' | 
| 171 | 
            -
                 | 
| 172 | 
            -
                   | 
| 234 | 
            +
             | 
| 235 | 
            +
              context 'special index' do
         | 
| 236 | 
            +
                let(:index) do
         | 
| 237 | 
            +
                  Picky::Index.new(:books) do
         | 
| 238 | 
            +
                    key_format :to_sym
         | 
| 239 | 
            +
                    source []
         | 
| 240 | 
            +
                    category :title
         | 
| 241 | 
            +
                    category :author, similarity: Picky::Generators::Similarity::DoubleMetaphone.new(3)
         | 
| 242 | 
            +
                  end
         | 
| 173 243 | 
             
                end
         | 
| 244 | 
            +
                let(:books) { Picky::Search.new index }
         | 
| 174 245 |  | 
| 175 | 
            -
                 | 
| 176 | 
            -
                  index. | 
| 246 | 
            +
                before(:each) do
         | 
| 247 | 
            +
                  index.add Book.new("one", "Title", "Author")
         | 
| 177 248 | 
             
                end
         | 
| 178 | 
            -
                it 'is not findable anymore after removing' do
         | 
| 179 | 
            -
                  books.search('Authr~').ids.should == [1]
         | 
| 180 249 |  | 
| 181 | 
            -
             | 
| 250 | 
            +
                context 'single category updating' do
         | 
| 251 | 
            +
                  it 'finds the first entry' do
         | 
| 252 | 
            +
                    books.search('title:Titl').ids.should == [:one]
         | 
| 253 | 
            +
                  end
         | 
| 182 254 |  | 
| 183 | 
            -
                   | 
| 184 | 
            -
             | 
| 255 | 
            +
                  it 'allows removing a single category and leaving the others alone' do
         | 
| 256 | 
            +
                    index[:title].remove "one"
         | 
| 185 257 |  | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
                it 'is findable after adding' do
         | 
| 190 | 
            -
                  books.search('Authr~').ids.should == [1]
         | 
| 258 | 
            +
                    books.search('Title').ids.should == []
         | 
| 259 | 
            +
                    books.search('Author').ids.should == [:one]
         | 
| 260 | 
            +
                  end
         | 
| 191 261 |  | 
| 192 | 
            -
                   | 
| 262 | 
            +
                  it 'allows adding a single category and leaving the others alone' do
         | 
| 263 | 
            +
                    index[:title].add Book.new("two", "Newtitle", "Newauthor")
         | 
| 193 264 |  | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 265 | 
            +
                    books.search('Title').ids.should == [:one]
         | 
| 266 | 
            +
                    books.search('Newtitle').ids.should == [:two]
         | 
| 196 267 |  | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 201 | 
            -
                   | 
| 268 | 
            +
                    books.search('Author').ids.should == [:one]
         | 
| 269 | 
            +
                    books.search('Newauthor').ids.should == []
         | 
| 270 | 
            +
                  end
         | 
| 271 | 
            +
             | 
| 272 | 
            +
                  it 'allows replacing a single category and leaving the others alone' do
         | 
| 273 | 
            +
                    index[:title].replace Book.new("one", "Replaced", "Notindexed")
         | 
| 202 274 |  | 
| 203 | 
            -
             | 
| 275 | 
            +
                    books.search('Title').ids.should == []
         | 
| 276 | 
            +
                    books.search('Replaced').ids.should == [:one]
         | 
| 204 277 |  | 
| 205 | 
            -
             | 
| 278 | 
            +
                    books.search('Notindexed').ids.should == []
         | 
| 279 | 
            +
                    books.search('Author').ids.should == [:one]
         | 
| 280 | 
            +
                  end
         | 
| 206 281 | 
             
                end
         | 
| 207 | 
            -
                it 'handles more complex cases' do
         | 
| 208 | 
            -
                  books.search('Now~').ids.should == []
         | 
| 209 282 |  | 
| 210 | 
            -
             | 
| 283 | 
            +
                context 'with partial' do
         | 
| 284 | 
            +
                  it 'finds the first entry' do
         | 
| 285 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 286 | 
            +
                  end
         | 
| 287 | 
            +
             | 
| 288 | 
            +
                  it 'allows removing something' do
         | 
| 289 | 
            +
                    index.remove "one"
         | 
| 290 | 
            +
                  end
         | 
| 291 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 292 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 293 | 
            +
             | 
| 294 | 
            +
                    index.remove "one"
         | 
| 295 | 
            +
             | 
| 296 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 297 | 
            +
                  end
         | 
| 298 | 
            +
             | 
| 299 | 
            +
                  it 'allows adding something' do
         | 
| 300 | 
            +
                    index.add Book.new("two", "Title2", "Author2")
         | 
| 301 | 
            +
                  end
         | 
| 302 | 
            +
                  it 'is findable after adding' do
         | 
| 303 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 304 | 
            +
             | 
| 305 | 
            +
                    index.add Book.new("two", "Title New", "Author New")
         | 
| 211 306 |  | 
| 212 | 
            -
             | 
| 307 | 
            +
                    books.search('Titl').ids.should == [:two,:one]
         | 
| 308 | 
            +
                  end
         | 
| 309 | 
            +
             | 
| 310 | 
            +
                  it 'allows replacing something' do
         | 
| 311 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 312 | 
            +
                  end
         | 
| 313 | 
            +
                  it 'is findable after replacing' do
         | 
| 314 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 315 | 
            +
             | 
| 316 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 317 | 
            +
             | 
| 318 | 
            +
                    books.search('Ne').ids.should == [:one, :one]
         | 
| 319 | 
            +
                  end
         | 
| 320 | 
            +
                  it 'handles more complex cases' do
         | 
| 321 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 322 | 
            +
             | 
| 323 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 324 | 
            +
             | 
| 325 | 
            +
                    books.search('title:Ne').ids.should == [:one]
         | 
| 326 | 
            +
                  end
         | 
| 327 | 
            +
                  it 'handles more complex cases' do
         | 
| 328 | 
            +
                    index.remove "one"
         | 
| 329 | 
            +
             | 
| 330 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 331 | 
            +
             | 
| 332 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 333 | 
            +
             | 
| 334 | 
            +
                    books.search('title:Ne').ids.should == [:one]
         | 
| 335 | 
            +
                  end
         | 
| 213 336 | 
             
                end
         | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 216 | 
            -
                  
         | 
| 217 | 
            -
             | 
| 218 | 
            -
                  
         | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 337 | 
            +
             | 
| 338 | 
            +
                context 'non-partial' do
         | 
| 339 | 
            +
                  it 'finds the first entry' do
         | 
| 340 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 341 | 
            +
                  end
         | 
| 342 | 
            +
             | 
| 343 | 
            +
                  it 'allows removing something' do
         | 
| 344 | 
            +
                    index.remove "one"
         | 
| 345 | 
            +
                  end
         | 
| 346 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 347 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 348 | 
            +
             | 
| 349 | 
            +
                    index.remove :one
         | 
| 350 | 
            +
             | 
| 351 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 352 | 
            +
                  end
         | 
| 353 | 
            +
             | 
| 354 | 
            +
                  it 'allows adding something' do
         | 
| 355 | 
            +
                    index.add Book.new("two", "Title2", "Author2")
         | 
| 356 | 
            +
                  end
         | 
| 357 | 
            +
                  it 'is findable after adding' do
         | 
| 358 | 
            +
                    books.search('Titl').ids.should == [:one]
         | 
| 359 | 
            +
             | 
| 360 | 
            +
                    index.add Book.new("two", "Title New", "Author New")
         | 
| 361 | 
            +
             | 
| 362 | 
            +
                    books.search('Titl').ids.should == [:two,:one]
         | 
| 363 | 
            +
                  end
         | 
| 364 | 
            +
             | 
| 365 | 
            +
                  it 'allows replacing something' do
         | 
| 366 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 367 | 
            +
                  end
         | 
| 368 | 
            +
                  it 'is findable after replacing' do
         | 
| 369 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 370 | 
            +
             | 
| 371 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 372 | 
            +
             | 
| 373 | 
            +
                    books.search('Ne').ids.should == [:one, :one]
         | 
| 374 | 
            +
                  end
         | 
| 375 | 
            +
                  it 'handles more complex cases' do
         | 
| 376 | 
            +
                    books.search('Ne').ids.should == []
         | 
| 377 | 
            +
             | 
| 378 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 379 | 
            +
             | 
| 380 | 
            +
                    books.search('title:Ne').ids.should == [:one]
         | 
| 381 | 
            +
                  end
         | 
| 382 | 
            +
                  it 'handles more complex cases' do
         | 
| 383 | 
            +
                    index.remove "one"
         | 
| 384 | 
            +
             | 
| 385 | 
            +
                    books.search('Titl').ids.should == []
         | 
| 386 | 
            +
             | 
| 387 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 388 | 
            +
             | 
| 389 | 
            +
                    books.search('title:Ne').ids.should == [:one]
         | 
| 390 | 
            +
                  end
         | 
| 222 391 | 
             
                end
         | 
| 223 | 
            -
                it 'handles more complex cases' do
         | 
| 224 | 
            -
                  books.search('Athr~').ids.should == [1]
         | 
| 225 | 
            -
                  
         | 
| 226 | 
            -
                  index.replace Book.new(2, "Title New", "Author New")
         | 
| 227 | 
            -
                  index.add Book.new(3, "TTL", "AUTHR")
         | 
| 228 392 |  | 
| 229 | 
            -
             | 
| 393 | 
            +
                context 'similarity' do
         | 
| 394 | 
            +
                  it 'finds the first entry' do
         | 
| 395 | 
            +
                    books.search('Authr~').ids.should == [:one]
         | 
| 396 | 
            +
                  end
         | 
| 397 | 
            +
             | 
| 398 | 
            +
                  it 'allows removing something' do
         | 
| 399 | 
            +
                    index.remove "one"
         | 
| 400 | 
            +
                  end
         | 
| 401 | 
            +
                  it 'is not findable anymore after removing' do
         | 
| 402 | 
            +
                    books.search('Authr~').ids.should == [:one]
         | 
| 403 | 
            +
             | 
| 404 | 
            +
                    index.remove "one"
         | 
| 405 | 
            +
             | 
| 406 | 
            +
                    books.search('Authr~').ids.should == []
         | 
| 407 | 
            +
                  end
         | 
| 408 | 
            +
             | 
| 409 | 
            +
                  it 'allows adding something' do
         | 
| 410 | 
            +
                    index.add Book.new("two", "Title2", "Author2")
         | 
| 411 | 
            +
                  end
         | 
| 412 | 
            +
                  it 'is findable after adding' do
         | 
| 413 | 
            +
                    books.search('Authr~').ids.should == [:one]
         | 
| 414 | 
            +
             | 
| 415 | 
            +
                    index.add Book.new("two", "Title New", "Author New")
         | 
| 416 | 
            +
             | 
| 417 | 
            +
                    books.search('Authr~').ids.should == [:two,:one]
         | 
| 418 | 
            +
                  end
         | 
| 419 | 
            +
             | 
| 420 | 
            +
                  it 'allows replacing something' do
         | 
| 421 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 422 | 
            +
                  end
         | 
| 423 | 
            +
                  it 'is findable after replacing' do
         | 
| 424 | 
            +
                    books.search('Nuw~').ids.should == []
         | 
| 425 | 
            +
             | 
| 426 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 427 | 
            +
             | 
| 428 | 
            +
                    books.search('Nuw~').ids.should == [:one, :one] # TODO FIXME Not really what I'd expect.
         | 
| 429 | 
            +
                  end
         | 
| 430 | 
            +
                  it 'handles more complex cases' do
         | 
| 431 | 
            +
                    books.search('Now~').ids.should == []
         | 
| 432 | 
            +
             | 
| 433 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 434 | 
            +
             | 
| 435 | 
            +
                    books.search('author:Now~').ids.should == [:one]
         | 
| 436 | 
            +
                  end
         | 
| 437 | 
            +
                  it 'handles more complex cases' do
         | 
| 438 | 
            +
                    index.remove "one"
         | 
| 439 | 
            +
             | 
| 440 | 
            +
                    books.search('Athr~').ids.should == []
         | 
| 441 | 
            +
             | 
| 442 | 
            +
                    index.replace Book.new("one", "Title New", "Author New")
         | 
| 443 | 
            +
             | 
| 444 | 
            +
                    books.search('author:Athr~').ids.should == [:one]
         | 
| 445 | 
            +
                  end
         | 
| 446 | 
            +
                  it 'handles more complex cases' do
         | 
| 447 | 
            +
                    books.search('Athr~').ids.should == [:one]
         | 
| 448 | 
            +
             | 
| 449 | 
            +
                    index.replace Book.new("two", "Title New", "Author New")
         | 
| 450 | 
            +
                    index.add Book.new("three", "TTL", "AUTHR")
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                    books.search('author:Athr~').ids.should == [:two, :one, :three] # TODO Is that what I'd expect?
         | 
| 453 | 
            +
                  end
         | 
| 230 454 | 
             
                end
         | 
| 231 455 | 
             
              end
         | 
| 232 | 
            -
             | 
| 456 | 
            +
             | 
| 233 457 | 
             
            end
         |