Sha256: 1ec77223bd9bb125cbc5fbcd7eab8b31f5f66c2f557beeed2abe7dac15e7553e

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 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"

  ActiveRecord::Base.establish_connection(
    adapter:  "postgresql",
    port:     ENV.fetch("PGPORT", "5432"),
    username: ENV.fetch("TEST_USER") { ENV.fetch("USER", "pg_enum") },
    password: ENV["TEST_PASSWORD"]
  )
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_enum_test"), owner: ENV.fetch("TEST_USER") { ENV.fetch("USER", "pg_enum") }
    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_enum_test")
    end
  end
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-pg_enum-1.0.4 Rakefile
activerecord-pg_enum-1.0.3 Rakefile
activerecord-pg_enum-1.0.2 Rakefile
activerecord-pg_enum-1.0.1 Rakefile