Sha256: 70e9f5d8289383cc233b19935a8193c6aa9da9904fc375031ac9c6769c8245a9
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 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' end result.total.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 woody.converted_name.should == 'ydooW' woody.should be_a Person end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gummi-0.2.0 | spec/lib/gummi/repository_layer/repository_spec.rb |