Sha256: 9e61d5ee714ab7b087fe8dd9dde7cfbf75969ac84b1a03a26ec15cc6516bb104

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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: db1).as_null_object }
  let(:company2)  { mock_model(Company, database: db2).as_null_object }

  let(:api)       { Apartment::Database }

  before do
    Apartment.reset # reset all config
    Apartment.seed_after_create = false
    Apartment.use_schemas = true
    api.reload!(config)
    api.create(db1)
    api.create(db2)
  end

  after do
    api.drop(db1)
    api.drop(db2)
  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

7 entries across 7 versions & 1 rubygems

Version Path
apartment-0.24.3 spec/support/contexts.rb
apartment-0.24.2 spec/support/contexts.rb
apartment-0.24.1 spec/support/contexts.rb
apartment-0.24.0 spec/support/contexts.rb
apartment-0.23.2 spec/support/contexts.rb
apartment-0.23.1 spec/support/contexts.rb
apartment-0.23.0 spec/support/contexts.rb