Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Created March 29, 2011 09:30
Show Gist options
  • Save kornysietsma/892082 to your computer and use it in GitHub Desktop.
Save kornysietsma/892082 to your computer and use it in GitHub Desktop.
class IngestionManager
def initialize(solrIngester, personRepository)
@solrIngester = solrIngester
@personRepository = personRepository
end
def ingestAllFromDatabase
@solrIngester.clear
@personRepository.each do |doc|
@solrIngester.addDocument(doc)
end
@solrIngester.commit
end
end
describe IngestionManager do
it "should ingest all the people from the database" do
ingester = mock('ingester')
repository = mock('repository')
manager = IngestionManager.new(ingester, repository)
person1 = mock('person1')
person2 = mock('person2')
ingester.should_receive :clear
repository.should_receive(:each).and_yield(person1).and_yield(person2)
ingester.should_receive(:addDocument).with(person1)
ingester.should_receive(:addDocument).with(person2)
ingester.should_receive :commit
manager.ingestAllFromDatabase
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment