forked from alexreisner/geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
78 lines (64 loc) · 1.92 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
71
72
73
74
75
76
77
78
require 'bundler'
Bundler::GemHelper.install_tasks
ACCEPTED_DB_VALUES = %w(sqlite postgres mysql)
DATABASE_CONFIG_FILE = 'test/database.yml'
def config
require 'yaml'
YAML.load(File.open(DATABASE_CONFIG_FILE))
end
namespace :db do
task :create do
if ACCEPTED_DB_VALUES.include? ENV['DB']
Rake::Task["db:#{ENV['DB']}:create"].invoke
end
end
task :drop do
if ACCEPTED_DB_VALUES.include? ENV['DB']
Rake::Task["db:#{ENV['DB']}:drop"].invoke
end
end
task :reset => [:drop, :create]
namespace :mysql do
desc 'Create the MySQL test databases'
task :create do
`mysql --user=#{config['mysql']['username']} -e "create DATABASE #{config['mysql']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci "`
end
desc 'Drop the MySQL test databases'
task :drop do
`mysqladmin --user=#{config['mysql']['username']} -f drop #{config['mysql']['database']}`
end
end
namespace :postgres do
desc 'Create the PostgreSQL test databases'
task :create do
`createdb -E UTF8 -T template0 #{config['postgres']['database']}`
end
desc 'Drop the PostgreSQL test databases'
task :drop do
`dropdb #{config['postgres']['database']}`
end
end
namespace :sqlite do
task :drop
task :create
end
end
require 'rake/testtask'
desc "Use DB to test with #{ACCEPTED_DB_VALUES}, otherwise test standalone"
Rake::TestTask.new(:test) do |test|
Rake::Task['db:reset'].invoke if ACCEPTED_DB_VALUES.include? ENV['DB']
test.libs << 'lib' << 'test'
test.pattern = 'test/unit/**/*_test.rb'
end
Rake::TestTask.new(:integration) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/integration/*_test.rb'
end
task :default => [:test]
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "Geocoder #{Geocoder::VERSION}"
rdoc.rdoc_files.include('*.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end