Sha256: 4120bac558216da8b6e503faa532ea2fdc42882d75e8f15d98452e4705f39501

Contents?: true

Size: 1.11 KB

Versions: 20

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

if [ HAS_SQLITE3, HAS_MYSQL, HAS_POSTGRES ].include?(ADAPTER)
  describe DataMapper::Adapters::DataObjectsAdapter, "with #{ADAPTER}" do
    describe 'a connection' do
      before do
        @adapter  = DataMapper::Repository.adapters[ADAPTER]
        @transaction = DataMapper::Transaction.new(@adapter)

        @command = mock('command', :execute_non_query => nil)
        @connection = mock('connection', :create_command => @command)
        DataObjects::Connection.stub!(:new).and_return(@connection)
      end

      it 'should close automatically when no longer needed' do
        @connection.should_receive(:close)
        @adapter.execute('SELECT 1')
      end

      it 'should not close when a current transaction is active' do
        @connection.should_receive(:create_command).with('SELECT 1').twice.and_return(@command)
        @connection.should_not_receive(:close)

        @transaction.begin
        @transaction.within do
          @adapter.execute('SELECT 1')
          @adapter.execute('SELECT 1')
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
datamapper-dm-core-0.9.11 spec/integration/data_objects_adapter_spec.rb
joevandyk-dm-core-0.9.6 spec/integration/data_objects_adapter_spec.rb
rpbertp13-dm-core-0.9.11.1 spec/integration/data_objects_adapter_spec.rb
rpbertp13-dm-core-0.9.11.2 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.10 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.11 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.6 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.7 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.8 spec/integration/data_objects_adapter_spec.rb
sam-dm-core-0.9.9 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.10 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.11 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.2 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.5 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.3 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.4 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.6 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.7 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.9 spec/integration/data_objects_adapter_spec.rb
dm-core-0.9.8 spec/integration/data_objects_adapter_spec.rb