Sha256: 71fe267f4db1d698760533b1067370034f8cc89e4f3f9f538a6fd85f1ab7d43d

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
module Alf
  describe Database, '.new' do

    let(:adapter){ Adapter.new(nil) }

    after do
      subject.adapter.should be_a(Adapter)
    end

    context 'on a single adapter' do
      subject{ Database.new(adapter) }

      it 'uses the specified adapter' do
        subject.adapter.should be(adapter)
      end

      it 'uses default options' do
        subject.schema_cache?.should be_true
      end
    end

    context 'on an adapter to be coerced' do
      subject{ Database.new(Path.dir) }

      it 'coerces the adapter' do
        subject.adapter.should be_a(Adapter::Folder)
      end

      it 'uses default options' do
        subject.schema_cache?.should be_true
      end
    end

    context 'when passing options' do
      subject{ Database.new(adapter, schema_cache: false) }

      it 'set the options correctly' do
        subject.schema_cache?.should be_false
      end
    end

    context 'when a block is given' do
      subject{ Database.new(adapter){|d| @seen = d } }

      it 'yields the block' do
        subject.should be_a(Database)
        @seen.should be_a(Database::Options)
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-database/database/test_new.rb
alf-core-0.14.0 spec/unit/alf-database/database/test_new.rb
alf-core-0.13.1 spec/unit/alf-database/database/test_new.rb
alf-core-0.13.0 spec/unit/alf-database/database/test_new.rb