Sha256: af49bfe46863971e49af1e61a1f86f64c51a282088acccc10925311463ff1881

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# encoding: utf-8

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Mongoid::Search do
  
  before(:each) do
    @product = Product.create :brand => "Apple", :name => "iPhone", :tags => ["Amazing", "Awesome", "Olé"].map { |tag| Tag.new(:name => tag) }
  end
  
  it "should set the _keywords field" do
    @product._keywords.should == ["apple", "iphone", "amazing", "awesome", "ole"]
  end
    
  it "should return results in search" do
    Product.search("apple").size.should == 1
  end
      
  it "should return results in search even searching a accented word" do
    Product.search("Ole").size.should == 1
    Product.search("Olé").size.should == 1
  end
       
  it "should return results in search even if the case doesn't match" do
    Product.search("oLe").size.should == 1
  end
      
  it "should return results in search with a partial word" do
    Product.search("iph").size.should == 1
  end
        
  it "should return results for any matching word with default search" do
    Product.search("apple motorola").size.should == 1
  end
          
  it "should not return results when all words do not match, if using :match => :all" do
    Product.match = :all
    Product.search("apple motorola").size.should == 0
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid_search-0.1.2 spec/mongoid_search_spec.rb
mongoid_search-0.1.1 spec/mongoid_search_spec.rb