Sha256: b0f21665f87af2f225e70c25627cbf66782d5a7214556aa9edc26df661d9b96d

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

ar_config = { adapter: 'sqlite3', database: ':memory:'}

case ENV['DB']
when /mysql/i
  create_sql = 'CREATE DATABASE plugin_dev DEFAULT CHARACTER SET utf8;'
  if /:(.*)$/ =~ ENV['DB']
    create_sql.sub! ';', " DEFAULT COLLATE #{$1};"
  end

  `mysql -u root -e "DROP DATABASE IF EXISTS plugin_dev; #{create_sql}"`
   ar_config = { adapter: 'mysql2', database: 'plugin_dev',
                 username: 'root', password: '' }
when /pg/i
  pg_user = ENV['DB_USER'] || ENV['USER']
  `psql -U #{pg_user} -d postgres -c "DROP DATABASE IF EXISTS plugin_dev;"`
  `psql -U #{pg_user} -d postgres -c "CREATE DATABASE plugin_dev;"`
  ar_config = { adapter: 'postgresql', database: 'plugin_dev',
                username: pg_user, password: '' }
end

ActiveRecord::Base.configurations = { 'test' => ar_config }
ActiveRecord::Base.establish_connection :test

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
file_blobs_rails-0.2.3 test/helpers/db_setup.rb
file_blobs_rails-0.2.2 test/helpers/db_setup.rb
file_blobs_rails-0.2.1 test/helpers/db_setup.rb
file_blobs_rails-0.2.0 test/helpers/db_setup.rb
file_blobs_rails-0.1.0 test/helpers/db_setup.rb