Sha256: 1c93745e3086df6ced68326ca048ac456512f85f22a3b5edda49fffffa74c4d2
Contents?: true
Size: 1.5 KB
Versions: 38
Compression:
Stored size: 1.5 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 escape the text in the excerpt" do @search.should_receive(:excerpt_for) do |string, model| string.should == 'test "escaping" <characters>' end @excerpter.string_to_escape 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
38 entries across 38 versions & 7 rubygems