spec/util_spec.rb in mongoid_search-0.2.6 vs spec/util_spec.rb in mongoid_search-0.2.7
- old
+ new
@@ -1,44 +1,44 @@
# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Util do
it "should return an empty array if no text is passed" do
- Util.keywords("", false, "").should == []
+ Util.normalize_keywords("", false, "").should == []
end
it "should return an array of keywords" do
- Util.keywords("keyword", false, "").class.should == Array
+ Util.normalize_keywords("keyword", false, "").class.should == Array
end
it "should return an array of strings" do
- Util.keywords("keyword", false, "").first.class.should == String
+ Util.normalize_keywords("keyword", false, "").first.class.should == String
end
it "should remove accents from the text passed" do
- Util.keywords("café", false, "").should == ["cafe"]
+ Util.normalize_keywords("café", false, "").should == ["cafe"]
end
it "should downcase the text passed" do
- Util.keywords("CaFé", false, "").should == ["cafe"]
+ Util.normalize_keywords("CaFé", false, "").should == ["cafe"]
end
it "should split whitespaces, hifens, dots, underlines, etc.." do
- Util.keywords("CaFé-express.com delicious;come visit, and 'win' an \"iPad\"", false, "").should == ["cafe", "express", "com", "delicious", "come", "visit", "and", "win", "an", "ipad"]
+ Util.normalize_keywords("CaFé-express.com delicious;come visit, and 'win' an \"iPad\"", false, "").should == ["cafe", "express", "com", "delicious", "come", "visit", "and", "win", "an", "ipad"]
end
it "should stem keywords" do
- Util.keywords("A runner running and eating", true, "").should == ["runner", "run", "and", "eat"]
+ Util.normalize_keywords("A runner running and eating", true, "").should == ["runner", "run", "and", "eat"]
end
it "should ignore keywords from ignore list" do
- Util.keywords("An amazing awesome runner running and eating", true, YAML.load(File.open(File.dirname(__FILE__) + '/config/ignorelist.yml'))["ignorelist"]).should == ["an", "runner", "run", "and", "eat"]
+ Util.normalize_keywords("An amazing awesome runner running and eating", true, YAML.load(File.open(File.dirname(__FILE__) + '/config/ignorelist.yml'))["ignorelist"]).should == ["an", "runner", "run", "and", "eat"]
end
it "should ignore keywords with less than two words" do
- Util.keywords("A runner running", false, "").should_not include "a"
+ Util.normalize_keywords("A runner running", false, "").should_not include "a"
end
it "should not ignore numbers" do
- Util.keywords("Ford T 1908", false, "").should include "1908"
+ Util.normalize_keywords("Ford T 1908", false, "").should include "1908"
end
end