Sha256: a6c638e2db387701c3d90420dcf9587d91ae1d1a63c099741bd809175d74ba3d

Contents?: true

Size: 1.57 KB

Versions: 16

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module ThinkingSphinx
  module Panes; end
end

require 'thinking_sphinx/panes/excerpts_pane'

describe ThinkingSphinx::Panes::ExcerptsPane do
  let(:pane)    {
    ThinkingSphinx::Panes::ExcerptsPane.new context, object, raw }
  let(:context) { {:indices => [double(:name => 'foo_core')]} }
  let(:object)  { double('object') }
  let(:raw)     { {} }
  let(:search)  { double('search', :query => 'foo', :options => {}) }

  before :each do
    allow(context).to receive_messages :search => search
  end

  describe '#excerpts' do
    let(:excerpter) { double('excerpter') }
    let(:excerpts)  { double('excerpts object') }

    before :each do
      stub_const 'ThinkingSphinx::Excerpter', double(:new => excerpter)
      allow(ThinkingSphinx::Panes::ExcerptsPane::Excerpts).to receive_messages :new => excerpts
    end

    it "returns an excerpt glazing" do
      expect(pane.excerpts).to eq(excerpts)
    end

    it "creates an excerpter with the first index and the query and conditions values" do
      context[:indices] = [double(:name => 'alpha'), double(:name => 'beta')]
      context.search.options[:conditions] = {:baz => 'bar'}

      expect(ThinkingSphinx::Excerpter).to receive(:new).
        with('alpha', 'foo bar', anything).and_return(excerpter)

      pane.excerpts
    end

    it "passes through excerpts options" do
      search.options[:excerpts] = {:before_match => 'foo'}

      expect(ThinkingSphinx::Excerpter).to receive(:new).
        with(anything, anything, :before_match => 'foo').and_return(excerpter)

      pane.excerpts
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
thinking-sphinx-5.5.1 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.5.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.4.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.3.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.2.1 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.2.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.1.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-5.0.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.4.1 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.4.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.3.2 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.3.1 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.3.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.2.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.1.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb
thinking-sphinx-4.0.0 spec/thinking_sphinx/panes/excerpts_pane_spec.rb