Sha256: 4866f19ff0e99d4f1b2337593cf66369d9522860564520a7fc258b1dcace7444

Contents?: true

Size: 963 Bytes

Versions: 21

Compression:

Stored size: 963 Bytes

Contents

# encoding: utf-8
#
require 'spec_helper'
require 'ostruct'

describe "Array IDs" do

  let(:index) { Picky::Index.new :arrays }
  let(:try) { Picky::Search.new index }

  # This tests the weights option.
  #
  it 'can use Arrays as IDs' do
    index.category :text1

    thing = OpenStruct.new id: ['id1', 'thing1'], text1: "ohai"
    other = OpenStruct.new id: ['id2', 'thing2'], text1: "ohai kthxbye"

    index.add thing
    index.add other

    try.search("text1:ohai").ids.should == [
      ["id2", "thing2"],
      ["id1", "thing1"]
    ]
  end

  # This tests the weights option.
  #
  it 'can use split as key_format' do
    index.key_format :split
    index.category :text1

    thing = OpenStruct.new id: "id1 thing1", text1: "ohai"
    other = OpenStruct.new id: "id2 thing2", text1: "ohai kthxbye"

    index.add thing
    index.add other

    try.search("text1:ohai").ids.should == [
      ["id2", "thing2"],
      ["id1", "thing1"]
    ]
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
picky-4.31.3 spec/functional/arrays_as_ids_spec.rb
picky-4.31.2 spec/functional/arrays_as_ids_spec.rb
picky-4.31.1 spec/functional/arrays_as_ids_spec.rb
picky-4.31.0 spec/functional/arrays_as_ids_spec.rb
picky-4.30.0 spec/functional/arrays_as_ids_spec.rb
picky-4.29.0 spec/functional/arrays_as_ids_spec.rb
picky-4.28.1 spec/functional/arrays_as_ids_spec.rb
picky-4.27.1 spec/functional/arrays_as_ids_spec.rb
picky-4.27.0 spec/functional/arrays_as_ids_spec.rb
picky-4.26.2 spec/functional/arrays_as_ids_spec.rb
picky-4.26.1 spec/functional/arrays_as_ids_spec.rb
picky-4.26.0 spec/functional/arrays_as_ids_spec.rb
picky-4.25.3 spec/functional/arrays_as_ids_spec.rb
picky-4.25.2 spec/functional/arrays_as_ids_spec.rb
picky-4.25.1 spec/functional/arrays_as_ids_spec.rb
picky-4.25.0 spec/functional/arrays_as_ids_spec.rb
picky-4.24.0 spec/functional/arrays_as_ids_spec.rb
picky-4.23.2 spec/functional/arrays_as_ids_spec.rb
picky-4.23.1 spec/functional/arrays_as_ids_spec.rb
picky-4.23.0 spec/functional/arrays_as_ids_spec.rb