Sha256: dedae7d8759af5cf3bd3387a8bbe75d66b5b6b203a1efd71d55d55ff70590d44
Contents?: true
Size: 1.22 KB
Versions: 6
Compression:
Stored size: 1.22 KB
Contents
require "spec_helper" describe PgSearch::Document do with_table "pg_search_documents", {}, &DOCUMENTS_SCHEMA with_model :Searchable do table model do include PgSearch multisearchable({}) end end it { should be_an(ActiveRecord::Base) } describe "callbacks" do describe "before_validation" do subject { document } let(:document) { PgSearch::Document.new(:searchable => searchable) } let(:searchable) { Searchable.new } before do # Redefine the options for multisearchable Searchable.multisearchable(multisearchable_options) end context "when searching against a single column" do let(:multisearchable_options) { {:against => :some_content} } let(:text) { "foo bar" } before do searchable.stub!(:some_content => text) document.valid? end its(:content) { should == text } end context "when searching against multiple columns" do let(:multisearchable_options) { {:against => [:attr1, :attr2]} } before do searchable.stub!(:attr1 => "1", :attr2 => "2") document.valid? end its(:content) { should == "1 2" } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems