-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
70 lines (58 loc) · 1.61 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
#this will be the absolute path to lib based on the calling __FILE__
lib = File.expand_path('../app', __FILE__)
#this will include the path in $LOAD_PATH unless it is already included
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
ENV["MONGODB_CFG_PATH"] ||= File.expand_path('../config', __FILE__) + "/mongoid.yml"
require "rake/testtask"
require "mongoid"
require "database_cleaner"
require "date"
require "./dashboard_init"
require "lib/app_log"
task default: [:test]
desc "Run all applicaiton tests"
Rake::TestTask.new do |t|
t.libs.push '.'
t.libs.push File.expand_path('../test', __FILE__)
t.pattern = [
"test/**/*_test.rb",
]
end
desc "Find all todo in the src code"
task :todo do
system "./scripts/todo_finder.sh > todo.txt"
system "cat todo.txt"
end
desc "Deploy application to production server"
task :deploy, [:key_file] do |t, args|
if args[:key_file].nil?
abort "rake aborted! needs key_file parameter. Usage: rake deploy[KEY_FILE]"
else
system "cd scripts && sudo ./deploy.sh " + args[:key_file]
end
end
namespace :db do
def clean_database
DatabaseCleaner.clean
return true
rescue => error
error "Error while cleaning the database: #{error}"
return false
end
task :db_config do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
# drop the previous database fixtures
if not clean_database
abort "rake aborted!"
end
end
desc "create the project fixtures"
task :seed => :db_config do
load './db/seed.rb'
end
desc "clean the database"
task :clean => :db_config do
clean_database
end
end