Sha256: fde3048194ac8f8809cf9d2e05d236619984dc42a91496e7c7176047e8d58415

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'
module Alf
  describe Database, 'connect' do

    context 'without a block' do
      subject{ Database.connect(Path.dir) }

      it{ should be_a(Database::Connection) }

      it 'should not be closed' do
        subject.should_not be_closed
      end
    end

    context 'with a block' do
      subject{
        Database.connect(Path.dir){|c| 
          c.should be_a(Database::Connection)
          c.should_not be_closed
          @seen = c
        }
      }

      it 'yields the block with a connection instance' do
        subject
        @seen.should be_a(Database::Connection)
      end

      it 'close the connection at the end' do
        subject
        @seen.should be_closed
      end
    end

    context 'when passing options' do
      subject{ Database.connect(Path.dir, schema_cache: false) }

      it 'overrides default options' do
        subject.schema_cache?.should eq(false)
      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_connect.rb
alf-core-0.14.0 spec/unit/alf-database/database/test_connect.rb
alf-core-0.13.1 spec/unit/alf-database/database/test_connect.rb
alf-core-0.13.0 spec/unit/alf-database/database/test_connect.rb