Permalink
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (57 sloc) 2.03 KB
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
%w[postgresql mysql mysql2 sqlite3].each do |adapter|
namespace adapter do
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = "-Ispec/connections/#{adapter}"
spec.fail_on_error = false
end
end
end
desc 'Run postgresql, mysql2 and sqlite3 tests'
task :spec do
%w[postgresql mysql mysql2 sqlite3].each do |adapter|
Rake::Task["#{adapter}:spec"].invoke
end
end
task :default => :spec
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "schema_plus #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
namespace :postgresql do
desc 'Build the PostgreSQL test databases'
task :build_databases do
%x( createdb -E UTF8 schema_plus_unittest )
end
desc 'Drop the PostgreSQL test databases'
task :drop_databases do
%x( dropdb schema_plus_unittest )
end
desc 'Rebuild the PostgreSQL test databases'
task :rebuild_databases => [:drop_databases, :build_databases]
end
task :build_postgresql_databases => 'postgresql:build_databases'
task :drop_postgresql_databases => 'postgresql:drop_databases'
task :rebuild_postgresql_databases => 'postgresql:rebuild_databases'
MYSQL_DB_USER = ENV.fetch('MYSQL_DB_USER', 'schema_plus')
namespace :mysql do
desc 'Build the MySQL test databases'
task :build_databases do
%x( echo "create DATABASE schema_plus_unittest DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci " | mysql --user=#{MYSQL_DB_USER})
end
desc 'Drop the MySQL test databases'
task :drop_databases do
%x( mysqladmin --user=#{MYSQL_DB_USER} -f drop schema_plus_unittest )
end
desc 'Rebuild the MySQL test databases'
task :rebuild_databases => [:drop_databases, :build_databases]
end
task :build_mysql_databases => 'mysql:build_databases'
task :drop_mysql_databases => 'mysql:drop_databases'
task :rebuild_mysql_databases => 'mysql:rebuild_databases'