forked from hauke/fidius-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
110 lines (94 loc) · 2.62 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'rubygems' if RUBY_VERSION < '1.9'
require 'rake/testtask'
require 'active_record'
require 'ci/reporter/rake/test_unit' # use this if you're using Test::Unit
$LOAD_PATH.unshift File.expand_path(File.dirname __FILE__)
require 'lib/fidius'
require 'lib/helper/fidius_db_helper'
require 'logger'
YAML::ENGINE.yamler= 'syck'
$WD = Dir.pwd
import File.join("#{$WD}","test","scenarios.rake")
# getting config dir
$CFG_D = File.join $WD, "config"
@db_helper = FIDIUS::DbHelper.new $CFG_D, $WD
namespace :debug do
desc "Print out important directories."
task :dirs do
puts "root directory: #{$WD}"
puts "config directory: #{$CFG_D}"
puts "load_path:\n\t#{$LOAD_PATH.join "\n\t"}"
end
end
namespace :db do
desc "Migrates the database."
task :migrate do
@db_helper.with_db do
Dir.chdir($WD)
ActiveRecord::Migrator.migrate("#{$CFG_D}/sql", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
end
desc "Creates the database."
task :create do
@db_helper.create_database
end
desc "Deletes the database."
task :drop do
@db_helper.drop_database
end
end
begin
require 'yard'
YARD::Rake::YardocTask.new(:doc) do |t|
t.files = ['lib/**/*.rb']
static_files = 'LICENSE'
t.options += [
'--title', 'FIDIUS Architecture',
'--private', # include private methods
'--protected', # include protected methods
'--files', static_files,
'--readme', 'README.md',
'--exclude', 'misc'
]
end
rescue LoadError
puts 'YARD not installed (gem install yard), http://yardoc.org'
end
def setup_test_enviorment
ENV['ENV'] = "test"
#ActiveRecord::Migration.verbose = false
FIDIUS::DbHelper.drop_database(connection_data)
FIDIUS::DbHelper.create_database(connection_data)
with_db {
Dir.chdir($WD)
ActiveRecord::Migrator.migrate("#{$CFG_D}/sql", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
}
end
$UNIT = 'test/unit/test_*.rb'
$FUNCTIONAL = 'test/functional/test_*.rb'
$INTEGRATION = 'test/integration/test_*.rb'
def create_test_task name, files
Rake::TestTask.new(name) do |t|
t.libs << "test"
t.test_files = (FileList[] << files)
t.verbose = true
end
end
task :test do
Rake::Task["test:all"].invoke
end
namespace :test do
create_test_task :unit, $UNIT
create_test_task :functional, $FUNCTIONAL
create_test_task :integration, $INTEGRATION
create_test_task :all, [$UNIT, $FUNCTIONAL]
end
namespace :lab do
namespace :create do
task :virtualbox do
path = File.join($CFG_D, "autogenerated_lab_config.yml")
lab_helper = FIDIUS::LabHelper.new
lab_helper.create_lab_config "virtualbox", path
end
end
end