Sha256: 38a8c6598fb3fde182e3d3c35092583374bc466fb75a2b498f2eb1aaa9e5f085
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
require "spec_helper" describe PgSearch::Features::DMetaphone do describe "#rank" do with_model :Model do table do |t| t.string :name t.text :content end end it "returns an expression similar to a TSearch, but wraps the arguments in pg_search_dmetaphone()" do query = "query" columns = [ PgSearch::Configuration::Column.new(:name, nil, Model), PgSearch::Configuration::Column.new(:content, nil, Model), ] options = {} config = stub(:config, :ignore => []) normalizer = PgSearch::Normalizer.new(config) feature = described_class.new(query, options, columns, Model, normalizer) feature.rank.to_sql.should == %Q{(ts_rank((to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."name"::text, ''))) || to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."content"::text, '')))), (to_tsquery('simple', ''' ' || pg_search_dmetaphone('query') || ' ''')), 0))} end end describe "#conditions" do with_model :Model do table do |t| t.string :name t.text :content end end it "returns an expression similar to a TSearch, but wraps the arguments in pg_search_dmetaphone()" do query = "query" columns = [ PgSearch::Configuration::Column.new(:name, nil, Model), PgSearch::Configuration::Column.new(:content, nil, Model), ] options = {} config = stub(:config, :ignore => []) normalizer = PgSearch::Normalizer.new(config) feature = described_class.new(query, options, columns, Model, normalizer) feature.conditions.to_sql.should == %Q{((to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."name"::text, ''))) || to_tsvector('simple', pg_search_dmetaphone(coalesce(#{Model.quoted_table_name}."content"::text, '')))) @@ (to_tsquery('simple', ''' ' || pg_search_dmetaphone('query') || ' ''')))} end end end
Version data entries
5 entries across 5 versions & 1 rubygems