Sha256: f0a0049f5337a77e85fdc2ab402c2e97dfe0f9335012df9ae44c274afedef63c

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

shared_examples_for "an adapter" do

  describe 'connection' do
    subject{ adapter.connection }
    after  { subject.close      }

    it{ should be_a(Alf::Adapter::Connection) }
  end

  describe 'connect' do
    subject{ adapter.connect{|c| @seen = c} }

    it 'yields a connection object' do
      subject
      @seen.should be_a(Alf::Adapter::Connection)
    end

    it 'closes the connection afterwards' do
      subject
      @seen.should be_closed
    end

    it 'closes the connection even in case of a failure' do
      lambda{
        adapter.connect{|c|
          @seen = c
          raise ArgumentError, "connection closes on failure"
        }
      }.should raise_error(ArgumentError, "connection closes on failure")
      @seen.should be_closed
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-adapter/shared_examples/an_adapter.rb
alf-core-0.14.0 spec/unit/alf-adapter/shared_examples/an_adapter.rb
alf-core-0.13.1 spec/unit/alf-adapter/shared_examples/an_adapter.rb
alf-core-0.13.0 spec/unit/alf-adapter/shared_examples/an_adapter.rb