Sha256: 0bfc62e0a214fbc96838baca570ae999f2357692a0a1aec00929ec8afaa26228

Contents?: true

Size: 871 Bytes

Versions: 2

Compression:

Stored size: 871 Bytes

Contents

namespace :landable do
  namespace :pgtap do
    def has_pgprove?
      @@has_prove ||= Kernel.system('which pg_prove > /dev/null')
    end

    desc "Run PGTap unit tests"
    task :run, [:test_file] => [ :environment ] do |t, args|
      dbdir = "#{Rails.root}/../../db"

      tests = args[:test_file] ? args[:test_file] : "*.sql"

      if not has_pgprove?
        puts "\nPGTap not installed.  Skipping DB unit tests"
        puts "Reference 'http://pgtap.org/documentation.html#installation' for installation instructions."
      else
        # Load pgtap functions into database.  Will not complain if already loaded.
        ActiveRecord::Base.connection.execute(IO.read("#{dbdir}/pgtap/pgtap.sql"))

        sh "cd #{dbdir}/test && pg_prove -d #{ActiveRecord::Base.connection.current_database} #{tests}"
      end
    end
  end

  task :pgtap => 'pgtap:run'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.7.1.rc1 lib/tasks/landable/pgtap.rake
landable-1.7.0 lib/tasks/landable/pgtap.rake