Sha256: ebe2bdc653158595e60eca08f6cdc056eced7644188d30d88ac06d01c7a46e82

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8

require 'acceptance/spec_helper'

describe 'Accessing excerpts for methods on a search result', :live => true do
  it "returns excerpts for a given method" do
    Book.create! :title => 'American Gods', :year => 2001
    index

    search = Book.search('gods')
    search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane

    search.first.excerpts.title.
      should == 'American <span class="match">Gods</span>'
  end

  it "handles UTF-8 text for excerpts" do
    Book.create! :title => 'Война и миръ', :year => 1869
    index

    search = Book.search 'миръ'
    search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane

    search.first.excerpts.title.
      should == 'Война и <span class="match">миръ</span>'
  end

  it "does not include class names in excerpts" do
    Book.create! :title => 'The Graveyard Book'
    index

    search = Book.search('graveyard')
    search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane

    search.first.excerpts.title.
      should == 'The <span class="match">Graveyard</span> Book'
  end

  it "respects the star option with queries" do
    Article.create! :title => 'Something'
    index

    search = Article.search('thin', :star => true)
    search.context[:panes] << ThinkingSphinx::Panes::ExcerptsPane

    search.first.excerpts.title.
      should == '<span class="match">Something</span>'
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.3 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.1.2 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.1.1 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.1.0 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.0.6 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.0.5 spec/acceptance/excerpts_spec.rb
thinking-sphinx-3.0.4 spec/acceptance/excerpts_spec.rb