From 12258a562d702c0c0245ab09294e837a7b399975 Mon Sep 17 00:00:00 2001 From: James Golick Date: Mon, 25 Jan 2010 13:03:34 -0800 Subject: [PATCH] add integration spec for offline indexing --- spec/integration/offline_indexing_spec.rb | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/integration/offline_indexing_spec.rb diff --git a/spec/integration/offline_indexing_spec.rb b/spec/integration/offline_indexing_spec.rb new file mode 100644 index 0000000..e817196 --- /dev/null +++ b/spec/integration/offline_indexing_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path("../../spec_helper", __FILE__) + +describe "Building an index offline" do + before do + $db.drop_table :awesome_things if $db.table_exists?(:awesome_things) + + if $db.table_exists?(:index_awesome_things_on_name) + $db.drop_table :awesome_things_on_name + end + + @klass = Class.new do + def self.name; "AwesomeThing"; end + def self.table_name; "awesome_things"; end + + include Friendly::Document + + attribute :name, String + end + @klass.create_tables! + + @jameses = [@klass.create(:name => "James"), @klass.create(:name => "James")] + + @klass.indexes :name + @klass.create_tables! + Friendly::Indexer.populate(@klass, :name) + end + + it "builds the missing index rows for all the rows in the doc table" do + @klass.all(:name => "James").should == @jameses + end +end