Sha256: 313457c4c486208b5ae03a821857de0d2b3189ac8b6a758a847df2b5ac17c655

Contents?: true

Size: 1.25 KB

Versions: 55

Compression:

Stored size: 1.25 KB

Contents

require '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

55 entries across 55 versions & 6 rubygems

Version Path
friendlyfashion-thinking-sphinx-2.0.14.4 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.14.3 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.1.0 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.5.0 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.14.2 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.14.1 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.0.14 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.4.14 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.13.3 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.13.2 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.13.1 spec/thinking_sphinx/excerpter_spec.rb
friendlyfashion-thinking-sphinx-2.0.13 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.0.13 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.4.13 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.0.12 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.4.12 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.0.11 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.4.11 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-2.0.10 spec/thinking_sphinx/excerpter_spec.rb
thinking-sphinx-1.4.10 spec/thinking_sphinx/excerpter_spec.rb