Sha256: c36ce5963ccd542eee9994b5bbcd2257222d86c0db2b7fa348be932b93a935e2

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

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

describe 'keyword search' do
  before :all do
    Sunspot.remove_all
    @posts = []
    @posts << Post.new(:title => 'The toast elects the insufficient spirit',
                       :body => 'Does the wind write?')
    @posts << Post.new(:title => 'A nail abbreviates the recovering insight outside the moron',
                       :body => 'The interpreted strain scans the buffer around the upper temper')
    @posts << Post.new(:title => 'The toast abbreviates the recovering spirit',
                       :body => 'Does the wind interpret the buffer?')
    Sunspot.index!(*@posts)
  end

  it 'matches a single keyword out of a single field' do
    results = Sunspot.search(Post) { keywords 'toast' }.results
    [0, 2].each { |i| results.should include(@posts[i]) }
    [1].each { |i| results.should_not include(@posts[i]) }
  end

  it 'matches multiple words out of a single field' do
    results = Sunspot.search(Post) { keywords 'elects toast' }.results
    results.should == [@posts[0]]
  end

  it 'matches multiple words in multiple fields' do
    results = Sunspot.search(Post) { keywords 'toast wind' }.results
    [0, 2].each { |i| results.should include(@posts[i]) }
    [1].each { |i| results.should_not include(@posts[i]) }
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
outoftime-sunspot-0.7.0 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.7.1 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.7.2 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.7.3 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.0 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.1 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.2 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.3 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.4 spec/integration/keyword_search_spec.rb
outoftime-sunspot-0.8.5 spec/integration/keyword_search_spec.rb
pallan-sunspot-0.8.3 spec/integration/keyword_search_spec.rb