-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRakefile
35 lines (30 loc) · 871 Bytes
/
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
require "bundler/gem_tasks"
require "rspec/core/rake_task"
def create_database(dbname)
require "pg"
c = PG::Connection.new(:dbname => "postgres")
c.async_exec("CREATE DATABASE #{dbname}")
rescue PG::DuplicateDatabase => err
raise unless err.message =~ /already exists/
end
def drop_database(dbname)
require "pg"
c = PG::Connection.new(:dbname => "postgres")
c.async_exec("DROP DATABASE #{dbname}")
rescue PG::InvalidCatalogName => err
raise unless err.message =~ /does not exist/
end
namespace :spec do
desc "Setup the test databases"
task :setup => :teardown do
create_database("logical_test")
create_database("logical_test_target")
end
desc "Teardown the test databases"
task :teardown do
drop_database("logical_test")
drop_database("logical_test_target")
end
end
RSpec::Core::RakeTask.new(:spec)
task :default => :spec