Sha256: ea0b5d123b95177007bb4ecd5574f14d24abb6c3bd754599cd680fe4070e4ae8

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

Bundler.require :hstore
require 'active_record'

Superstore::Base.config = {'adapter' => 'hstore'}

class PGInitializer
  def self.initialize!
    config = {
      'adapter'   => 'postgresql',
      'encoding'  => 'unicode',
      'database'  => 'superstore_test',
      'pool'      => 5,
      'username' => 'postgres'
    }

    ActiveRecord::Base.configurations = { test: config }

    ActiveRecord::Tasks::DatabaseTasks.drop config
    ActiveRecord::Tasks::DatabaseTasks.create config
    ActiveRecord::Base.establish_connection config

    Superstore::Base.adapter.create_table('issues')
  end

  def self.table_names
    %w(issues)
  end
end

PGInitializer.initialize!

module ActiveSupport
  class TestCase
    teardown do
      PGInitializer.table_names.each do |table_name|
        ActiveRecord::Base.connection.execute "TRUNCATE #{table_name}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-1.0.0 test/support/hstore.rb