Sha256: 50ee4e17cecb196c469a5e83902cf9237c70b77a27bc5be222960ab325b15ba6

Contents?: true

Size: 1.26 KB

Versions: 27

Compression:

Stored size: 1.26 KB

Contents

require 'spec/spec_helper'

describe ThinkingSphinx::Excerpter do
  before :each do
    @alpha      = Alpha.find(:first)
    @search     = mock 'search', :excerpt_for => 'excerpted value'
    @excerpter  = ThinkingSphinx::Excerpter.new(@search, @alpha)
  end
  
  it "should not respond to id" do
    @excerpter.should_not respond_to(:id)
  end
  
  describe '#method_missing' do
    it "should return the excerpt from Sphinx" do
      @excerpter.name.should == 'excerpted value'
    end
    
    it "should send through the instance class to excerpt_for" do
      @search.should_receive(:excerpt_for) do |string, model|
        model.should == Alpha
      end
      
      @excerpter.name
    end
    
    it "should use attribute methods for excerpts calls" do
      @search.should_receive(:excerpt_for) do |string, model|
        string.should == 'one'
      end
      
      @excerpter.name
    end
    
    it "should use instance methods for excerpts calls" do
      @search.should_receive(:excerpt_for) do |string, model|
        string.should == 'ONE'
      end
      
      @excerpter.big_name
    end
    
    it "should still raise an exception if no column or method exists" do
      lambda {
        @excerpter.foo
      }.should raise_error(NoMethodError)
    end
  end
end

Version data entries

27 entries across 27 versions & 12 rubygems

Version Path
DrMark-thinking-sphinx-1.2.5 spec/lib/thinking_sphinx/excerpter_spec.rb
DrMark-thinking-sphinx-1.2.6 spec/lib/thinking_sphinx/excerpter_spec.rb
bterlson-thinking-sphinx-1.2.8 spec/lib/thinking_sphinx/excerpter_spec.rb
ebeigarts-thinking-sphinx-1.2.10 spec/lib/thinking_sphinx/excerpter_spec.rb
factorylabs-thinking-sphinx-1.2.7 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.0 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.1 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.10 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.11 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.2 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.3 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.4 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.5 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.6 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.7 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.8 spec/lib/thinking_sphinx/excerpter_spec.rb
freelancing-god-thinking-sphinx-1.2.9 spec/lib/thinking_sphinx/excerpter_spec.rb
hariton-thinking-sphinx-1.2.11.2 spec/lib/thinking_sphinx/excerpter_spec.rb
hariton-thinking-sphinx-1.2.11 spec/lib/thinking_sphinx/excerpter_spec.rb
hariton-thinking-sphinx-1.2.7.0 spec/lib/thinking_sphinx/excerpter_spec.rb