spec/lib/batch_spec.rb in assimilate-0.0.4 vs spec/lib/batch_spec.rb in assimilate-0.0.5

- old
+ new

@@ -43,19 +43,20 @@ } end it "should load the records verbatim" do @catalog.catalog.count.should == 6 - @catalog.where('_resource' => 'testdata', 'ID' => '3').should == {'ID' => '3', 'name' => 'Benjamin Franklin', 'title' => 'Sage'} + @catalog.where('_resource' => 'testdata', 'ID' => '3').should == + {'ID' => '3', 'name' => 'Benjamin Franklin', 'title' => 'Sage', 'spouse' => 'Deborah'} end it "should refuse to do a duplicate import" do - lambda {import_data("123")}.should raise_error(Assimilate::DuplicateImportError) + lambda {import_data("123")}.should raise_error(Assimilate::DuplicateImportError, "duplicate batch for datestamp 123") end it "should refuse to re-import same file" do - lambda {import_data("234")}.should raise_error(Assimilate::DuplicateImportError) + lambda {import_data("234")}.should raise_error(Assimilate::DuplicateImportError, "duplicate batch for file batch_input.csv") end it "should do all no-ops when importing identical data" do lambda {import_data("234", "duplicate_input.csv")}.should_not raise_error @batcher.stats.should == { @@ -76,13 +77,11 @@ describe "into existing catalog" do before(:all) do reset_catalog import_data("123") - end - before(:each) do import_data("345", "updates.csv") end it "should recognize changes" do @batcher.stats.should == { @@ -93,11 +92,16 @@ :deletes_count => 2, :deleted_ids => ['4', '6'], :updates_count => 1, :updated_ids => ['3'], :unchanged_count => 3, - :updated_fields => {'title' => 1} + :updated_fields => {'title' => 1, 'spouse' => 1} } @catalog.active_count.should == 5 + end + + it "should handle deleted attributes" do + franklin = @catalog.where('ID' => '3') + franklin['spouse'].should be_nil end end end