Sha256: 33945f259c53734f4c36af85279eedf29bf378869a4253b47b437d68946d4636

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'fixtures/test_model'
require 'fixtures/extra_field'
require 'spec'
require 'spec/autorun'

Spec::Runner.configure do |config|
  config.before(:suite) do
    # we create a test database if it does not exist
    # I do not use database users or password for the tests, using ident authentication instead
    begin
      ActiveRecord::Base.establish_connection(
        :adapter  => "postgresql",
        :host     => "localhost",
        :database => "ar_pg_copy_test"
      )
      ActiveRecord::Base.connection.execute %{
        SET client_min_messages TO warning;
        DROP TABLE IF EXISTS test_models; 
        DROP TABLE IF EXISTS extra_fields; 
        CREATE TABLE test_models (id serial PRIMARY KEY, data text);
        CREATE TABLE extra_fields (id serial PRIMARY KEY, data text, created_at timestamp, updated_at timestamp);
}
    rescue Exception => e
      puts "RESCUE"
      ActiveRecord::Base.establish_connection(
        :adapter  => "postgresql",
        :host     => "localhost",
        :database => "postgres"
      )
      ActiveRecord::Base.connection.execute "CREATE DATABASE ar_pg_copy_test"
      retry
    end
  end

end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
postgres-copy-0.3.2 spec/spec_helper.rb
postgres-copy-0.3.1 spec/spec_helper.rb
activerecord-postgres-copy-0.2.2 spec/spec_helper.rb