Sha256: 3708a2d5effc5363818d6a21bb8d467c8763ce486605c734cf5201486fdcb693
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
require 'spec_helper' require 'people' describe Gummi::RepositoryLayer::Repository do let(:repository_class) { People } let(:entity_class) { Person } let(:db_class) { DB::Person } describe 'Repobahn' do it 'is included' do repository_class.should respond_to :db_class repository_class.should respond_to :entity_class repository_class.should respond_to :db_instance_to_entity end end describe '.get' do context 'existing record' do let (:db_person) { DB::Person.create name: 'Buzz Lightyear' } it 'return an entity' do person = People.get(db_person.id) person.id.should == db_person.id end end context 'missing record' do it 'returns nil' do person = People.get 'missing_id' person.should be_nil end end end describe '.search' do before do DB::Person.create name: 'Buzz Lightyear' DB::Person.create name: 'Woody' Gummi::DbLayer::DefaultIndex.refresh end it 'finds the correct documents' do result = People.search do |search| search.query_string = 'Woody' search.facets[:names] = { terms: { field: :name, all_terms: true, size: 100 } } end result.total.should == 1 result.facets.names.woody.should == 1 result.records.first.name.should == 'Woody' end it 'converts the result to entities' do result = People.search do |search| search.query_string = 'Woody' end woody = result.records.first result.facets.should be_nil woody.converted_name.should == 'ydooW' woody.should be_a Person end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gummi-0.2.2 | spec/lib/gummi/repository_layer/repository_spec.rb |
gummi-0.2.1 | spec/lib/gummi/repository_layer/repository_spec.rb |