Sha256: 22ca310f3ae2d426fa17bd0e4c63e6c9da7a40bc2c4b570fcc3e19a0c34d6944

Contents?: true

Size: 992 Bytes

Versions: 4

Compression:

Stored size: 992 Bytes

Contents

# encoding: UTF-8

require 'env/models'
require 'env/migrations'

module ArelHelpers
  class Env
    class << self

      def db_dir
        @db_dir ||= File.join(File.dirname(File.dirname(__FILE__)), "tmp")
      end

      def db_file
        @db_file ||= File.join(db_dir, "test.sqlite3")
      end

      def establish_connection
        ActiveRecord::Base.establish_connection(
          :adapter  => "sqlite3",
          :database => db_file
        )
      end

      def migrate
        CreatePostsTable.new.change
        CreateCommentsTable.new.change
        CreateAuthorsTable.new.change
        CreateFavoritesTable.new.change
        CreateCollabPostsTable.new.change
        CreateCardsTable.new.change
        CreateCardLocationsTable.new.change
        CreateLocationsTable.new.change
        CreateCommunityTicketsTable.new.change
      end

      def reset
        File.unlink(db_file) if File.exist?(db_file)
        FileUtils.mkdir_p(db_dir)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
arel-helpers-2.5.0 spec/env.rb
arel-helpers-2.4.0 spec/env.rb
arel-helpers-2.3.0 spec/env.rb
arel-helpers-2.2.0 spec/env.rb