Sha256: 4514c4df6b8be70bc0b63a338247c53123df67c089b05a7068743b39509af6f1

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'
require 'apartment/adapters/postgresql_adapter'

describe Apartment::Adapters::PostgresqlAdapter do

  let(:config){ Apartment::Test.config['connections']['postgresql'] }
  subject{ Apartment::Database.postgresql_adapter config.symbolize_keys }

  context "using schemas" do

    before{ Apartment.use_schemas = true }

    # Not sure why, but somehow using let(:database_names) memoizes for the whole example group, not just each test
    def database_names
      ActiveRecord::Base.connection.execute("SELECT nspname FROM pg_namespace;").collect{|row| row['nspname']}
    end

    let(:default_database){ subject.process{ ActiveRecord::Base.connection.schema_search_path } }

    it_should_behave_like "a generic apartment adapter"
    it_should_behave_like "a schema based apartment adapter"
  end

  context "using databases" do

    before{ Apartment.use_schemas = false }

    # Not sure why, but somehow using let(:database_names) memoizes for the whole example group, not just each test
    def database_names
      connection.execute("select datname from pg_database;").collect{|row| row['datname']}
    end

    let(:default_database){ subject.process{ ActiveRecord::Base.connection.current_database } }

    it_should_behave_like "a generic apartment adapter"
    it_should_behave_like "a db based apartment adapter"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apartment-0.19.0 spec/adapters/postgresql_adapter_spec.rb