Created
March 29, 2011 09:30
-
-
Save kornysietsma/892082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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