Sha256: b50d5b136096d6afa77ecef3aef84abe08f0f4f823daf6fc48986c2e6beeba8f

Contents?: true

Size: 1.53 KB

Versions: 5

Compression:

Stored size: 1.53 KB

Contents

#   Some shared contexts for specs

shared_context "with default schema", :default_schema => true do
  let(:default_schema){ Apartment::Test.next_db }

  before do
    Apartment::Test.create_schema(default_schema)
    Apartment.default_schema = default_schema
  end

  after do
    # resetting default_schema so we can drop and any further resets won't try to access droppped schema
    Apartment.default_schema = nil
    Apartment::Test.drop_schema(default_schema)
  end
end

# Some default setup for elevator specs
shared_context "elevators", :elevator => true do
   let(:company1)  { mock_model(Company, :database => Apartment::Test.next_db).as_null_object }
   let(:company2)  { mock_model(Company, :database => Apartment::Test.next_db).as_null_object }

   let(:database1) { company1.database }
   let(:database2) { company2.database }

   let(:api)       { Apartment::Database }

   before do
     Apartment.reset # reset all config
     Apartment.seed_after_create = false
     Apartment.use_postgres_schemas = true
     api.reload! # reload adapter

     api.create(database1)
     api.create(database2)
   end

   after do
     api.drop(database1)
     api.drop(database2)
  end
end

shared_context "persistent_schemas", :persistent_schemas => true do
  let(:persistent_schemas){ ['hstore', 'postgis'] }

  before do
    persistent_schemas.map{|schema| subject.create(schema) }
    Apartment.persistent_schemas = persistent_schemas
  end

  after do
    Apartment.persistent_schemas = []
    persistent_schemas.map{|schema| subject.drop(schema) }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
apartment-0.18.0 spec/support/contexts.rb
apartment-0.17.3 spec/support/contexts.rb
apartment-0.17.2 spec/support/contexts.rb
apartment-0.17.1 spec/support/contexts.rb
apartment-0.17.0 spec/support/contexts.rb