Sha256: 0a9ab61208535a8f154b0de3ce718dcf39ef8716912e574fd6f4117ec9872dee

Contents?: true

Size: 992 Bytes

Versions: 8

Compression:

Stored size: 992 Bytes

Contents

# encoding: UTF-8

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

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

8 entries across 8 versions & 1 rubygems

Version Path
arel-helpers-2.11.0 spec/env.rb
arel-helpers-2.10.0 spec/env.rb
arel-helpers-2.9.1 spec/env.rb
arel-helpers-2.9.0 spec/env.rb
arel-helpers-2.8.0 spec/env.rb
arel-helpers-2.7.0 spec/env.rb
arel-helpers-2.6.1 spec/env.rb
arel-helpers-2.6.0 spec/env.rb