Sha256: 29885fe96badbc048a3e83cf9b1c8f60ebb3041ea30aa5c3a663881df1e16d08

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

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

describe DataObjects::Connection do
  before do
    @connection = DataObjects::Connection.new('mock://localhost')
  end

  after do
    @connection.release
  end

  %w{dispose create_command}.each do |meth|
    it "should respond to ##{meth}" do
      @connection.should.respond_to(meth.intern)
    end
  end

  it "should have #to_s that returns the connection uri string" do
    @connection.to_s.should == 'mock://localhost'
  end

  describe "initialization" do

    it "should accept a connection uri as a Addressable::URI" do
      c = DataObjects::Connection.new(Addressable::URI::parse('mock://localhost/database'))
      # relying on the fact that mock connection sets @uri
      c.to_s.should == 'mock://localhost/database'
    end

    it "should return the Connection specified by the scheme" do
      c = DataObjects::Connection.new(Addressable::URI.parse('mock://localhost/database'))
      c.should.be.kind_of(DataObjects::Mock::Connection)
      c.should.be.kind_of(DataObjects::Pooling)
    end

    it "should return the Connection specified by the scheme without pooling" do
      c = DataObjects::Connection.new(Addressable::URI.parse('java://jdbc/database?scheme=mock2'))
      c.should.not.be.kind_of(DataObjects::Pooling)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
data_objects-0.10.3 spec/connection_spec.rb
data_objects-0.10.2 spec/connection_spec.rb
data_objects-0.10.1 spec/connection_spec.rb