Sha256: 39079be6fffe2dcc6375c56f2abb4a7d91f45d09e20029c4f36007cb4b405fb4

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "appraisal"

if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
  task :default => :appraisal
else
  task :default => :spec
end

task :connection do
  require "active_record"
  require_relative "spec/support/connection_config"

  config = db_config_hash.except(:database)

  if ActiveRecord.constants.include?(:DatabaseConfigurations)
    config = ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "primary", config)
  end

  ActiveRecord::Base.establish_connection(config)
end

namespace :spec do
  RSpec::Core::RakeTask.new(:run)

  desc "Setup the Database for testing"
  task setup: [:connection] do
    ActiveRecord::Base.connection_pool.with_connection do |conn|
      conn.create_database ENV.fetch("TEST_DATABASE", "pg_collation_test"), owner: ENV.fetch("TEST_USER") { ENV.fetch("USER", "pg_collation") }
    end
  end

  desc "Discard the test database"
  task teardown: [:connection] do
    ActiveRecord::Base.connection_pool.with_connection do |conn|
      conn.drop_database ENV.fetch("TEST_DATABASE", "pg_collation_test")
    end
  end

  task reset: [:teardown, :setup]
end

task spec: %w[spec:setup spec:run spec:teardown]

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-pg_collation-0.1.2 Rakefile
activerecord-pg_collation-0.1.1 Rakefile
activerecord-pg_collation-0.1.0 Rakefile