forked from textacular/textacular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
62 lines (48 loc) · 1.3 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
require "bundler/gem_tasks"
require 'active_record'
require 'rake/testtask'
require 'pry'
Rake::TestTask.new do |t|
t.libs << 'spec'
t.test_files = FileList[ 'spec/**/*_spec.rb' ]
end
task :default => :test
file 'spec/config.yml' do |t|
sh 'erb spec/config.yml.example > spec/config.yml'
end
desc 'Fire up an interactive terminal to play with'
task :console => :'db:connect' do
Pry.start
end
namespace :db do
task :connect => 'spec/config.yml' do |t|
ActiveRecord::Base.establish_connection \
YAML.load_file 'spec/config.yml'
end
task :disconnect do
ActiveRecord::Base.clear_all_connections!
end
desc 'Create the test database'
task :create do
sh 'createdb textacular'
end
desc 'Drop the test database'
task :drop => :disconnect do
sh 'dropdb textacular'
end
namespace :migrate do
desc 'Run the test database migrations'
task :up => :'db:connect' do
ActiveRecord::Migrator.up 'db/migrate'
end
desc 'Reverse the test database migrations'
task :down => :'db:connect' do
ActiveRecord::Migrator.down 'db/migrate'
end
end
task :migrate => :'migrate:up'
desc 'Create and configure the test database'
task :setup => [ :create, :migrate ]
desc 'Drop the test tables and database'
task :teardown => [ :'migrate:down', :drop ]
end