-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rakefile
70 lines (57 loc) · 1.93 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
%w[postgresql mysql mysql2].each do |adapter|
namespace adapter do
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = "-Ispec/connections/#{adapter}"
end
end
end
desc 'Run postgresql and mysql tests'
task :spec do
%w[postgresql mysql mysql2].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 = "automatic_foreign_key #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
DBNAME = "afk_unittest"
namespace :postgresql do
desc 'Build the PostgreSQL test databases'
task :build_databases do
%x( createdb -E UTF8 #{DBNAME} )
end
desc 'Drop the PostgreSQL test databases'
task :drop_databases do
%x( dropdb #{DBNAME} )
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 = 'afk'
namespace :mysql do
desc 'Build the MySQL test databases'
task :build_databases do
%x( echo "create DATABASE #{DBNAME} 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 #{DBNAME} )
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'