Permalink
Browse files

add integration spec for offline indexing

  • Loading branch information...
1 parent c2a5a23 commit 12258a562d702c0c0245ab09294e837a7b399975 @jamesgolick committed Jan 25, 2010
Showing with 31 additions and 0 deletions.
  1. +31 −0 spec/integration/offline_indexing_spec.rb
View
31 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

0 comments on commit 12258a5

Please sign in to comment.