lib/tasks/landable/pgtap.rake in landable-1.13.1 vs lib/tasks/landable/pgtap.rake in landable-1.13.2
- old
+ new
@@ -1,44 +1,38 @@
namespace :landable do
namespace :pgtap do
- def has_pgprove?
- @@has_prove ||= Kernel.system('which pg_prove > /dev/null')
+ def pgprove?
+ @has_prove ||= Kernel.system('which pg_prove > /dev/null')
end
- def has_pgconfig?
- @@has_pgconfig ||= Kernel.system('which pg_config > /dev/null')
+ def pgconfig?
+ @has_pgconfig ||= Kernel.system('which pg_config > /dev/null')
end
- def has_pgtap?
+ def pgtap?
has_pgtap = false
- if has_pgconfig?
+ if pgconfig?
sharedir = "#{`pg_config | grep SHAREDIR | awk {' print $3 '}`.strip}/extension/pgtap.control"
- if File.file?("#{sharedir}")
- has_pgtap = true
- end
+ has_pgtap = true if File.file?("#{sharedir}")
end
has_pgtap
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 has_pgprove? and has_pgtap?
+ desc 'Run PGTap unit tests'
+ task :run, [:test_file] => [:environment] do |_t, _args|
+ if pgprove? && pgtap?
# Load pgtap functions into database. Will not complain if already loaded.
- ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pgtap;")
+ ActiveRecord::Base.connection.execute('CREATE EXTENSION IF NOT EXISTS pgtap;')
# Runs the tests. Wrapped pg_prove call in shell script due to issues with return values
sh "cd #{Rails.root}/../../script && ./pgtap"
else
puts "\nPGTap and/or pg_prove not installed. Skipping DB unit tests"
puts "Reference 'http://pgtap.org/documentation.html#installation' for installation instructions."
end
end
end
- task :pgtap => 'pgtap:run'
+ task pgtap: 'pgtap:run'
end