-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathRakefile
54 lines (44 loc) · 1.4 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
require 'rake/testtask'
require 'yaml'
# To get started testing, run `crowd -c test/config load_schema`, in order to
# create and load a fresh test database, and then `rake test`.
desc 'Run all tests'
task :test => ['test:drop_db', 'test:create_db'] do
require 'minitest/autorun'
$LOAD_PATH.unshift(File.expand_path('test'))
Dir['./test/**/test_*.rb'].each {|test| require test }
end
namespace :gem do
desc 'Build and install cloud-crowd gem'
task :install do
sh "gem build cloud-crowd.gemspec"
sh "gem install #{Dir['*.gem'].join(' ')} --local --no-ri --no-rdoc"
end
desc 'Uninstall the cloud-crowd gem'
task :uninstall do
sh "sudo gem uninstall -x cloud-crowd"
end
end
namespace :test do
desc 'Wipe out local databases'
task :drop_db do
path = YAML.load(File.read('./test/config/database.yml'))[:database]
FileUtils.rm path if File.exists? path
end
desc "Create local database"
task :create_db do
load_db_code
# Load in schema
require 'cloud_crowd/schema.rb'
end
end
def load_db_code
# Load Code
require File.expand_path(File.dirname(__FILE__)) + "/lib/cloud-crowd"
config_directory = File.expand_path(File.dirname(__FILE__)) + "/test/config"
CloudCrowd.configure("#{config_directory}/config.yml")
# Connect to DB
require 'cloud_crowd/models'
CloudCrowd.configure_database("#{config_directory}/database.yml", false)
end
task :default => :test