Sha256: b0e95a3d514927844d48dcab87299d7f40c2f57678732cfa040abf94be5b45de

Contents?: true

Size: 640 Bytes

Versions: 4

Compression:

Stored size: 640 Bytes

Contents

module Apartment
  module Test
    def self.reset
      Apartment::Database.instance_variable_set :@initialized, nil
      Apartment.excluded_models = nil
      Apartment.use_postgres_schemas = nil
    end
    
    def self.drop_schema(schema)
      ActiveRecord::Base.silence{ ActiveRecord::Base.connection.execute("DROP SCHEMA IF EXISTS #{schema} CASCADE") }
    end
    
    def self.create_schema(schema)
      ActiveRecord::Base.connection.execute("CREATE SCHEMA #{schema}")
    end
    
    def self.in_database(db)
      Apartment::Database.switch db
      yield if block_given?
      Apartment::Database.reset
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apartment-0.9.2 spec/support/apartment_helpers.rb
apartment-0.9.1 spec/support/apartment_helpers.rb
apartment-0.9.0 spec/support/apartment_helpers.rb
apartment-0.8.0 spec/support/apartment_helpers.rb