Sha256: 73254beaf7a6af9522f8c536b005509e2280712c33dfe7ba524d87f6051da384

Contents?: true

Size: 996 Bytes

Versions: 5

Compression:

Stored size: 996 Bytes

Contents

require File.expand_path('spec_helper', File.dirname(__FILE__))

describe 'indexing' do
  it 'should index non-multivalued field with newlines' do
    lambda do
      Sunspot.index!(Post.new(:title => "A\nTitle"))
    end.should_not raise_error
  end

  it 'should correctly remove by model instance' do
    post = Post.new(:title => 'test post')
    Sunspot.index!(post)
    Sunspot.remove!(post)
    Sunspot.search(Post) { with(:title, 'test post') }.results.should be_empty
  end

  it 'should correctly delete by ID' do
    post = Post.new(:title => 'test post')
    Sunspot.index!(post)
    Sunspot.remove_by_id!(Post, post.id)
    Sunspot.search(Post) { with(:title, 'test post') }.results.should be_empty
  end

  it 'removes documents by query' do
    Sunspot.remove_all!
    posts = [Post.new(:title => 'birds'), Post.new(:title => 'monkeys')]
    Sunspot.index!(posts)
    Sunspot.remove! do
      with(:title, 'birds')
    end
    Sunspot.search(Post).should have(2).results
  end
end

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
pduey-sunspot-1.2.1.1 spec/integration/indexing_spec.rb
erichummel-sunspot-1.2.1 spec/integration/indexing_spec.rb
lisausa-sunspot-1.2.1 spec/integration/indexing_spec.rb
sunspot_rbg-1.3.1 spec/integration/indexing_spec.rb
sunspot_rbg-1.3.0 spec/integration/indexing_spec.rb