Sha256: bc532436b49536d411e33476850023c53affd662ab6dfc143b0e58d23b21e58d

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

require 'cities'
require 'admin/countries'
require 'admin/cars'

describe Repobahn::Repository do

  context 'in the root namespace' do
    describe '#db_class' do
      it 'defaults to the singular version in the DB namespace' do
        Cities.db_class.should == DB::City
      end
    end

    describe '#entity_class' do
      it 'defaults to the singular version' do
        Cities.entity_class.should == City
      end
    end
  end

  context 'in a custom namespace' do
    describe '#db_class' do
      it 'defaults to the singular version in the DB namespace' do
        Admin::Countries.db_class.should == Admin::DB::Country
      end
    end

    describe '#entity_class' do
      it 'defaults to the singular version' do
        Admin::Countries.entity_class.should == Admin::Country
      end
    end
  end

  context 'with custom document/entity class definitions' do
    describe '#db_class' do
      it 'defaults to the singular version in the DB namespace' do
        Admin::Cars.db_class.should == Admin::DB::Vehicle
      end
    end

    describe '#entity_class' do
      it 'defaults to the singular version' do
        Admin::Cars.entity_class.should == Admin::Auto
      end
    end
  end

  describe '#db_instances_to_entities' do
    let(:db1) { DB::City.new name: 'New York' }
    let(:db2) { DB::City.new name: 'Boston' }
    let(:dbs) { [db1, db2] }

    it 'converts DB instances to Entities' do
      entities = Cities.db_instances_to_entities dbs
      entities.size.should == 2
      entities.first.should be_instance_of City
      entities.second.should be_instance_of City
      entities.first.name.should == 'New York'
      entities.second.name.should == 'Boston'
    end

    it 'returns a single Entity if a single DB instance is passed in' do
      entity = Cities.db_instances_to_entities db1
      entity.should be_instance_of City
      entity.name.should == 'New York'
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gummi-0.2.3 spec/lib/repobahn/repository_spec.rb
gummi-0.2.2 spec/lib/repobahn/repository_spec.rb
gummi-0.2.1 spec/lib/repobahn/repository_spec.rb
gummi-0.2.0 spec/lib/repobahn/repository_spec.rb