Sha256: 0bf590ba69eb81d488fc5634f2a5f20609105bf20e7a1a50624a8dac3ab83522

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 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",
    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.0 Rakefile
activerecord-pg_enum-0.4.0 Rakefile
activerecord-pg_enum-0.3.0 Rakefile
activerecord-pg_enum-0.2.1 Rakefile