Sha256: 1835c3b2056b6bba5692ddd0d42d0e5a833d747eff17c57febd8c62c4abaa6ef

Contents?: true

Size: 810 Bytes

Versions: 38

Compression:

Stored size: 810 Bytes

Contents

describe 'keyword highlighting' do
  before :all do
    @posts = []
    @posts << Post.new(:body => 'And the fox laughed')
    @posts << Post.new(:body => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', :blog_id => 1)
    Sunspot.index!(*@posts)
    @search_result = Sunspot.search(Post) { keywords 'fox', :highlight => true }
  end
  
  it 'should include highlights in the results' do
    @search_result.hits.first.highlights.length.should == 1
  end
  
  it 'should return formatted highlight fragments' do
    @search_result.hits.first.highlights(:body).first.format.should == 'And the <em>fox</em> laughed'
  end
  
  it 'should be empty for non-keyword searches' do
    search_result = Sunspot.search(Post){ with :blog_id, 1 }
    search_result.hits.first.highlights.should be_empty
  end
end

Version data entries

38 entries across 38 versions & 9 rubygems

Version Path
benjaminkrause-sunspot-0.9.7 spec/integration/highlighting_spec.rb
benjaminkrause-sunspot-0.9.8 spec/integration/highlighting_spec.rb
erichummel-sunspot-1.2.1g spec/integration/highlighting_spec.rb
erichummel-sunspot-1.2.1f spec/integration/highlighting_spec.rb
erichummel-sunspot-1.2.1b spec/integration/highlighting_spec.rb
erichummel-sunspot-1.2.1a spec/integration/highlighting_spec.rb
erichummel-sunspot-1.2.1 spec/integration/highlighting_spec.rb
lisausa-sunspot-1.2.1.1 spec/integration/highlighting_spec.rb
lisausa-sunspot-1.2.1 spec/integration/highlighting_spec.rb
sunspot_rbg-1.3.1 spec/integration/highlighting_spec.rb
sunspot_rbg-1.3.0 spec/integration/highlighting_spec.rb
ruben-sunspot-1.1.4 spec/integration/highlighting_spec.rb
ruben-sunspot-1.1.3 spec/integration/highlighting_spec.rb
ruben-sunspot-1.1.2 spec/integration/highlighting_spec.rb
sunspot-1.2.1 spec/integration/highlighting_spec.rb
sunspot-1.2.0 spec/integration/highlighting_spec.rb
ruben-sunspot-1.1.1 spec/integration/highlighting_spec.rb
ruben-sunspot-1.1.0 spec/integration/highlighting_spec.rb
nuatt_sunspot-1.1.0.3 spec/integration/highlighting_spec.rb
sunspot-1.1.0 spec/integration/highlighting_spec.rb