Sha256: a967f22c4740f5e9186c7119c325ccd4d228ed9dc40cf08fb8abcb550b341426
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 # require 'spec_helper' describe "id option" do it 'can be given a different id (in-ruby based)' do data = Picky::Index.new :id do id :number category :text end require 'ostruct' thing = OpenStruct.new number: 1, text: "ohai" other = OpenStruct.new number: 2, text: "ohai kthxbye" data.add thing data.add other try = Picky::Search.new data try.search("text:kthxbye").ids.should == [2] end it 'can be given a different id (source based)' do require 'ostruct' things = [] things << OpenStruct.new(number: 1, text: "ohai") things << OpenStruct.new(number: 2, text: "ohai kthxbye") data = Picky::Index.new :id do source { things } key_format :to_i id :number # TODO :format => :to_i category :text end data.index try = Picky::Search.new data try.search("text:kthxbye").ids.should == [2] end it 'default is id' do index = Picky::Index.new :id do category :text end require 'ostruct' thing = OpenStruct.new id: 1, text: "ohai" other = OpenStruct.new id: 2, text: "ohai kthxbye" index.add thing index.add other try = Picky::Search.new index try.search("text:kthxbye").ids.should == [2] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
picky-4.21.1 | spec/functional/id_spec.rb |