Sha256: ec84974b0d6d344304b731eb81a2f7cfc2694ba3392a58fd2d4ed45f69df3dca
Contents?: true
Size: 1.29 KB
Versions: 14
Compression:
Stored size: 1.29 KB
Contents
require File.join(File.dirname(__FILE__), 'spec_helper') describe 'more_like_this' do before :all do Sunspot.remove_all @posts = [ Post.new(:body => "one two three", :tags => %w(ruby sunspot rsolr)), Post.new(:body => "four five six", :tags => %w(ruby solr lucene)), Post.new(:body => "two three four", :tags => %w(python sqlalchemy)), Post.new(:body => "three four five", :tags => %w(ruby sunspot mat)), Post.new(:body => "six seven eight", :tags => %w(bogus airplane)) ] Sunspot.index!(@posts) end it 'should return results for all MLT fields' do Sunspot.more_like_this(@posts.first).results.to_set.should == @posts[1..3].to_set end it 'should return results for specified text field' do Sunspot.more_like_this(@posts.first) do fields :body end.results.to_set.should == @posts[2..3].to_set end it 'should return empty result set if no results' do Sunspot.more_like_this(@posts.last) do with(:title, 'bogus') end.results.should == [] end describe 'when non-indexed object searched' do before(:each) { @mlt = Sunspot.more_like_this(Post.new) } it 'should return empty result set' do @mlt.results.should == [] end it 'shoult return a total of 0' do @mlt.total.should == 0 end end end
Version data entries
14 entries across 14 versions & 5 rubygems